File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212import org .schabi .newpipe .extractor .services .youtube .extractors .YoutubeSearchExtractor ;
1313import org .schabi .newpipe .extractor .services .youtube .linkHandler .YoutubeSearchQueryHandlerFactory ;
1414
15+ import java .util .regex .Pattern ;
16+
1517import static java .util .Arrays .asList ;
1618import static org .junit .Assert .*;
1719import 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments