diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java index 8a4ecf05f..e46a63a53 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java @@ -288,4 +288,19 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor { throw new ParsingException("Could not parse date from premiere: \"" + startTime + "\""); } } + + @Nullable + @Override + public String getShortDescription() throws ParsingException { + + if (videoInfo.has("detailedMetadataSnippets")) { + return getTextFromObject(videoInfo.getArray("detailedMetadataSnippets").getObject(0).getObject("snippetText")); + } + + if (videoInfo.has("descriptionSnippet")) { + return getTextFromObject(videoInfo.getObject("descriptionSnippet")); + } + + return null; + } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java index 8f2d42437..61690df7e 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java @@ -32,6 +32,7 @@ public class StreamInfoItem extends InfoItem { private final StreamType streamType; private String uploaderName; + private String shortDescription; private String textualUploadDate; @Nullable private DateWrapper uploadDate; @@ -92,6 +93,14 @@ public class StreamInfoItem extends InfoItem { this.uploaderAvatarUrl = uploaderAvatarUrl; } + public String getShortDescription() { + return shortDescription; + } + + public void setShortDescription(final String shortDescription) { + this.shortDescription = shortDescription; + } + @Nullable public String getTextualUploadDate() { return textualUploadDate; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java index 6d61ee441..21aa25f2b 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java @@ -116,4 +116,14 @@ public interface StreamInfoItemExtractor extends InfoItemExtractor { @Nullable DateWrapper getUploadDate() throws ParsingException; + + /** + * Get the video's short description. + * + * @return The video's short description or {@code null} if not provided by the service. + * @throws ParsingException if there is an error in the extraction + */ + @Nullable + default String getShortDescription() throws ParsingException { return null; } + } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemsCollector.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemsCollector.java index ae00a1b7f..01909c26e 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemsCollector.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemsCollector.java @@ -101,6 +101,11 @@ public class StreamInfoItemsCollector extends InfoItemsCollector