Skip to content

Commit 0438828

Browse files
committed
Add a test for the number of audioStreams in CreativeCommonsPlaysWellWithOthers test
It should be only two audio streams for track "Plays Well with Others, Ep 2: What Do an Army of Ants and an Online Encyclopedia Have in Common?" by Creative Commons (https://soundcloud.com/wearecc/plays-well-with-others-ep-2-what-do-an-army-of-ants-and-an-online-encyclopedia-have-in-common): - one which is a progressive stream, in MP3 format with a bitrate of 128 kbps - one which is an HLS stream, in OPUS format with a bitrate of 64 kbps.
1 parent 3bd08a2 commit 0438828

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

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

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
package org.schabi.newpipe.extractor.services.soundcloud;
22

33
import org.junit.BeforeClass;
4-
import org.junit.Ignore;
54
import org.junit.Test;
65
import org.schabi.newpipe.downloader.DownloaderTestImpl;
6+
import org.schabi.newpipe.extractor.MediaFormat;
77
import org.schabi.newpipe.extractor.NewPipe;
88
import org.schabi.newpipe.extractor.StreamingService;
99
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
1010
import org.schabi.newpipe.extractor.exceptions.GeographicRestrictionException;
1111
import org.schabi.newpipe.extractor.exceptions.SoundCloudGoPlusContentException;
1212
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
13+
import org.schabi.newpipe.extractor.stream.AudioStream;
1314
import org.schabi.newpipe.extractor.stream.StreamExtractor;
1415
import org.schabi.newpipe.extractor.stream.StreamType;
1516

@@ -19,12 +20,14 @@
1920

2021
import javax.annotation.Nullable;
2122

23+
import static junit.framework.TestCase.assertEquals;
24+
import static org.hamcrest.CoreMatchers.containsString;
25+
import static org.hamcrest.MatcherAssert.assertThat;
2226
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
2327

2428
public class SoundcloudStreamExtractorTest {
2529
private static final String SOUNDCLOUD = "https://soundcloud.com/";
2630

27-
@Ignore("Ignore until #526 is merged. Throwing the ContentNotSupportedException is wrong and going to be fixed by that PR.")
2831
public static class SoundcloudGeoRestrictedTrack extends DefaultStreamExtractorTest {
2932
private static final String ID = "one-touch";
3033
private static final String UPLOADER = SOUNDCLOUD + "jessglynne";
@@ -143,6 +146,25 @@ public static void setUp() throws Exception {
143146
@Override public boolean expectedHasSubtitles() { return false; }
144147
@Override public boolean expectedHasFrames() { return false; }
145148
@Override public int expectedStreamSegmentsCount() { return 0; }
146-
}
147149

150+
@Override
151+
@Test
152+
public void testAudioStreams() throws Exception {
153+
super.testAudioStreams();
154+
final List<AudioStream> audioStreams = extractor.getAudioStreams();
155+
assertEquals(2, audioStreams.size());
156+
for (final AudioStream audioStream : audioStreams) {
157+
final String mediaUrl = audioStream.getUrl();
158+
if (audioStream.getFormat() == MediaFormat.OPUS) {
159+
// assert that it's an OPUS 64 kbps media URL with a single range which comes from an HLS SoundCloud CDN
160+
assertThat(mediaUrl, containsString("-hls-opus-media.sndcdn.com"));
161+
assertThat(mediaUrl, containsString(".64.opus"));
162+
}
163+
if (audioStream.getFormat() == MediaFormat.MP3) {
164+
// assert that it's a MP3 128 kbps media URL which comes from a progressive SoundCloud CDN
165+
assertThat(mediaUrl, containsString("-media.sndcdn.com/bKOA7Pwbut93.128.mp3"));
166+
}
167+
}
168+
}
169+
}
148170
}

0 commit comments

Comments
 (0)