Skip to content

Commit 093762e

Browse files
committed
throw ContentNotSupportedException when content is know to be unsupported
1 parent 094b87c commit 093762e

4 files changed

Lines changed: 22 additions & 2 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.schabi.newpipe.extractor.exceptions;
2+
3+
public class ContentNotSupportedException extends ParsingException {
4+
public ContentNotSupportedException(String message) {
5+
super(message);
6+
}
7+
8+
public ContentNotSupportedException(String message, Throwable cause) {
9+
super(message, cause);
10+
}
11+
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.schabi.newpipe.extractor.StreamingService;
1111
import org.schabi.newpipe.extractor.downloader.Downloader;
1212
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
13+
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
1314
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
1415
import org.schabi.newpipe.extractor.exceptions.ParsingException;
1516
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
@@ -196,6 +197,10 @@ public List<AudioStream> getAudioStreams() throws IOException, ExtractionExcepti
196197
throw new ExtractionException("Could not get SoundCloud's track audio url", e);
197198
}
198199

200+
if (audioStreams.isEmpty()) {
201+
throw new ContentNotSupportedException("HLS audio streams / opus streams are not yet supported");
202+
}
203+
199204
return audioStreams;
200205
}
201206

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubePlaylistLinkHandlerFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.schabi.newpipe.extractor.services.youtube.linkHandler;
22

3+
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
34
import org.schabi.newpipe.extractor.exceptions.ParsingException;
45
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
56
import org.schabi.newpipe.extractor.utils.Utils;
@@ -47,7 +48,7 @@ public String getId(String url) throws ParsingException {
4748

4849
// Don't accept auto-generated "Mix" playlists but auto-generated YouTube Music playlists
4950
if (listID.startsWith("RD") && !listID.startsWith("RDCLAK")) {
50-
throw new ParsingException("YouTube Mix playlists are not yet supported");
51+
throw new ContentNotSupportedException("YouTube Mix playlists are not yet supported");
5152
}
5253

5354
return listID;

extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.schabi.newpipe.extractor.NewPipe;
66
import org.schabi.newpipe.extractor.StreamingService;
77
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
8+
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
89
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
910
import org.schabi.newpipe.extractor.localization.DateWrapper;
1011
import org.schabi.newpipe.extractor.utils.DashMpdParser;
@@ -47,7 +48,7 @@ public static class StreamExtractException extends ExtractionException {
4748
}
4849

4950
public StreamInfo(int serviceId, String url, String originalUrl, StreamType streamType, String id, String name,
50-
int ageLimit) {
51+
int ageLimit) {
5152
super(serviceId, id, url, originalUrl, name);
5253
this.streamType = streamType;
5354
this.ageLimit = ageLimit;
@@ -131,6 +132,8 @@ private static StreamInfo extractStreams(StreamInfo streamInfo, StreamExtractor
131132
/* Load and extract audio */
132133
try {
133134
streamInfo.setAudioStreams(extractor.getAudioStreams());
135+
} catch (ContentNotSupportedException e) {
136+
throw e;
134137
} catch (Exception e) {
135138
streamInfo.addError(new ExtractionException("Couldn't get audio streams", e));
136139
}

0 commit comments

Comments
 (0)