throw ContentNotSupportedException when content is know to be unsupported
This commit is contained in:
parent
094b87c537
commit
093762e793
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.downloader.Downloader;
|
import org.schabi.newpipe.extractor.downloader.Downloader;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
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.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
|
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);
|
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;
|
return audioStreams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.schabi.newpipe.extractor.services.youtube.linkHandler;
|
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.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
|
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
|
||||||
import org.schabi.newpipe.extractor.utils.Utils;
|
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
|
// Don't accept auto-generated "Mix" playlists but auto-generated YouTube Music playlists
|
||||||
if (listID.startsWith("RD") && !listID.startsWith("RDCLAK")) {
|
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;
|
return listID;
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.schabi.newpipe.extractor.InfoItem;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
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.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
||||||
import org.schabi.newpipe.extractor.utils.DashMpdParser;
|
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,
|
public StreamInfo(int serviceId, String url, String originalUrl, StreamType streamType, String id, String name,
|
||||||
int ageLimit) {
|
int ageLimit) {
|
||||||
super(serviceId, id, url, originalUrl, name);
|
super(serviceId, id, url, originalUrl, name);
|
||||||
this.streamType = streamType;
|
this.streamType = streamType;
|
||||||
this.ageLimit = ageLimit;
|
this.ageLimit = ageLimit;
|
||||||
|
@ -131,6 +132,8 @@ public class StreamInfo extends Info {
|
||||||
/* Load and extract audio */
|
/* Load and extract audio */
|
||||||
try {
|
try {
|
||||||
streamInfo.setAudioStreams(extractor.getAudioStreams());
|
streamInfo.setAudioStreams(extractor.getAudioStreams());
|
||||||
|
} catch (ContentNotSupportedException e) {
|
||||||
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
streamInfo.addError(new ExtractionException("Couldn't get audio streams", e));
|
streamInfo.addError(new ExtractionException("Couldn't get audio streams", e));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue