|
1 | 1 | package org.schabi.newpipe.extractor.services.soundcloud; |
2 | 2 |
|
3 | 3 | import org.junit.BeforeClass; |
4 | | -import org.junit.Ignore; |
5 | 4 | import org.junit.Test; |
6 | 5 | import org.schabi.newpipe.downloader.DownloaderTestImpl; |
| 6 | +import org.schabi.newpipe.extractor.MediaFormat; |
7 | 7 | import org.schabi.newpipe.extractor.NewPipe; |
8 | 8 | import org.schabi.newpipe.extractor.StreamingService; |
9 | 9 | import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException; |
10 | 10 | import org.schabi.newpipe.extractor.exceptions.GeographicRestrictionException; |
11 | 11 | import org.schabi.newpipe.extractor.exceptions.SoundCloudGoPlusContentException; |
12 | 12 | import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest; |
| 13 | +import org.schabi.newpipe.extractor.stream.AudioStream; |
13 | 14 | import org.schabi.newpipe.extractor.stream.StreamExtractor; |
14 | 15 | import org.schabi.newpipe.extractor.stream.StreamType; |
15 | 16 |
|
|
19 | 20 |
|
20 | 21 | import javax.annotation.Nullable; |
21 | 22 |
|
| 23 | +import static junit.framework.TestCase.assertEquals; |
| 24 | +import static org.hamcrest.CoreMatchers.containsString; |
| 25 | +import static org.hamcrest.MatcherAssert.assertThat; |
22 | 26 | import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; |
23 | 27 |
|
24 | 28 | public class SoundcloudStreamExtractorTest { |
25 | 29 | private static final String SOUNDCLOUD = "https://soundcloud.com/"; |
26 | 30 |
|
27 | | - @Ignore("Ignore until #526 is merged. Throwing the ContentNotSupportedException is wrong and going to be fixed by that PR.") |
28 | 31 | public static class SoundcloudGeoRestrictedTrack extends DefaultStreamExtractorTest { |
29 | 32 | private static final String ID = "one-touch"; |
30 | 33 | private static final String UPLOADER = SOUNDCLOUD + "jessglynne"; |
@@ -143,6 +146,25 @@ public static void setUp() throws Exception { |
143 | 146 | @Override public boolean expectedHasSubtitles() { return false; } |
144 | 147 | @Override public boolean expectedHasFrames() { return false; } |
145 | 148 | @Override public int expectedStreamSegmentsCount() { return 0; } |
146 | | - } |
147 | 149 |
|
| 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 | + } |
148 | 170 | } |
0 commit comments