From 4349be13af66aaf9af4c244d53cce1702b3a0782 Mon Sep 17 00:00:00 2001 From: Stypox Date: Thu, 9 Apr 2020 18:18:43 +0200 Subject: [PATCH] [PeerTube] Return empty audio stream list instead of null --- .../extractors/PeertubeStreamExtractor.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java index 4fda7827..74d646bf 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java @@ -41,7 +41,7 @@ import javax.annotation.Nonnull; public class PeertubeStreamExtractor extends StreamExtractor { private final String baseUrl; private JsonObject json; - private List subtitles = new ArrayList<>(); + private final List subtitles = new ArrayList<>(); public PeertubeStreamExtractor(final StreamingService service, final LinkHandler linkHandler) throws ParsingException { super(service, linkHandler); @@ -64,11 +64,13 @@ public class PeertubeStreamExtractor extends StreamExtractor { return new DateWrapper(PeertubeParsingHelper.parseDateFrom(textualUploadDate)); } + @Nonnull @Override public String getThumbnailUrl() throws ParsingException { return baseUrl + JsonUtils.getString(json, "previewPath"); } + @Nonnull @Override public Description getDescription() throws ParsingException { String text; @@ -127,6 +129,7 @@ public class PeertubeStreamExtractor extends StreamExtractor { return json.getLong("dislikes"); } + @Nonnull @Override public String getUploaderUrl() throws ParsingException { final String name = JsonUtils.getString(json, "account.name"); @@ -134,11 +137,13 @@ public class PeertubeStreamExtractor extends StreamExtractor { return getService().getChannelLHFactory().fromId("accounts/" + name + "@" + host, baseUrl).getUrl(); } + @Nonnull @Override public String getUploaderName() throws ParsingException { return JsonUtils.getString(json, "account.displayName"); } + @Nonnull @Override public String getUploaderAvatarUrl() { String value; @@ -150,6 +155,7 @@ public class PeertubeStreamExtractor extends StreamExtractor { return baseUrl + value; } + @Nonnull @Override public String getSubChannelUrl() throws ParsingException { return JsonUtils.getString(json, "channel.url"); @@ -173,11 +179,13 @@ public class PeertubeStreamExtractor extends StreamExtractor { return baseUrl + value; } + @Nonnull @Override public String getDashMpdUrl() { return ""; } + @Nonnull @Override public String getHlsUrl() { return ""; @@ -185,7 +193,7 @@ public class PeertubeStreamExtractor extends StreamExtractor { @Override public List getAudioStreams() { - return null; + return Collections.emptyList(); } @Override @@ -220,11 +228,13 @@ public class PeertubeStreamExtractor extends StreamExtractor { return Collections.emptyList(); } + @Nonnull @Override public List getSubtitlesDefault() { return subtitles; } + @Nonnull @Override public List getSubtitles(final MediaFormat format) { final List filteredSubs = new ArrayList<>(); @@ -256,6 +266,7 @@ public class PeertubeStreamExtractor extends StreamExtractor { return collector; } + @Nonnull @Override public List getTags() { try { @@ -370,31 +381,37 @@ public class PeertubeStreamExtractor extends StreamExtractor { } } + @Nonnull @Override public String getName() throws ParsingException { return JsonUtils.getString(json, "name"); } + @Nonnull @Override public String getOriginalUrl() throws ParsingException { return baseUrl + "/videos/watch/" + getId(); } + @Nonnull @Override public String getHost() throws ParsingException { return JsonUtils.getString(json, "account.host"); } + @Nonnull @Override public String getPrivacy() throws ParsingException { return JsonUtils.getString(json, "privacy.label"); } + @Nonnull @Override public String getCategory() throws ParsingException { return JsonUtils.getString(json, "category.label"); } + @Nonnull @Override public String getLicence() throws ParsingException { return JsonUtils.getString(json, "licence.label");