Skip to content

Commit 9b6fe1d

Browse files
committed
Throw IllegalArgumentException when Page is invalid
1 parent 4cc3120 commit 9b6fe1d

19 files changed

Lines changed: 107 additions & 18 deletions

extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceExtractor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ public InfoItemsPage<StreamInfoItem> getInitialPage() {
8080
}
8181

8282
@Override
83-
8483
public InfoItemsPage<StreamInfoItem> getPage(final Page page) {
8584
return InfoItemsPage.emptyPage();
8685
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeAccountExtractor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.COUNT_KEY;
2525
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.ITEMS_PER_PAGE;
2626
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.START_KEY;
27+
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
2728

2829
public class PeertubeAccountExtractor extends ChannelExtractor {
2930
private JsonObject json;
@@ -110,7 +111,12 @@ private void collectStreamsFrom(final StreamInfoItemsCollector collector, final
110111

111112
@Override
112113
public InfoItemsPage<StreamInfoItem> getPage(final Page page) throws IOException, ExtractionException {
114+
if (page == null || isNullOrEmpty(page.getUrl())) {
115+
throw new IllegalArgumentException("Page doesn't contain an URL");
116+
}
117+
113118
final Response response = getDownloader().get(page.getUrl());
119+
114120
JsonObject json = null;
115121
if (response != null && !Utils.isBlank(response.responseBody())) {
116122
try {

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.COUNT_KEY;
2525
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.ITEMS_PER_PAGE;
2626
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.START_KEY;
27+
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
28+
2729

2830
public class PeertubeChannelExtractor extends ChannelExtractor {
2931
private JsonObject json;
@@ -116,7 +118,12 @@ private void collectStreamsFrom(final StreamInfoItemsCollector collector, final
116118

117119
@Override
118120
public InfoItemsPage<StreamInfoItem> getPage(final Page page) throws IOException, ExtractionException {
121+
if (page == null || isNullOrEmpty(page.getUrl())) {
122+
throw new IllegalArgumentException("Page doesn't contain an URL");
123+
}
124+
119125
final Response response = getDownloader().get(page.getUrl());
126+
120127
JsonObject json = null;
121128
if (response != null && !Utils.isBlank(response.responseBody())) {
122129
try {

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsExtractor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.COUNT_KEY;
2424
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.ITEMS_PER_PAGE;
2525
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.START_KEY;
26+
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
2627

2728
public class PeertubeCommentsExtractor extends CommentsExtractor {
2829
public PeertubeCommentsExtractor(final StreamingService service, final ListLinkHandler uiHandler) {
@@ -51,7 +52,12 @@ private void collectCommentsFrom(final CommentsInfoItemsCollector collector, fin
5152

5253
@Override
5354
public InfoItemsPage<CommentsInfoItem> getPage(final Page page) throws IOException, ExtractionException {
55+
if (page == null || isNullOrEmpty(page.getUrl())) {
56+
throw new IllegalArgumentException("Page doesn't contain an URL");
57+
}
58+
5459
final Response response = getDownloader().get(page.getUrl());
60+
5561
JsonObject json = null;
5662
if (response != null && !Utils.isBlank(response.responseBody())) {
5763
try {

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubePlaylistExtractor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.COUNT_KEY;
2727
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.ITEMS_PER_PAGE;
2828
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.START_KEY;
29+
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
2930

3031
public class PeertubePlaylistExtractor extends PlaylistExtractor {
3132
private JsonObject playlistInfo;
@@ -108,7 +109,12 @@ private void collectStreamsFrom(final StreamInfoItemsCollector collector, final
108109

109110
@Override
110111
public InfoItemsPage<StreamInfoItem> getPage(final Page page) throws IOException, ExtractionException {
112+
if (page == null || isNullOrEmpty(page.getUrl())) {
113+
throw new IllegalArgumentException("Page doesn't contain an URL");
114+
}
115+
111116
final Response response = getDownloader().get(page.getUrl());
117+
112118
JsonObject json = null;
113119
if (response != null && !Utils.isBlank(response.responseBody())) {
114120
try {

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeSearchExtractor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.COUNT_KEY;
2626
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.ITEMS_PER_PAGE;
2727
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.START_KEY;
28+
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
2829

2930
public class PeertubeSearchExtractor extends SearchExtractor {
3031
public PeertubeSearchExtractor(StreamingService service, SearchQueryHandler linkHandler) {
@@ -68,7 +69,12 @@ private void collectStreamsFrom(final InfoItemsSearchCollector collector, final
6869

6970
@Override
7071
public InfoItemsPage<InfoItem> getPage(final Page page) throws IOException, ExtractionException {
72+
if (page == null || isNullOrEmpty(page.getUrl())) {
73+
throw new IllegalArgumentException("Page doesn't contain an URL");
74+
}
75+
7176
final Response response = getDownloader().get(page.getUrl());
77+
7278
JsonObject json = null;
7379
if (response != null && !Utils.isBlank(response.responseBody())) {
7480
try {

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeTrendingExtractor.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020

2121
import java.io.IOException;
2222

23+
import javax.annotation.Nonnull;
24+
2325
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.COUNT_KEY;
2426
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.ITEMS_PER_PAGE;
2527
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.START_KEY;
28+
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
2629

2730
public class PeertubeTrendingExtractor extends KioskExtractor<StreamInfoItem> {
2831
public PeertubeTrendingExtractor(final StreamingService streamingService, final ListLinkHandler linkHandler, final String kioskId) {
@@ -60,7 +63,12 @@ private void collectStreamsFrom(final StreamInfoItemsCollector collector, final
6063

6164
@Override
6265
public InfoItemsPage<StreamInfoItem> getPage(final Page page) throws IOException, ExtractionException {
66+
if (page == null || isNullOrEmpty(page.getUrl())) {
67+
throw new IllegalArgumentException("Page doesn't contain an URL");
68+
}
69+
6370
final Response response = getDownloader().get(page.getUrl());
71+
6472
JsonObject json = null;
6573
if (response != null && !Utils.isBlank(response.responseBody())) {
6674
try {
@@ -84,5 +92,5 @@ public InfoItemsPage<StreamInfoItem> getPage(final Page page) throws IOException
8492
}
8593

8694
@Override
87-
public void onFetchPage(Downloader downloader) throws IOException, ExtractionException { }
95+
public void onFetchPage(@Nonnull final Downloader downloader) throws IOException, ExtractionException { }
8896
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChannelExtractor.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package org.schabi.newpipe.extractor.services.soundcloud.extractors;
22

3-
import com.grack.nanojson.JsonArray;
43
import com.grack.nanojson.JsonObject;
54
import com.grack.nanojson.JsonParser;
65
import com.grack.nanojson.JsonParserException;
6+
77
import org.schabi.newpipe.extractor.Page;
88
import org.schabi.newpipe.extractor.StreamingService;
99
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
@@ -15,9 +15,10 @@
1515
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
1616
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
1717

18-
import javax.annotation.Nonnull;
1918
import java.io.IOException;
2019

20+
import javax.annotation.Nonnull;
21+
2122
import static org.schabi.newpipe.extractor.utils.JsonUtils.EMPTY_STRING;
2223
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
2324

@@ -118,6 +119,10 @@ public InfoItemsPage<StreamInfoItem> getInitialPage() throws ExtractionException
118119

119120
@Override
120121
public InfoItemsPage<StreamInfoItem> getPage(final Page page) throws IOException, ExtractionException {
122+
if (page == null || isNullOrEmpty(page.getUrl())) {
123+
throw new IllegalArgumentException("Page doesn't contain an URL");
124+
}
125+
121126
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
122127
String nextPageUrl = SoundcloudParsingHelper.getStreamsFromApiMinItems(15, collector, page.getUrl());
123128

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChartsExtractor.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
1111
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
1212

13-
import javax.annotation.Nonnull;
1413
import java.io.IOException;
1514

15+
import javax.annotation.Nonnull;
16+
1617
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
1718
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
1819

@@ -34,7 +35,11 @@ public String getName() {
3435
}
3536

3637
@Override
37-
public InfoItemsPage<StreamInfoItem> getPage(Page page) throws IOException, ExtractionException {
38+
public InfoItemsPage<StreamInfoItem> getPage(final Page page) throws IOException, ExtractionException {
39+
if (page == null || isNullOrEmpty(page.getUrl())) {
40+
throw new IllegalArgumentException("Page doesn't contain an URL");
41+
}
42+
3843
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
3944
String nextPageUrl = SoundcloudParsingHelper.getStreamsFromApi(collector, page.getUrl(), true);
4045

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudCommentsExtractor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
import javax.annotation.Nonnull;
2323

24+
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
25+
2426
public class SoundcloudCommentsExtractor extends CommentsExtractor {
2527
public SoundcloudCommentsExtractor(final StreamingService service, final ListLinkHandler uiHandler) {
2628
super(service, uiHandler);
@@ -48,6 +50,10 @@ public InfoItemsPage<CommentsInfoItem> getInitialPage() throws ExtractionExcepti
4850

4951
@Override
5052
public InfoItemsPage<CommentsInfoItem> getPage(final Page page) throws ExtractionException, IOException {
53+
if (page == null || isNullOrEmpty(page.getUrl())) {
54+
throw new IllegalArgumentException("Page doesn't contain an URL");
55+
}
56+
5157
final Downloader downloader = NewPipe.getDownloader();
5258
final Response response = downloader.get(page.getUrl());
5359

0 commit comments

Comments
 (0)