From 4cccd33f3da13f57e6b04e3dcc2697f1e3fe8535 Mon Sep 17 00:00:00 2001 From: chowder <16789070+chowder@users.noreply.github.com> Date: Tue, 18 Oct 2022 23:10:17 +0100 Subject: [PATCH] Implement isShortFormContent for StreamExtractor and StreamInfo --- .../newpipe/extractor/stream/StreamExtractor.java | 10 ++++++++++ .../newpipe/extractor/stream/StreamInfo.java | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java index ab922b1c..5a5b8607 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java @@ -554,6 +554,16 @@ public abstract class StreamExtractor extends Extractor { return Collections.emptyList(); } + /** + * Whether the stream is a short-form content. These are content in the style of TikTok, + * YouTube Shorts, or Instagram Reels videos. + * + * @return whether the stream is a short-form content + */ + public boolean isShortFormContent() throws ParsingException { + return false; + } + public enum Privacy { PUBLIC, UNLISTED, 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 8d3f2c52..fa979c34 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 @@ -342,6 +342,11 @@ public class StreamInfo extends Info { } catch (final Exception e) { streamInfo.addError(e); } + try { + streamInfo.setShortFormContent(extractor.isShortFormContent()); + } catch (final Exception e) { + streamInfo.addError(e); + } streamInfo.setRelatedItems(ExtractorHelper.getRelatedItemsOrLogError(streamInfo, extractor)); @@ -389,6 +394,7 @@ public class StreamInfo extends Info { private List tags = new ArrayList<>(); private List streamSegments = new ArrayList<>(); private List metaInfo = new ArrayList<>(); + private boolean shortFormContent = false; /** * Preview frames, e.g. for the storyboard / seekbar thumbnail preview @@ -724,4 +730,12 @@ public class StreamInfo extends Info { public List getMetaInfo() { return this.metaInfo; } + + public boolean isShortFormContent() { + return shortFormContent; + } + + public void setShortFormContent(final boolean isShortFormContent) { + this.shortFormContent = isShortFormContent; + } }