[PeerTube] Return empty audio stream list instead of null
This commit is contained in:
		
							parent
							
								
									3b2cfb4ca2
								
							
						
					
					
						commit
						4349be13af
					
				
					 1 changed files with 19 additions and 2 deletions
				
			
		| 
						 | 
					@ -41,7 +41,7 @@ import javax.annotation.Nonnull;
 | 
				
			||||||
public class PeertubeStreamExtractor extends StreamExtractor {
 | 
					public class PeertubeStreamExtractor extends StreamExtractor {
 | 
				
			||||||
    private final String baseUrl;
 | 
					    private final String baseUrl;
 | 
				
			||||||
    private JsonObject json;
 | 
					    private JsonObject json;
 | 
				
			||||||
    private List<SubtitlesStream> subtitles = new ArrayList<>();
 | 
					    private final List<SubtitlesStream> subtitles = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public PeertubeStreamExtractor(final StreamingService service, final LinkHandler linkHandler) throws ParsingException {
 | 
					    public PeertubeStreamExtractor(final StreamingService service, final LinkHandler linkHandler) throws ParsingException {
 | 
				
			||||||
        super(service, linkHandler);
 | 
					        super(service, linkHandler);
 | 
				
			||||||
| 
						 | 
					@ -64,11 +64,13 @@ public class PeertubeStreamExtractor extends StreamExtractor {
 | 
				
			||||||
        return new DateWrapper(PeertubeParsingHelper.parseDateFrom(textualUploadDate));
 | 
					        return new DateWrapper(PeertubeParsingHelper.parseDateFrom(textualUploadDate));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String getThumbnailUrl() throws ParsingException {
 | 
					    public String getThumbnailUrl() throws ParsingException {
 | 
				
			||||||
        return baseUrl + JsonUtils.getString(json, "previewPath");
 | 
					        return baseUrl + JsonUtils.getString(json, "previewPath");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public Description getDescription() throws ParsingException {
 | 
					    public Description getDescription() throws ParsingException {
 | 
				
			||||||
        String text;
 | 
					        String text;
 | 
				
			||||||
| 
						 | 
					@ -127,6 +129,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
 | 
				
			||||||
        return json.getLong("dislikes");
 | 
					        return json.getLong("dislikes");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String getUploaderUrl() throws ParsingException {
 | 
					    public String getUploaderUrl() throws ParsingException {
 | 
				
			||||||
        final String name = JsonUtils.getString(json, "account.name");
 | 
					        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();
 | 
					        return getService().getChannelLHFactory().fromId("accounts/" + name + "@" + host, baseUrl).getUrl();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String getUploaderName() throws ParsingException {
 | 
					    public String getUploaderName() throws ParsingException {
 | 
				
			||||||
        return JsonUtils.getString(json, "account.displayName");
 | 
					        return JsonUtils.getString(json, "account.displayName");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String getUploaderAvatarUrl() {
 | 
					    public String getUploaderAvatarUrl() {
 | 
				
			||||||
        String value;
 | 
					        String value;
 | 
				
			||||||
| 
						 | 
					@ -150,6 +155,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
 | 
				
			||||||
        return baseUrl + value;
 | 
					        return baseUrl + value;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String getSubChannelUrl() throws ParsingException {
 | 
					    public String getSubChannelUrl() throws ParsingException {
 | 
				
			||||||
        return JsonUtils.getString(json, "channel.url");
 | 
					        return JsonUtils.getString(json, "channel.url");
 | 
				
			||||||
| 
						 | 
					@ -173,11 +179,13 @@ public class PeertubeStreamExtractor extends StreamExtractor {
 | 
				
			||||||
        return baseUrl + value;
 | 
					        return baseUrl + value;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String getDashMpdUrl() {
 | 
					    public String getDashMpdUrl() {
 | 
				
			||||||
        return "";
 | 
					        return "";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String getHlsUrl() {
 | 
					    public String getHlsUrl() {
 | 
				
			||||||
        return "";
 | 
					        return "";
 | 
				
			||||||
| 
						 | 
					@ -185,7 +193,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public List<AudioStream> getAudioStreams() {
 | 
					    public List<AudioStream> getAudioStreams() {
 | 
				
			||||||
        return null;
 | 
					        return Collections.emptyList();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
| 
						 | 
					@ -220,11 +228,13 @@ public class PeertubeStreamExtractor extends StreamExtractor {
 | 
				
			||||||
        return Collections.emptyList();
 | 
					        return Collections.emptyList();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public List<SubtitlesStream> getSubtitlesDefault() {
 | 
					    public List<SubtitlesStream> getSubtitlesDefault() {
 | 
				
			||||||
        return subtitles;
 | 
					        return subtitles;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public List<SubtitlesStream> getSubtitles(final MediaFormat format) {
 | 
					    public List<SubtitlesStream> getSubtitles(final MediaFormat format) {
 | 
				
			||||||
        final List<SubtitlesStream> filteredSubs = new ArrayList<>();
 | 
					        final List<SubtitlesStream> filteredSubs = new ArrayList<>();
 | 
				
			||||||
| 
						 | 
					@ -256,6 +266,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
 | 
				
			||||||
        return collector;
 | 
					        return collector;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public List<String> getTags() {
 | 
					    public List<String> getTags() {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
| 
						 | 
					@ -370,31 +381,37 @@ public class PeertubeStreamExtractor extends StreamExtractor {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String getName() throws ParsingException {
 | 
					    public String getName() throws ParsingException {
 | 
				
			||||||
        return JsonUtils.getString(json, "name");
 | 
					        return JsonUtils.getString(json, "name");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String getOriginalUrl() throws ParsingException {
 | 
					    public String getOriginalUrl() throws ParsingException {
 | 
				
			||||||
        return baseUrl + "/videos/watch/" + getId();
 | 
					        return baseUrl + "/videos/watch/" + getId();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String getHost() throws ParsingException {
 | 
					    public String getHost() throws ParsingException {
 | 
				
			||||||
        return JsonUtils.getString(json, "account.host");
 | 
					        return JsonUtils.getString(json, "account.host");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String getPrivacy() throws ParsingException {
 | 
					    public String getPrivacy() throws ParsingException {
 | 
				
			||||||
        return JsonUtils.getString(json, "privacy.label");
 | 
					        return JsonUtils.getString(json, "privacy.label");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String getCategory() throws ParsingException {
 | 
					    public String getCategory() throws ParsingException {
 | 
				
			||||||
        return JsonUtils.getString(json, "category.label");
 | 
					        return JsonUtils.getString(json, "category.label");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String getLicence() throws ParsingException {
 | 
					    public String getLicence() throws ParsingException {
 | 
				
			||||||
        return JsonUtils.getString(json, "licence.label");
 | 
					        return JsonUtils.getString(json, "licence.label");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue