Skip to content

Commit 9efcc61

Browse files
committed
Adapt some tests to match the new URLs
1 parent f39603f commit 9efcc61

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorChannelOnlyTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor;
1313
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory;
1414

15+
import java.util.regex.Pattern;
16+
1517
import static java.util.Arrays.asList;
1618
import static org.junit.Assert.*;
1719
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
@@ -51,7 +53,12 @@ public void testGetSecondPage() throws Exception {
5153

5254
@Test
5355
public void testGetSecondPageUrl() throws Exception {
54-
assertEquals("https://www.youtube.com/results?q=pewdiepie&sp=EgIQAlAU&gl=GB&page=2", extractor.getNextPageUrl());
56+
// check that ctoken, continuation and itct are longer than 5 characters
57+
Pattern pattern = Pattern.compile(
58+
"https:\\/\\/www.youtube.com\\/results\\?search_query=pewdiepie&sp=EgIQAg%253D%253D&gl=GB&pbj=1"
59+
+ "&ctoken=[\\w%]{5,}?&continuation=[\\w%]{5,}?&itct=[\\w]{5,}?"
60+
);
61+
assertTrue(pattern.matcher(extractor.getNextPageUrl()).find());
5562
}
5663

5764
@Ignore

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchQHTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ public void testGetContentFilter() throws Exception {
2828

2929
@Test
3030
public void testWithContentfilter() throws Exception {
31-
assertEquals("https://www.youtube.com/results?q=asdf&sp=EgIQAVAU", YouTube.getSearchQHFactory()
31+
assertEquals("https://www.youtube.com/results?search_query=asdf&sp=EgIQAQ%253D%253D", YouTube.getSearchQHFactory()
3232
.fromQuery("asdf", asList(new String[]{VIDEOS}), "").getUrl());
33-
assertEquals("https://www.youtube.com/results?q=asdf&sp=EgIQAlAU", YouTube.getSearchQHFactory()
33+
assertEquals("https://www.youtube.com/results?search_query=asdf&sp=EgIQAg%253D%253D", YouTube.getSearchQHFactory()
3434
.fromQuery("asdf", asList(new String[]{CHANNELS}), "").getUrl());
35-
assertEquals("https://www.youtube.com/results?q=asdf&sp=EgIQA1AU", YouTube.getSearchQHFactory()
35+
assertEquals("https://www.youtube.com/results?search_query=asdf&sp=EgIQAw%253D%253D", YouTube.getSearchQHFactory()
3636
.fromQuery("asdf", asList(new String[]{PLAYLISTS}), "").getUrl());
37-
assertEquals("https://www.youtube.com/results?q=asdf", YouTube.getSearchQHFactory()
37+
assertEquals("https://www.youtube.com/results?search_query=asdf", YouTube.getSearchQHFactory()
3838
.fromQuery("asdf", asList(new String[]{"fjiijie"}), "").getUrl());
3939
}
4040

0 commit comments

Comments
 (0)