Skip to content

Commit 044b8fe

Browse files
committed
fix fetch page
1 parent c5ce8ec commit 044b8fe

10 files changed

Lines changed: 24 additions & 33 deletions

File tree

src/main/java/org/schabi/newpipe/extractor/ListExtractor.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,10 @@ public abstract class ListExtractor extends Extractor {
1515

1616
/**
1717
* Get a new ListExtractor with the given nextStreamsUrl set.
18-
* <p>
19-
* The extractor <b>WILL</b> fetch the page if {@link #fetchPageUponCreation()} return true, otherwise, it will <b>NOT</b>.
20-
* <p>
21-
* You can call {@link #fetchPage()} later, but this is mainly used just to get more items, so we don't waste bandwidth
22-
* downloading the whole page, but if the service that is being implemented need it, just do its own logic in {@link #fetchPageUponCreation()}.
2318
*/
2419
public ListExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
2520
super(service, url);
2621
setNextStreamsUrl(nextStreamsUrl);
27-
28-
if (fetchPageUponCreation()) {
29-
fetchPage();
30-
}
31-
}
32-
33-
/**
34-
* Decide if the page will be fetched upon creation.
35-
* <p>
36-
* The default implementation checks if the nextStreamsUrl is null or empty (indication that the caller
37-
* don't need or know what is the next page, thus, fetch the page).
38-
*/
39-
protected boolean fetchPageUponCreation() {
40-
return nextStreamsUrl == null || nextStreamsUrl.isEmpty();
4122
}
4223

4324
@Nonnull

src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public static ChannelInfo getInfo(ServiceList serviceItem, String url) throws IO
5555
}
5656

5757
public static ChannelInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
58+
ChannelExtractor extractor = service.getChannelExtractor(url);
59+
extractor.fetchPage();
5860
return getInfo(service.getChannelExtractor(url));
5961
}
6062

src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,17 @@ public static KioskInfo getInfo(StreamingService service,
6565
String contentCountry) throws IOException, ExtractionException {
6666
KioskList kl = service.getKioskList();
6767
KioskExtractor extractor = kl.getExtractorByUrl(url, null);
68-
return getInfo(extractor, contentCountry);
69-
}
70-
71-
public static KioskInfo getInfo(KioskExtractor extractor,
72-
String contentCountry) throws IOException, ExtractionException {
7368
extractor.setContentCountry(contentCountry);
7469
extractor.fetchPage();
70+
return getInfo(extractor);
71+
}
72+
73+
/**
74+
* Get KioskInfo from KioskExtractor
75+
*
76+
* @param extractor an extractor where fetchPage() was already got called on.
77+
*/
78+
public static KioskInfo getInfo(KioskExtractor extractor) throws ExtractionException {
7579

7680
int serviceId = extractor.getServiceId();
7781
String name = extractor.getName();

src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,16 @@ public static PlaylistInfo getInfo(ServiceList serviceItem, String url) throws I
3232
}
3333

3434
public static PlaylistInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
35-
return getInfo(service.getPlaylistExtractor(url));
35+
PlaylistExtractor extractor = service.getPlaylistExtractor(url);
36+
extractor.fetchPage();
37+
return getInfo(extractor);
3638
}
3739

40+
/**
41+
* Get PlaylistInfo from PlaylistExtractor
42+
*
43+
* @param extractor an extractor where fetchPage() was already got called on.
44+
*/
3845
public static PlaylistInfo getInfo(PlaylistExtractor extractor) throws ParsingException {
3946

4047
int serviceId = extractor.getServiceId();

src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractor.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ public void onFetchPage(@Nonnull Downloader downloader) throws IOException, Extr
7070
nextStreamsAjax = null;
7171
}
7272

73-
@Override
74-
protected boolean fetchPageUponCreation() {
75-
// Unfortunately, we have to fetch the page even if we are getting only next streams,
76-
// as they don't deliver enough information on their own (the channel name, for example).
77-
fetchingNextStreams = nextStreamsUrl != null && !nextStreamsUrl.isEmpty();
78-
return true;
79-
}
80-
8173
@Nonnull
8274
@Override
8375
public String getCleanUrl() {

src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public static void setUp() throws Exception {
2323
NewPipe.init(Downloader.getInstance());
2424
extractor = SoundCloud.getService()
2525
.getChannelExtractor("https://soundcloud.com/liluzivert");
26+
extractor.fetchPage();
2627
}
2728

2829
@Test

src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static void setUp() throws Exception {
2222
NewPipe.init(Downloader.getInstance());
2323
extractor = SoundCloud.getService()
2424
.getPlaylistExtractor("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r");
25+
extractor.fetchPage();
2526
}
2627

2728
@Test

src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public static void setUp() throws Exception {
4444
NewPipe.init(Downloader.getInstance());
4545
extractor = (YoutubeChannelExtractor) YouTube.getService()
4646
.getChannelExtractor("https://www.youtube.com/user/Gronkh");
47+
extractor.fetchPage();
4748
}
4849

4950
@Test

src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public static void setUp() throws Exception {
3030
NewPipe.init(Downloader.getInstance());
3131
extractor = (YoutubePlaylistExtractor) YouTube.getService()
3232
.getPlaylistExtractor("https://www.youtube.com/watch?v=lp-EO5I60KA&list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj");
33+
extractor.fetchPage();
3334
}
3435

3536
@Test

src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public static void setUp() throws Exception {
4848
extractor = (YoutubeTrendingExtractor) YouTube.getService()
4949
.getKioskList()
5050
.getExtractorById("Trending", null);
51+
extractor.fetchPage();
5152
}
5253

5354
@Test

0 commit comments

Comments
 (0)