This commit is contained in:
Christian Schabesberger 2019-01-29 16:04:19 +01:00
parent 644da4fc3c
commit d0efe8bd47
3 changed files with 47 additions and 3 deletions

View File

@ -121,6 +121,8 @@ public class MediaCCCStreamExtractor extends StreamExtractor {
mediaFormat = MediaFormat.OPUS;
} else if(mimeType.endsWith("mpeg")) {
mediaFormat = MediaFormat.MP3;
} else if(mimeType.endsWith("ogg")){
mediaFormat = MediaFormat.OGG;
} else {
throw new ExtractionException("Unknown media format: " + mimeType);
}
@ -146,8 +148,6 @@ public class MediaCCCStreamExtractor extends StreamExtractor {
mediaFormat = MediaFormat.WEBM;
} else if(mimeType.endsWith("mp4")) {
mediaFormat = MediaFormat.MPEG_4;
} else if(mimeType.endsWith("ogg")){
mediaFormat = MediaFormat.OGG;
} else {
throw new ExtractionException("Unknown media format: " + mimeType);
}

View File

@ -0,0 +1,42 @@
package org.schabi.newpipe.extractor.services.media_ccc;
import org.junit.BeforeClass;
import org.junit.Test;
import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor;
import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.utils.Localization;
import static junit.framework.TestCase.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
/**
* Test {@link MediaCCCStreamExtractor}
*/
public class MediaCCCOggTest {
// test against https://api.media.ccc.de/public/events/1317
private static StreamExtractor extractor;
@BeforeClass
public static void setUpClass() throws Exception {
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
extractor = MediaCCC.getStreamExtractor("https://api.media.ccc.de/public/events/1317");
extractor.fetchPage();
}
@Test
public void getAudioStreamsCount() throws Exception {
assertEquals(1, extractor.getAudioStreams().size());
}
@Test
public void getAudioStreamsContainOgg() throws Exception {
for(AudioStream stream : extractor.getAudioStreams()) {
System.out.println(stream.getFormat());
}
}
}

View File

@ -30,7 +30,7 @@ public class MediaCCCSearchExtractorAllTest {
public static void setUpClass() throws Exception {
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
extractor = MediaCCC.getSearchExtractor( new MediaCCCSearchQueryHandlerFactory()
.fromQuery("c", Arrays.asList(new String[] {"all"}), "")
.fromQuery("c3", Arrays.asList(new String[] {"all"}), "")
,new Localization("GB", "en"));
extractor.fetchPage();
itemsPage = extractor.getInitialPage();
@ -40,6 +40,7 @@ public class MediaCCCSearchExtractorAllTest {
public void testIfChannelInfoItemsAvailable() {
boolean isAvialable = false;
for(InfoItem item : itemsPage.getItems()) {
System.out.println(item);
if(item instanceof ChannelInfoItem) {
isAvialable = true;
}
@ -51,6 +52,7 @@ public class MediaCCCSearchExtractorAllTest {
public void testIfStreamInfoitemsAvailable() {
boolean isAvialable = false;
for(InfoItem item : itemsPage.getItems()) {
System.out.println(item);
if(item instanceof StreamInfoItem) {
isAvialable = true;
}