MediaCCCLH: use substring instead of replace; improve a bit tests, return Collections.emptyList(); instead of null where it's annotated @NonNull
This commit is contained in:
parent
f742a6bd3e
commit
0cd5e05b7b
|
@ -16,6 +16,7 @@ import org.schabi.newpipe.extractor.stream.*;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -104,13 +105,13 @@ public class MediaCCCStreamExtractor extends StreamExtractor {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getDashMpdUrl() throws ParsingException {
|
public String getDashMpdUrl() throws ParsingException {
|
||||||
return null;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getHlsUrl() throws ParsingException {
|
public String getHlsUrl() throws ParsingException {
|
||||||
return null;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -170,14 +171,16 @@ public class MediaCCCStreamExtractor extends StreamExtractor {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public List<SubtitlesStream> getSubtitlesDefault() throws IOException, ExtractionException {
|
public List<SubtitlesStream> getSubtitlesDefault() throws IOException, ExtractionException {
|
||||||
return null;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public List<SubtitlesStream> getSubtitles(final MediaFormat format) throws IOException, ExtractionException {
|
public List<SubtitlesStream> getSubtitles(final MediaFormat format) throws IOException, ExtractionException {
|
||||||
return null;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class MediaCCCStreamLinkHandlerFactory extends LinkHandlerFactory {
|
||||||
public String getId(String urlString) throws ParsingException {
|
public String getId(String urlString) throws ParsingException {
|
||||||
if (urlString.startsWith("https://api.media.ccc.de/public/events/") &&
|
if (urlString.startsWith("https://api.media.ccc.de/public/events/") &&
|
||||||
!urlString.contains("?q=")) {
|
!urlString.contains("?q=")) {
|
||||||
return urlString.replace("https://api.media.ccc.de/public/events/", "");
|
return urlString.substring(39); //remove api…/public/events part
|
||||||
}
|
}
|
||||||
|
|
||||||
URL url;
|
URL url;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import org.schabi.newpipe.DownloaderTestImpl;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor;
|
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.utils.UtilsTest;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
@ -14,6 +15,7 @@ import java.util.Calendar;
|
||||||
|
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
|
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,16 +51,19 @@ public class MediaCCCStreamExtractorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUrl() throws Exception {
|
public void testUrl() throws Exception {
|
||||||
|
assertIsSecureUrl(extractor.getUrl());
|
||||||
assertEquals("https://api.media.ccc.de/public/events/gpn18-105-tmux-warum-ein-schwarzes-fenster-am-bildschirm-reicht", extractor.getUrl());
|
assertEquals("https://api.media.ccc.de/public/events/gpn18-105-tmux-warum-ein-schwarzes-fenster-am-bildschirm-reicht", extractor.getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOriginalUrl() throws Exception {
|
public void testOriginalUrl() throws Exception {
|
||||||
|
assertIsSecureUrl(extractor.getOriginalUrl());
|
||||||
assertEquals("https://media.ccc.de/v/gpn18-105-tmux-warum-ein-schwarzes-fenster-am-bildschirm-reicht", extractor.getOriginalUrl());
|
assertEquals("https://media.ccc.de/v/gpn18-105-tmux-warum-ein-schwarzes-fenster-am-bildschirm-reicht", extractor.getOriginalUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThumbnail() throws Exception {
|
public void testThumbnail() throws Exception {
|
||||||
|
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||||
assertEquals("https://static.media.ccc.de/media/events/gpn/gpn18/105-hd.jpg", extractor.getThumbnailUrl());
|
assertEquals("https://static.media.ccc.de/media/events/gpn/gpn18/105-hd.jpg", extractor.getThumbnailUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,11 +74,13 @@ public class MediaCCCStreamExtractorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUploaderUrl() throws Exception {
|
public void testUploaderUrl() throws Exception {
|
||||||
|
assertIsSecureUrl(extractor.getUploaderUrl());
|
||||||
assertEquals("https://api.media.ccc.de/public/conferences/gpn18", extractor.getUploaderUrl());
|
assertEquals("https://api.media.ccc.de/public/conferences/gpn18", extractor.getUploaderUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUploaderAvatarUrl() throws Exception {
|
public void testUploaderAvatarUrl() throws Exception {
|
||||||
|
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||||
assertEquals("https://static.media.ccc.de/media/events/gpn/gpn18/logo.png", extractor.getUploaderAvatarUrl());
|
assertEquals("https://static.media.ccc.de/media/events/gpn/gpn18/logo.png", extractor.getUploaderAvatarUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,16 +129,19 @@ public class MediaCCCStreamExtractorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUrl() throws Exception {
|
public void testUrl() throws Exception {
|
||||||
|
assertIsSecureUrl(extractor.getUrl());
|
||||||
assertEquals("https://api.media.ccc.de/public/events/36c3-10565-what_s_left_for_private_messaging", extractor.getUrl());
|
assertEquals("https://api.media.ccc.de/public/events/36c3-10565-what_s_left_for_private_messaging", extractor.getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOriginalUrl() throws Exception {
|
public void testOriginalUrl() throws Exception {
|
||||||
|
assertIsSecureUrl(extractor.getOriginalUrl());
|
||||||
assertEquals("https://media.ccc.de/v/36c3-10565-what_s_left_for_private_messaging", extractor.getOriginalUrl());
|
assertEquals("https://media.ccc.de/v/36c3-10565-what_s_left_for_private_messaging", extractor.getOriginalUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThumbnail() throws Exception {
|
public void testThumbnail() throws Exception {
|
||||||
|
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||||
assertEquals("https://static.media.ccc.de/media/congress/2019/10565-hd.jpg", extractor.getThumbnailUrl());
|
assertEquals("https://static.media.ccc.de/media/congress/2019/10565-hd.jpg", extractor.getThumbnailUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,11 +152,13 @@ public class MediaCCCStreamExtractorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUploaderUrl() throws Exception {
|
public void testUploaderUrl() throws Exception {
|
||||||
|
assertIsSecureUrl(extractor.getUploaderUrl());
|
||||||
assertEquals("https://api.media.ccc.de/public/conferences/36c3", extractor.getUploaderUrl());
|
assertEquals("https://api.media.ccc.de/public/conferences/36c3", extractor.getUploaderUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUploaderAvatarUrl() throws Exception {
|
public void testUploaderAvatarUrl() throws Exception {
|
||||||
|
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||||
assertEquals("https://static.media.ccc.de/media/congress/2019/logo.png", extractor.getUploaderAvatarUrl());
|
assertEquals("https://static.media.ccc.de/media/congress/2019/logo.png", extractor.getUploaderAvatarUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue