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..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 @@ -1049,7 +1049,16 @@ public List getFrames() throws ExtractionException { storyboardsRenderer = storyboards.getObject("playerStoryboardSpecRenderer"); } - final String[] spec = storyboardsRenderer.getString("spec").split("\\|"); + if (storyboardsRenderer == null) { + return Collections.emptyList(); + } + + final String storyboardsRendererSpec = storyboardsRenderer.getString("spec"); + if (storyboardsRendererSpec == null) { + return Collections.emptyList(); + } + + final String[] spec = storyboardsRendererSpec.split("\\|"); final String url = spec[0]; final ArrayList result = new ArrayList<>(spec.length - 1); 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..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,18 +1,27 @@ package org.schabi.newpipe.extractor.stream; +import java.io.Serializable; import java.util.List; -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) { +public final class Frameset implements Serializable { + + 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 +95,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 }; 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..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 @@ -335,6 +335,12 @@ private static StreamInfo extractOptionalData(StreamInfo streamInfo, StreamExtra streamInfo.addError(e); } + try { + streamInfo.setPreviewFrames(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<>(); + /** + * Preview frames, e.g. for the storyboard / seekbar thumbnail preview + */ + private List previewFrames = Collections.emptyList(); + /** * Get the stream type * @@ -711,6 +722,14 @@ public void setMetaInfo(final List metaInfo) { this.metaInfo = metaInfo; } + public List getPreviewFrames() { + return previewFrames; + } + + public void setPreviewFrames(final List previewFrames) { + this.previewFrames = previewFrames; + } + @Nonnull public List getMetaInfo() { return this.metaInfo;