Skip to content

Commit 0e3e420

Browse files
committed
Fix tests
1 parent d61d9d1 commit 0e3e420

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
public class SoundcloudStreamExtractor extends StreamExtractor {
3939
private JsonObject track;
40+
private boolean isAvailable = true;
4041

4142
public SoundcloudStreamExtractor(StreamingService service, LinkHandler linkHandler) {
4243
super(service, linkHandler);
@@ -48,6 +49,7 @@ public void onFetchPage(@Nonnull Downloader downloader) throws IOException, Extr
4849

4950
final String policy = track.getString("policy", EMPTY_STRING);
5051
if (!policy.equals("ALLOW") && !policy.equals("MONETIZE")) {
52+
isAvailable = false;
5153
if (policy.equals("SNIP")) {
5254
throw new SoundCloudGoPlusContentException();
5355
}
@@ -190,7 +192,7 @@ public List<AudioStream> getAudioStreams() throws ExtractionException {
190192
// Streams can be streamable and downloadable - or explicitly not.
191193
// For playing the track, it is only necessary to have a streamable track.
192194
// If this is not the case, this track might not be published yet.
193-
if (!track.getBoolean("streamable")) return audioStreams;
195+
if (!track.getBoolean("streamable") || !isAvailable) return audioStreams;
194196

195197
try {
196198
final JsonArray transcodings = track.getObject("media").getArray("transcodings");

extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import org.schabi.newpipe.extractor.MediaFormat;
77
import org.schabi.newpipe.extractor.NewPipe;
88
import org.schabi.newpipe.extractor.StreamingService;
9-
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
109
import org.schabi.newpipe.extractor.exceptions.GeographicRestrictionException;
1110
import org.schabi.newpipe.extractor.exceptions.SoundCloudGoPlusContentException;
1211
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
@@ -62,6 +61,7 @@ public void geoRestrictedContent() throws Exception {
6261
@Nullable @Override public String expectedTextualUploadDate() { return "2019-05-16 16:28:45"; }
6362
@Override public long expectedLikeCountAtLeast() { return -1; }
6463
@Override public long expectedDislikeCountAtLeast() { return -1; }
64+
@Override public boolean expectedHasAudioStreams() { return false; }
6565
@Override public boolean expectedHasVideoStreams() { return false; }
6666
@Override public boolean expectedHasSubtitles() { return false; }
6767
@Override public boolean expectedHasFrames() { return false; }
@@ -103,7 +103,9 @@ public void goPlusContent() throws Exception {
103103
@Nullable @Override public String expectedTextualUploadDate() { return "2016-11-11 01:16:37"; }
104104
@Override public long expectedLikeCountAtLeast() { return -1; }
105105
@Override public long expectedDislikeCountAtLeast() { return -1; }
106+
@Override public boolean expectedHasAudioStreams() { return false; }
106107
@Override public boolean expectedHasVideoStreams() { return false; }
108+
@Override public boolean expectedHasRelatedStreams() { return false; }
107109
@Override public boolean expectedHasSubtitles() { return false; }
108110
@Override public boolean expectedHasFrames() { return false; }
109111
@Override public int expectedStreamSegmentsCount() { return 0; }

0 commit comments

Comments
 (0)