From 93b0c5b15fe6a2e2e4b79b8236dc306445189fe0 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Sat, 5 Jun 2021 00:34:54 +0200 Subject: [PATCH 1/8] Added seekbar data --- .../services/youtube/YoutubeService.java | 5 +++++ .../newpipe/extractor/stream/StreamInfo.java | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java index 07db99a364..eaccfd0b81 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java @@ -175,6 +175,11 @@ public ListLinkHandlerFactory getCommentsLHFactory() { return YoutubeCommentsLinkHandlerFactory.getInstance(); } + @Override + public StreamExtractor getStreamExtractor(String url) throws ExtractionException { + return super.getStreamExtractor(url); + } + @Override public CommentsExtractor getCommentsExtractor(ListLinkHandler urlIdHandler) throws ExtractionException { 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 56809aa166..99d52371d3 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 @@ -335,6 +335,12 @@ private static StreamInfo extractOptionalData(StreamInfo streamInfo, StreamExtra streamInfo.addError(e); } + try { + streamInfo.setFrames(extractor.getFrames()); + } catch (Exception e) { + streamInfo.addError(e); + } + streamInfo.setRelatedItems(ExtractorHelper.getRelatedItemsOrLogError(streamInfo, extractor)); return streamInfo; @@ -386,6 +392,11 @@ private static StreamInfo extractOptionalData(StreamInfo streamInfo, StreamExtra private List streamSegments = new ArrayList<>(); private List metaInfo = new ArrayList<>(); + /** + * Frames, e.g. for the storyboard / seekbar thumbnail preview + */ + private List frames = new ArrayList<>(); + /** * Get the stream type * @@ -711,6 +722,14 @@ public void setMetaInfo(final List metaInfo) { this.metaInfo = metaInfo; } + public List getFrames() { + return frames; + } + + public void setFrames(List frames) { + this.frames = frames; + } + @Nonnull public List getMetaInfo() { return this.metaInfo; From b086655d54d5d94552ca89f52b3e55611bcdf640 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Sat, 5 Jun 2021 22:25:36 +0200 Subject: [PATCH 2/8] Reverted useless change --- .../newpipe/extractor/services/youtube/YoutubeService.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java index eaccfd0b81..07db99a364 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java @@ -175,11 +175,6 @@ public ListLinkHandlerFactory getCommentsLHFactory() { return YoutubeCommentsLinkHandlerFactory.getInstance(); } - @Override - public StreamExtractor getStreamExtractor(String url) throws ExtractionException { - return super.getStreamExtractor(url); - } - @Override public CommentsExtractor getCommentsExtractor(ListLinkHandler urlIdHandler) throws ExtractionException { From 09b670d7452c0e5ac3390bc6975496f480b91ad5 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Sat, 5 Jun 2021 22:29:39 +0200 Subject: [PATCH 3/8] Renamed frames to previewFrames (so it's better understandable) --- .../newpipe/extractor/stream/StreamInfo.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 99d52371d3..1819f59895 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 @@ -336,7 +336,7 @@ private static StreamInfo extractOptionalData(StreamInfo streamInfo, StreamExtra } try { - streamInfo.setFrames(extractor.getFrames()); + streamInfo.setPreviewFrames(extractor.getFrames()); } catch (Exception e) { streamInfo.addError(e); } @@ -393,9 +393,9 @@ private static StreamInfo extractOptionalData(StreamInfo streamInfo, StreamExtra private List metaInfo = new ArrayList<>(); /** - * Frames, e.g. for the storyboard / seekbar thumbnail preview + * Preview frames, e.g. for the storyboard / seekbar thumbnail preview */ - private List frames = new ArrayList<>(); + private List previewFrames = new ArrayList<>(); /** * Get the stream type @@ -722,12 +722,12 @@ public void setMetaInfo(final List metaInfo) { this.metaInfo = metaInfo; } - public List getFrames() { - return frames; + public List getPreviewFrames() { + return previewFrames; } - public void setFrames(List frames) { - this.frames = frames; + public void setPreviewFrames(final List previewFrames) { + this.previewFrames = previewFrames; } @Nonnull From 4e41e172eabf9abae67388ba64c0761d90012e42 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Sun, 6 Jun 2021 22:01:03 +0200 Subject: [PATCH 4/8] Update Frameset.java Reformatted code --- .../newpipe/extractor/stream/Frameset.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Frameset.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Frameset.java index d9bbc70ade..d327a91056 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Frameset.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Frameset.java @@ -4,15 +4,23 @@ public final class Frameset { - private List urls; - private int frameWidth; - private int frameHeight; - private int totalCount; - private int durationPerFrame; - private int framesPerPageX; - private int framesPerPageY; - - public Frameset(List urls, int frameWidth, int frameHeight, int totalCount, int durationPerFrame, int framesPerPageX, int framesPerPageY) { + private final List urls; + private final int frameWidth; + private final int frameHeight; + private final int totalCount; + private final int durationPerFrame; + private final int framesPerPageX; + private final int framesPerPageY; + + public Frameset( + final List urls, + final int frameWidth, + final int frameHeight, + final int totalCount, + final int durationPerFrame, + final int framesPerPageX, + final int framesPerPageY) { + this.urls = urls; this.totalCount = totalCount; this.durationPerFrame = durationPerFrame; @@ -86,7 +94,7 @@ public int getDurationPerFrame() { *
  • 4: Bottom bound
  • * */ - public int[] getFrameBoundsAt(long position) { + public int[] getFrameBoundsAt(final long position) { if (position < 0 || position > ((totalCount + 1) * durationPerFrame)) { // Return the first frame as fallback return new int[] { 0, 0, 0, frameWidth, frameHeight }; From 17ccaf4b877399de28609b9279ca4c3123bdb13a Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Tue, 8 Jun 2021 20:30:13 +0200 Subject: [PATCH 5/8] Update YoutubeStreamExtractor.java To fix ``java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference`` --- .../youtube/extractors/YoutubeStreamExtractor.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java index ad2b1f7db5..a5b8093702 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java @@ -1049,7 +1049,16 @@ public List getFrames() throws ExtractionException { storyboardsRenderer = storyboards.getObject("playerStoryboardSpecRenderer"); } - final String[] spec = storyboardsRenderer.getString("spec").split("\\|"); + if (storyboardsRenderer == null) { + return new ArrayList<>(); + } + + final String storyboardsRendererSpec = storyboardsRenderer.getString("spec"); + if (storyboardsRendererSpec == null) { + return new ArrayList<>(); + } + + final String[] spec = storyboardsRendererSpec.split("\\|"); final String url = spec[0]; final ArrayList result = new ArrayList<>(spec.length - 1); From 0f9ed020a40c58a33daddc2dcc993e1c8a07b6e2 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Tue, 8 Jun 2021 21:03:48 +0200 Subject: [PATCH 6/8] Frameset has to implement Serializable or NewPipe fails java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = org.schabi.newpipe.extractor.stream.StreamInfo) ... Caused by: java.io.NotSerializableException: org.schabi.newpipe.extractor.stream.Frameset ... --- .../java/org/schabi/newpipe/extractor/stream/Frameset.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Frameset.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Frameset.java index d327a91056..d07a0b7b93 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Frameset.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Frameset.java @@ -1,8 +1,9 @@ package org.schabi.newpipe.extractor.stream; +import java.io.Serializable; import java.util.List; -public final class Frameset { +public final class Frameset implements Serializable { private final List urls; private final int frameWidth; From ecf4232ce311c4d6cb690c626634ba54200e7528 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Tue, 15 Jun 2021 21:58:00 +0200 Subject: [PATCH 7/8] Using ``Collections.emptyList()`` --- .../services/youtube/extractors/YoutubeStreamExtractor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java index a5b8093702..8cc60b24d4 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java @@ -1050,12 +1050,12 @@ public List getFrames() throws ExtractionException { } if (storyboardsRenderer == null) { - return new ArrayList<>(); + return Collections.emptyList(); } final String storyboardsRendererSpec = storyboardsRenderer.getString("spec"); if (storyboardsRendererSpec == null) { - return new ArrayList<>(); + return Collections.emptyList(); } final String[] spec = storyboardsRendererSpec.split("\\|"); From 0c12b396e5c084e9666b818553dcafec8222f8c8 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Sun, 27 Jun 2021 14:42:32 +0200 Subject: [PATCH 8/8] Review changes --- .../java/org/schabi/newpipe/extractor/stream/StreamInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1819f59895..12affe4d19 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 @@ -395,7 +395,7 @@ private static StreamInfo extractOptionalData(StreamInfo streamInfo, StreamExtra /** * Preview frames, e.g. for the storyboard / seekbar thumbnail preview */ - private List previewFrames = new ArrayList<>(); + private List previewFrames = Collections.emptyList(); /** * Get the stream type