Update DefaultStreamExtractorTest and SoundcloudStreamExtractorTest to support changes made in Stream classes
This commit is contained in:
parent
7477ed0f3d
commit
f6ec7f9a61
2 changed files with 43 additions and 20 deletions
|
@ -271,13 +271,20 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
|
|||
assertFalse(videoStreams.isEmpty());
|
||||
|
||||
for (final VideoStream stream : videoStreams) {
|
||||
assertIsSecureUrl(stream.getUrl());
|
||||
assertFalse(stream.getResolution().isEmpty());
|
||||
|
||||
final int formatId = stream.getFormatId();
|
||||
// see MediaFormat: video stream formats range from 0 to 0x100
|
||||
assertTrue(0 <= formatId && formatId < 0x100,
|
||||
"format id does not fit a video stream: " + formatId);
|
||||
if (stream.isUrl()) {
|
||||
assertIsSecureUrl(stream.getContent());
|
||||
}
|
||||
final StreamType streamType = extractor().getStreamType();
|
||||
// On some video streams, the resolution can be empty and the format be unknown,
|
||||
// especially on livestreams (like streams with HLS master playlists)
|
||||
if (streamType != StreamType.LIVE_STREAM
|
||||
&& streamType != StreamType.AUDIO_LIVE_STREAM) {
|
||||
assertFalse(stream.getResolution().isEmpty());
|
||||
final int formatId = stream.getFormatId();
|
||||
// see MediaFormat: video stream formats range from 0 to 0x100
|
||||
assertTrue(0 <= formatId && formatId < 0x100,
|
||||
"Format id does not fit a video stream: " + formatId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assertTrue(videoStreams.isEmpty());
|
||||
|
@ -294,12 +301,17 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
|
|||
assertFalse(audioStreams.isEmpty());
|
||||
|
||||
for (final AudioStream stream : audioStreams) {
|
||||
assertIsSecureUrl(stream.getUrl());
|
||||
if (stream.isUrl()) {
|
||||
assertIsSecureUrl(stream.getContent());
|
||||
}
|
||||
|
||||
final int formatId = stream.getFormatId();
|
||||
// see MediaFormat: video stream formats range from 0x100 to 0x1000
|
||||
assertTrue(0x100 <= formatId && formatId < 0x1000,
|
||||
"format id does not fit an audio stream: " + formatId);
|
||||
// The media format can be unknown on some audio streams
|
||||
if (stream.getFormat() != null) {
|
||||
final int formatId = stream.getFormat().id;
|
||||
// see MediaFormat: audio stream formats range from 0x100 to 0x1000
|
||||
assertTrue(0x100 <= formatId && formatId < 0x1000,
|
||||
"Format id does not fit an audio stream: " + formatId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assertTrue(audioStreams.isEmpty());
|
||||
|
@ -316,12 +328,14 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
|
|||
assertFalse(subtitles.isEmpty());
|
||||
|
||||
for (final SubtitlesStream stream : subtitles) {
|
||||
assertIsSecureUrl(stream.getUrl());
|
||||
if (stream.isUrl()) {
|
||||
assertIsSecureUrl(stream.getContent());
|
||||
}
|
||||
|
||||
final int formatId = stream.getFormatId();
|
||||
// see MediaFormat: video stream formats range from 0x1000 to 0x10000
|
||||
assertTrue(0x1000 <= formatId && formatId < 0x10000,
|
||||
"format id does not fit a subtitles stream: " + formatId);
|
||||
"Format id does not fit a subtitles stream: " + formatId);
|
||||
}
|
||||
} else {
|
||||
assertTrue(subtitles.isEmpty());
|
||||
|
@ -344,7 +358,8 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
|
|||
assertTrue(dashMpdUrl.isEmpty());
|
||||
} else {
|
||||
assertIsSecureUrl(dashMpdUrl);
|
||||
ExtractorAsserts.assertContains(expectedDashMpdUrlContains(), extractor().getDashMpdUrl());
|
||||
ExtractorAsserts.assertContains(expectedDashMpdUrlContains(),
|
||||
extractor().getDashMpdUrl());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.exceptions.GeographicRestrictionException;
|
|||
import org.schabi.newpipe.extractor.exceptions.SoundCloudGoPlusContentException;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||||
import org.schabi.newpipe.extractor.stream.DeliveryMethod;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
|
||||
|
@ -21,7 +22,7 @@ import java.util.List;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
|
||||
public class SoundcloudStreamExtractorTest {
|
||||
|
@ -188,15 +189,22 @@ public class SoundcloudStreamExtractorTest {
|
|||
final List<AudioStream> audioStreams = extractor.getAudioStreams();
|
||||
assertEquals(2, audioStreams.size());
|
||||
for (final AudioStream audioStream : audioStreams) {
|
||||
final String mediaUrl = audioStream.getUrl();
|
||||
final DeliveryMethod deliveryMethod = audioStream.getDeliveryMethod();
|
||||
assertSame(DeliveryMethod.PROGRESSIVE_HTTP, deliveryMethod,
|
||||
"Wrong delivery method for stream " + audioStream.getId() + ": "
|
||||
+ deliveryMethod);
|
||||
final String mediaUrl = audioStream.getContent();
|
||||
if (audioStream.getFormat() == MediaFormat.OPUS) {
|
||||
// assert that it's an OPUS 64 kbps media URL with a single range which comes from an HLS SoundCloud CDN
|
||||
// Assert that it's an OPUS 64 kbps media URL with a single range which comes
|
||||
// from an HLS SoundCloud CDN
|
||||
ExtractorAsserts.assertContains("-hls-opus-media.sndcdn.com", mediaUrl);
|
||||
ExtractorAsserts.assertContains(".64.opus", mediaUrl);
|
||||
}
|
||||
if (audioStream.getFormat() == MediaFormat.MP3) {
|
||||
// assert that it's a MP3 128 kbps media URL which comes from a progressive SoundCloud CDN
|
||||
ExtractorAsserts.assertContains("-media.sndcdn.com/bKOA7Pwbut93.128.mp3", mediaUrl);
|
||||
// Assert that it's a MP3 128 kbps media URL which comes from a progressive
|
||||
// SoundCloud CDN
|
||||
ExtractorAsserts.assertContains("-media.sndcdn.com/bKOA7Pwbut93.128.mp3",
|
||||
mediaUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue