Skip to content

Commit 6fafc76

Browse files
committed
FUNK: fix NumberFormatException
2 parents b808bfa + 6b1e9be commit 6fafc76

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ sourceCompatibility = 1.8
1717
targetCompatibility = 1.8
1818
group = 'de.mediathekview'
1919
archivesBaseName = "MServer"
20-
version = '3.1.195'
20+
version = '3.1.196'
2121

2222
def jarName = 'MServer.jar'
2323
def mainClass = 'mServer.Main'

src/main/java/mServer/crawler/sender/funk/json/NexxCloudVideoDetailsDeserializer.java

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package mServer.crawler.sender.funk.json;
22

33
import com.google.gson.*;
4+
import de.mediathekview.mlib.tool.Log;
45
import mServer.crawler.sender.base.FilmUrlInfoDto;
56
import mServer.crawler.sender.base.JsonUtils;
7+
import org.apache.logging.log4j.LogManager;
8+
import org.apache.logging.log4j.Logger;
69

710
import java.lang.reflect.Type;
811
import java.util.Arrays;
@@ -13,7 +16,7 @@
1316

1417
public class NexxCloudVideoDetailsDeserializer implements JsonDeserializer<Set<FilmUrlInfoDto>> {
1518
// https://[result.streamdata.cdnShieldProgHTTP]/[result.streamdata.azureLocator]/[result.general.ID]_src_[result.streamdata.azureFileDistribution].mp4
16-
private static final String VIDEO_FILE_URL_PATTERN = "https://%s%s/%s_src_%dx%d_%d.mp4";
19+
private static final String VIDEO_FILE_URL_PATTERN = "https://%s%s/%s_src_%dx%d_%s.mp4";
1720
// globalstatic+details["qAccount"]+"/files/"+details["qPrefix"]+"/"+details["qLocator"]+"/"+ss+".mp4"
1821
private static final String VIDEO_FILE_URL_PATTERN_3Q = "https://%s%s/files/%s/%s/%s.mp4";
1922
private static final String TAG_RESULT = "result";
@@ -33,6 +36,9 @@ public class NexxCloudVideoDetailsDeserializer implements JsonDeserializer<Set<F
3336
private static final String STREAMDATA_CDN_TYPE = "cdnType";
3437
private static final String STREAMDATA_SSH_HOST = "cdnShieldHTTPS";
3538

39+
private static final Logger LOGGER =
40+
LogManager.getLogger(NexxCloudVideoDetailsDeserializer.class);
41+
3642
@Override
3743
public Set<FilmUrlInfoDto> deserialize(
3844
final JsonElement jsonElement, final Type typeOfT, final JsonDeserializationContext context)
@@ -163,15 +169,20 @@ private Optional<NexxResolutionDTO> toResolution(final String resolutionText) {
163169
final String[] resolutionTextSplitted = resolutionText.split(SPLITERATOR_COLON);
164170
Optional<String> fileId = Optional.empty();
165171
if (resolutionTextSplitted.length >= 2) {
166-
final int size = Integer.parseInt(resolutionTextSplitted[0]);
167-
final String[] reolutions = resolutionTextSplitted[1].split(SPLITERATOR_X);
168-
if (reolutions.length == 2) {
169-
final int width = Integer.parseInt(clearNumber(reolutions[0]));
170-
final int height = Integer.parseInt(clearNumber(reolutions[1]));
171-
if (resolutionTextSplitted.length > 2) {
172-
fileId = Optional.of(resolutionTextSplitted[2]);
172+
try {
173+
final String size = resolutionTextSplitted[0].replaceAll("^0+(?!$)", "");
174+
final String[] reolutions = resolutionTextSplitted[1].split(SPLITERATOR_X);
175+
if (reolutions.length == 2) {
176+
final int width = Integer.parseInt(clearNumber(reolutions[0]));
177+
final int height = Integer.parseInt(clearNumber(reolutions[1]));
178+
if (resolutionTextSplitted.length > 2) {
179+
fileId = Optional.of(resolutionTextSplitted[2]);
180+
}
181+
return Optional.of(new NexxResolutionDTO(width, height, size, fileId));
173182
}
174-
return Optional.of(new NexxResolutionDTO(width, height, size, fileId));
183+
} catch (NumberFormatException e) {
184+
LOGGER.error(e);
185+
Log.errorLog(62345326, e);
175186
}
176187
}
177188
return Optional.empty();

src/main/java/mServer/crawler/sender/funk/json/NexxResolutionDTO.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
public class NexxResolutionDTO {
77
private final int widht;
88
private final int height;
9-
private final int size;
9+
private final String size;
1010
private Optional<String> fileId;
1111

12-
public NexxResolutionDTO(final int widht, final int height, final int size, Optional<String> aFileId) {
12+
public NexxResolutionDTO(final int widht, final int height, final String size, Optional<String> aFileId) {
1313
this.widht = widht;
1414
this.height = height;
1515
this.size = size;
@@ -24,7 +24,7 @@ public int getHeight() {
2424
return height;
2525
}
2626

27-
public int getSize() {
27+
public String getSize() {
2828
return size;
2929
}
3030

@@ -41,7 +41,7 @@ public boolean equals(final Object o) {
4141
return false;
4242
}
4343
final NexxResolutionDTO that = (NexxResolutionDTO) o;
44-
return widht == that.widht && height == that.height && size == that.size;
44+
return widht == that.widht && height == that.height && Objects.equals(size, that.size);
4545
}
4646

4747
@Override

0 commit comments

Comments
 (0)