From b3699cdcfcf0d0229bdeb5d0c185f67cf661d569 Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Thu, 1 Feb 2018 19:07:57 -0800 Subject: [PATCH] -Fixed tests -Simplified subtitle extraction url --- .../extractor/services/youtube/YoutubeStreamExtractor.java | 4 ++-- .../soundcloud/SoundcloudStreamExtractorDefaultTest.java | 4 ++-- .../services/youtube/YoutubeStreamExtractorDefaultTest.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java index 85e432212..4ad78fd8f 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java @@ -716,7 +716,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { final Document listing = Jsoup.parse(pageContent, listingUrl); final Elements tracks = listing.select("track"); - List subtitles = new ArrayList<>(tracks.size() * 5); + List subtitles = new ArrayList<>(tracks.size() * 2); for (final Element track : tracks) { final String languageCode = track.attr("lang_code"); subtitles.add(getVideoSubtitlesUrl(id, languageCode, SubtitlesFormat.TTML)); @@ -761,7 +761,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { @Nonnull private static Subtitles getVideoSubtitlesUrl(final String id, final String locale, final SubtitlesFormat format) { final String url = "https://www.youtube.com/api/timedtext?lang=" + locale + - "&fmt=" + format.getExtension() + "&name=&v=" + id; + "&fmt=" + format.getExtension() + "&v=" + id; // These are all non-generated return new Subtitles(format, locale, url, false); } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java index 392535750..7becab629 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java @@ -109,12 +109,12 @@ public class SoundcloudStreamExtractorDefaultTest { @Test public void testGetSubtitlesListDefault() throws IOException, ExtractionException { // Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null - assertTrue(extractor.getSubtitlesDefault() == null); + assertTrue(extractor.getSubtitlesDefault().isEmpty()); } @Test public void testGetSubtitlesList() throws IOException, ExtractionException { // Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null - assertTrue(extractor.getSubtitles(SubtitlesFormat.VTT) == null); + assertTrue(extractor.getSubtitlesDefault().isEmpty()); } } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java index d18b43d2d..e0bf2f76c 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java @@ -153,6 +153,6 @@ public class YoutubeStreamExtractorDefaultTest { @Test public void testGetSubtitlesList() throws IOException, ExtractionException { // Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null - assertTrue(extractor.getSubtitles(SubtitlesFormat.VTT).isEmpty()); + assertTrue(extractor.getSubtitlesDefault().isEmpty()); } }