Skip to content

Commit

Permalink
remove orf dummy urls
Browse files Browse the repository at this point in the history
  • Loading branch information
codingPF committed Apr 12, 2024
1 parent d2dbf7e commit 493295c
Showing 1 changed file with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class OrfOnEpisodeDeserializer implements JsonDeserializer<OrfOnVideoInfo

private static final String[] TAG_SUBTITLE_SECTION = {"_embedded", "subtitle"};
private static final String TAG_SUBTITLE_TTML = "ttml_url";
private static final String[] PREFERED_CODEC = {"hls", "hds", "streaming", "progressive"};
private static final String[] PREFERED_CODEC = {"hls", "hds", "progressive"};
//
private final OrfHttpClient connection;
//
Expand Down Expand Up @@ -145,22 +145,19 @@ private Optional<Map<Qualities, String>> parseUrl(JsonElement jsonElement) {
return Optional.empty();
}
// We need to fallback to episode.sources in case there are many elements in the playlist
if (videoPath1.get().getAsJsonArray().size() > 1) {
return parseFallbackVideo(jsonElement);
}

Optional<JsonElement> videoPath2 = JsonUtils.getElement(videoPath1.get().getAsJsonArray().get(0), TAG_VIDEO_PATH_2);
if (videoPath2.isEmpty() || !videoPath2.get().isJsonArray()) {
return Optional.empty();
}
for (String key : PREFERED_CODEC) {
Optional<Map<Qualities, String>> resultingVideos = readVideoForTargetCodec(videoPath2.get(), key);
if (resultingVideos.isPresent()) {
return resultingVideos;
if (videoPath1.get().getAsJsonArray().size() == 1) {
Optional<JsonElement> videoPath2 = JsonUtils.getElement(videoPath1.get().getAsJsonArray().get(0), TAG_VIDEO_PATH_2);
if (videoPath2.isEmpty() || !videoPath2.get().isJsonArray()) {
return Optional.empty();
}
for (String key : PREFERED_CODEC) {
Optional<Map<Qualities, String>> resultingVideos = readVideoForTargetCodec(videoPath2.get(), key);
if (resultingVideos.isPresent()) {
return resultingVideos;
}
}
}

return Optional.empty();
return parseFallbackVideo(jsonElement);
}

private Optional<Map<Qualities, String>> parseFallbackVideo(JsonElement root) {
Expand All @@ -172,7 +169,7 @@ private Optional<Map<Qualities, String>> parseFallbackVideo(JsonElement root) {
if (codecs.isPresent() && codecs.get().isJsonArray()) {
for (JsonElement singleVideo : codecs.get().getAsJsonArray()) {
Optional<String> tgtUrl = JsonUtils.getElementValueAsString(singleVideo, TAG_VIDEO_FALLBACK_URL);
if (tgtUrl.isPresent()) {
if (tgtUrl.isPresent() && !tgtUrl.get().contains("/Jugendschutz") && !tgtUrl.get().contains("/no_drm_support") && !tgtUrl.get().contains("/schwarzung")) {
urls.put(Qualities.NORMAL, tgtUrl.get());
return Optional.of(urls);
}
Expand All @@ -190,9 +187,11 @@ private Optional<Map<Qualities, String>> readVideoForTargetCodec(JsonElement url
Optional<String> qualityValue = JsonUtils.getElementValueAsString(videoElement, TAG_VIDEO_QUALITY);
Optional<String> url = JsonUtils.getElementValueAsString(videoElement, TAG_VIDEO_URL);
if (url.isPresent() && codec.isPresent() && qualityValue.isPresent() && targetCodec.equalsIgnoreCase(codec.get()) && OrfOnEpisodeDeserializer.getQuality(qualityValue.get()).isPresent()) {
final Optional<Qualities> quality = OrfOnEpisodeDeserializer.getQuality(qualityValue.get());
if (quality.isPresent()) {
urls.put(quality.get(), url.get());
if (!url.get().contains("/Jugendschutz") && !url.get().contains("/no_drm_support") && !url.get().contains("/schwarzung")) {
final Optional<Qualities> quality = OrfOnEpisodeDeserializer.getQuality(qualityValue.get());
if (quality.isPresent()) {
urls.put(quality.get(), url.get());
}
}
}
}
Expand Down

0 comments on commit 493295c

Please sign in to comment.