From fa57ec08d2617668bd48c1a4d9c6cf9ca846f053 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Fri, 26 Aug 2022 16:52:38 +0200 Subject: [PATCH] Code improvements * Throw ContentNotSupportedExceptions when extracting (as was done before) --- .../YoutubeOtfDashManifestCreator.java | 8 +++----- .../org/schabi/newpipe/extractor/stream/StreamInfo.java | 4 ++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreator/YoutubeOtfDashManifestCreator.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreator/YoutubeOtfDashManifestCreator.java index a29f48a63..4762d3587 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreator/YoutubeOtfDashManifestCreator.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreator/YoutubeOtfDashManifestCreator.java @@ -50,11 +50,9 @@ public class YoutubeOtfDashManifestCreator extends AbstractYoutubeDashManifestCr // Get all durations and repetitions which are separated by a comma .split(","); final int lastIndex = segmentsAndDurationsResponseSplit.length - 1; - if (isBlank(segmentsAndDurationsResponseSplit[lastIndex])) { - segmentDurations = Arrays.copyOf(segmentsAndDurationsResponseSplit, lastIndex); - } else { - segmentDurations = segmentsAndDurationsResponseSplit; - } + segmentDurations = isBlank(segmentsAndDurationsResponseSplit[lastIndex]) + ? Arrays.copyOf(segmentsAndDurationsResponseSplit, lastIndex) + : segmentsAndDurationsResponseSplit; } catch (final Exception e) { throw new DashManifestCreationException("Could not get segment durations", e); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java index 5b5710945..2c16ce71b 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java @@ -523,6 +523,8 @@ public class StreamInfo extends Info { /* Extract video stream url */ try { streamInfo.setVideoStreams(extractor.getVideoStreams()); + } catch (final ContentNotSupportedException e) { + throw e; } catch (final Exception e) { streamInfo.addError(new ExtractionException("Couldn't get video streams", e)); } @@ -530,6 +532,8 @@ public class StreamInfo extends Info { /* Extract video only stream url */ try { streamInfo.setVideoOnlyStreams(extractor.getVideoOnlyStreams()); + } catch (final ContentNotSupportedException e) { + throw e; } catch (final Exception e) { streamInfo.addError(new ExtractionException("Couldn't get video only streams", e)); }