From 8806fb4e6bac52d657b74d8fd35a454456636b34 Mon Sep 17 00:00:00 2001 From: bopol Date: Fri, 12 Feb 2021 20:34:46 +0100 Subject: [PATCH] address reviews --- .../extractor/localization/Localization.java | 6 +- .../extractors/PeertubeStreamExtractor.java | 2 +- .../extractors/YoutubeStreamExtractor.java | 2 +- .../extractor/stream/StreamExtractor.java | 3 +- .../MediaCCCStreamExtractorTest.java | 176 ++++-------------- .../YoutubeStreamExtractorDefaultTest.java | 1 - 6 files changed, 39 insertions(+), 151 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/localization/Localization.java b/extractor/src/main/java/org/schabi/newpipe/extractor/localization/Localization.java index 83fc84454..e0f60a86b 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/localization/Localization.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/localization/Localization.java @@ -103,14 +103,14 @@ public class Localization implements Serializable { /** * Converts a three letter language code (ISO 639-2/T) to a Locale - * in the limit of Java Locale class. + * because limits of Java Locale class. * * @param code a three letter language code * @return the Locale corresponding */ public static Locale getLocaleFromThreeLetterCode(@Nonnull String code) throws ParsingException { - String[] languages = Locale.getISOLanguages(); - Map localeMap = new HashMap<>(languages.length); + final String[] languages = Locale.getISOLanguages(); + final Map localeMap = new HashMap<>(languages.length); for (String language : languages) { final Locale locale = new Locale(language); localeMap.put(locale.getISO3Language(), locale); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java index 3e1ebae79..611838710 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java @@ -435,7 +435,7 @@ public class PeertubeStreamExtractor extends StreamExtractor { case 4: return Privacy.INTERNAL; default: - return null; + return Privacy.OTHER; } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java index 81522ea7c..0609b7689 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java @@ -1109,7 +1109,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { @Nonnull @Override public Privacy getPrivacy() { - boolean isUnlisted = playerResponse + final boolean isUnlisted = playerResponse .getObject("microformat") .getObject("playerMicroformatRenderer") .getBoolean("isUnlisted"); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java index 40eeaf58d..d430eed5f 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java @@ -513,6 +513,7 @@ public abstract class StreamExtractor extends Extractor { PUBLIC, UNLISTED, PRIVATE, - INTERNAL + INTERNAL, + OTHER } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCStreamExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCStreamExtractorTest.java index 88d7dfc61..4c1adfd99 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCStreamExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCStreamExtractorTest.java @@ -50,52 +50,19 @@ public class MediaCCCStreamExtractorTest { @Override public List expectedDescriptionContains() { return Arrays.asList("SSH-Sessions", "\"Terminal Multiplexer\""); } @Override public long expectedLength() { return 3097; } @Override public long expectedViewCountAtLeast() { return 2380; } - @Nullable - @Override public String expectedUploadDate() { return "2018-05-11 00:00:00.000"; } - @Nullable - @Override - public String expectedTextualUploadDate() { - return "2018-05-11T02:00:00.000+02:00"; - } + @Nullable @Override public String expectedUploadDate() { return "2018-05-11 00:00:00.000"; } + @Nullable @Override public String expectedTextualUploadDate() { return "2018-05-11T02:00:00.000+02:00"; } + @Override public long expectedLikeCountAtLeast() { return -1; } + @Override public long expectedDislikeCountAtLeast() { return -1; } + @Override public boolean expectedHasRelatedStreams() { return false; } + @Override public boolean expectedHasSubtitles() { return false; } + @Override public boolean expectedHasFrames() { return false; } + @Override public List expectedTags() { return Arrays.asList("gpn18", "105"); } + @Override public int expectedStreamSegmentsCount() { return 0; } + @Override public Locale expectedLanguageInfo() { return new Locale("de"); } @Override - public long expectedLikeCountAtLeast() { - return -1; - } - - @Override - public long expectedDislikeCountAtLeast() { - return -1; - } - - @Override - public boolean expectedHasRelatedStreams() { - return false; - } - - @Override - public boolean expectedHasSubtitles() { - return false; - } - - @Override - public boolean expectedHasFrames() { - return false; - } - - @Override - public List expectedTags() { - return Arrays.asList("gpn18", "105"); - } - - @Override - public int expectedStreamSegmentsCount() { - return 0; - } - - @Override - @Test - public void testThumbnailUrl() throws Exception { + @Test public void testThumbnailUrl() throws Exception { super.testThumbnailUrl(); assertEquals("https://static.media.ccc.de/media/events/gpn/gpn18/105-hd.jpg", extractor.getThumbnailUrl()); } @@ -120,11 +87,6 @@ public class MediaCCCStreamExtractorTest { super.testAudioStreams(); assertEquals(2, extractor.getAudioStreams().size()); } - - @Override - public Locale expectedLanguageInfo() { - return new Locale("de"); - } } public static class _36c3PrivacyMessaging extends DefaultStreamExtractorTest { @@ -139,111 +101,37 @@ public class MediaCCCStreamExtractorTest { extractor.fetchPage(); } - @Override - public StreamExtractor extractor() { + @Override public StreamExtractor extractor() { return extractor; } - - @Override - public StreamingService expectedService() { + @Override public StreamingService expectedService() { return MediaCCC; } - - @Override - public String expectedName() { + @Override public String expectedName() { return "What's left for private messaging?"; } - - @Override - public String expectedId() { + @Override public String expectedId() { return ID; } + @Override public String expectedUrlContains() { return URL; } + @Override public String expectedOriginalUrlContains() { return URL; } + @Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; } + @Override public String expectedUploaderName() { return "36c3"; } + @Override public String expectedUploaderUrl() { return "https://media.ccc.de/c/36c3"; } + @Override public List expectedDescriptionContains() { return Arrays.asList("WhatsApp", "Signal"); } + @Override public long expectedLength() { return 3603; } + @Override public long expectedViewCountAtLeast() { return 2380; } + @Nullable @Override public String expectedUploadDate() { return "2020-01-11 00:00:00.000"; } + @Nullable @Override public String expectedTextualUploadDate() { return "2020-01-11T01:00:00.000+01:00"; } + @Override public long expectedLikeCountAtLeast() { return -1; } + @Override public long expectedDislikeCountAtLeast() { return -1; } + @Override public boolean expectedHasRelatedStreams() { return false; } + @Override public boolean expectedHasSubtitles() { return false; } + @Override public boolean expectedHasFrames() { return false; } + @Override public List expectedTags() { return Arrays.asList("36c3", "10565", "2019", "Security", "Main"); } @Override - public String expectedUrlContains() { - return URL; - } - - @Override - public String expectedOriginalUrlContains() { - return URL; - } - - @Override - public StreamType expectedStreamType() { - return StreamType.VIDEO_STREAM; - } - - @Override - public String expectedUploaderName() { - return "36c3"; - } - - @Override - public String expectedUploaderUrl() { - return "https://media.ccc.de/c/36c3"; - } - - @Override - public List expectedDescriptionContains() { - return Arrays.asList("WhatsApp", "Signal"); - } - - @Override - public long expectedLength() { - return 3603; - } - - @Override - public long expectedViewCountAtLeast() { - return 2380; - } - - @Nullable - @Override - public String expectedUploadDate() { - return "2020-01-11 00:00:00.000"; - } - - @Nullable - @Override - public String expectedTextualUploadDate() { - return "2020-01-11T01:00:00.000+01:00"; - } - - @Override - public long expectedLikeCountAtLeast() { - return -1; - } - - @Override - public long expectedDislikeCountAtLeast() { - return -1; - } - - @Override - public boolean expectedHasRelatedStreams() { - return false; - } - - @Override - public boolean expectedHasSubtitles() { - return false; - } - - @Override - public boolean expectedHasFrames() { - return false; - } - - @Override - public List expectedTags() { - return Arrays.asList("36c3", "10565", "2019", "Security", "Main"); - } - - @Override - @Test - public void testThumbnailUrl() throws Exception { + @Test public void testThumbnailUrl() throws Exception { super.testThumbnailUrl(); assertEquals("https://static.media.ccc.de/media/congress/2019/10565-hd.jpg", extractor.getThumbnailUrl()); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorDefaultTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorDefaultTest.java index c30a282df..56b13a7dd 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorDefaultTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorDefaultTest.java @@ -432,7 +432,6 @@ public class YoutubeStreamExtractorDefaultTest { } public static class CCLicensed { - // StreamSegment example with macro-makers panel and transcription panel private static final String ID = "M4gD1WSo5mA"; private static final String URL = BASE_URL + ID; private static StreamExtractor extractor;