throw ContentNotSupportedException when content is know to be unsupported

This commit is contained in:
bopol 2020-03-30 11:48:00 +02:00
parent 094b87c537
commit 093762e793
4 changed files with 22 additions and 2 deletions

View File

@ -0,0 +1,11 @@
package org.schabi.newpipe.extractor.exceptions;
public class ContentNotSupportedException extends ParsingException {
public ContentNotSupportedException(String message) {
super(message);
}
public ContentNotSupportedException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.downloader.Downloader;
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
@ -196,6 +197,10 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
throw new ExtractionException("Could not get SoundCloud's track audio url", e);
}
if (audioStreams.isEmpty()) {
throw new ContentNotSupportedException("HLS audio streams / opus streams are not yet supported");
}
return audioStreams;
}

View File

@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube.linkHandler;
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
import org.schabi.newpipe.extractor.utils.Utils;
@ -47,7 +48,7 @@ public class YoutubePlaylistLinkHandlerFactory extends ListLinkHandlerFactory {
// Don't accept auto-generated "Mix" playlists but auto-generated YouTube Music playlists
if (listID.startsWith("RD") && !listID.startsWith("RDCLAK")) {
throw new ParsingException("YouTube Mix playlists are not yet supported");
throw new ContentNotSupportedException("YouTube Mix playlists are not yet supported");
}
return listID;

View File

@ -5,6 +5,7 @@ import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.localization.DateWrapper;
import org.schabi.newpipe.extractor.utils.DashMpdParser;
@ -47,7 +48,7 @@ public class StreamInfo extends Info {
}
public StreamInfo(int serviceId, String url, String originalUrl, StreamType streamType, String id, String name,
int ageLimit) {
int ageLimit) {
super(serviceId, id, url, originalUrl, name);
this.streamType = streamType;
this.ageLimit = ageLimit;
@ -131,6 +132,8 @@ public class StreamInfo extends Info {
/* Load and extract audio */
try {
streamInfo.setAudioStreams(extractor.getAudioStreams());
} catch (ContentNotSupportedException e) {
throw e;
} catch (Exception e) {
streamInfo.addError(new ExtractionException("Couldn't get audio streams", e));
}