From 86db415b181b81a1c12e781aba3e880e4a95626d Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 24 Feb 2018 22:20:50 +0100 Subject: [PATCH] architecture refacturing --- ...Collector.java => InfoItemsCollector.java} | 6 +-- .../newpipe/extractor/ListExtractor.java | 51 +++++++++--------- .../schabi/newpipe/extractor/ListInfo.java | 4 +- .../newpipe/extractor/StreamingService.java | 4 +- .../extractor/channel/ChannelExtractor.java | 21 +++++--- .../extractor/channel/ChannelInfo.java | 13 ++--- ...or.java => ChannelInfoItemsCollector.java} | 8 +-- .../extractor/kiosk/KioskExtractor.java | 10 ++-- .../newpipe/extractor/kiosk/KioskInfo.java | 10 ++-- .../newpipe/extractor/kiosk/KioskList.java | 16 +++--- .../extractor/playlist/PlaylistExtractor.java | 17 ++++-- .../extractor/playlist/PlaylistInfo.java | 14 ++--- ...r.java => PlaylistInfoItemsCollector.java} | 6 +-- ...tor.java => InfoItemsSearchCollector.java} | 24 ++++----- .../extractor/search/SearchEngine.java | 8 +-- .../SoundcloudChannelExtractor.java | 23 ++++---- .../soundcloud/SoundcloudChartsExtractor.java | 27 +++++----- .../soundcloud/SoundcloudParsingHelper.java | 54 +++++++++---------- .../SoundcloudPlaylistExtractor.java | 22 ++++---- .../soundcloud/SoundcloudSearchEngine.java | 6 +-- .../soundcloud/SoundcloudService.java | 12 ++--- .../soundcloud/SoundcloudStreamExtractor.java | 5 +- .../SoundcloudSubscriptionExtractor.java | 4 +- .../youtube/YoutubeChannelExtractor.java | 40 +++++++------- .../youtube/YoutubePlaylistExtractor.java | 34 ++++++------ .../services/youtube/YoutubeSearchEngine.java | 6 +-- .../services/youtube/YoutubeService.java | 12 ++--- .../youtube/YoutubeStreamExtractor.java | 6 +-- .../youtube/YoutubeTrendingExtractor.java | 14 ++--- .../extractor/stream/StreamExtractor.java | 3 +- ...tor.java => StreamInfoItemsCollector.java} | 8 +-- .../extractor/utils/ExtractorHelper.java | 14 ++--- .../SoundcloudChannelExtractorTest.java | 8 +-- .../SoundcloudChartsExtractorTest.java | 23 ++++---- .../SoundcloudPlaylistExtractorTest.java | 4 +- .../SoundcloudStreamExtractorDefaultTest.java | 4 +- .../youtube/YoutubeChannelExtractorTest.java | 8 +-- .../youtube/YoutubePlaylistExtractorTest.java | 12 ++--- .../YoutubeStreamExtractorDefaultTest.java | 2 +- .../youtube/YoutubeTrendingExtractorTest.java | 14 ++--- 40 files changed, 298 insertions(+), 279 deletions(-) rename src/main/java/org/schabi/newpipe/extractor/{InfoItemCollector.java => InfoItemsCollector.java} (92%) rename src/main/java/org/schabi/newpipe/extractor/channel/{ChannelInfoItemCollector.java => ChannelInfoItemsCollector.java} (87%) rename src/main/java/org/schabi/newpipe/extractor/playlist/{PlaylistInfoItemCollector.java => PlaylistInfoItemsCollector.java} (80%) rename src/main/java/org/schabi/newpipe/extractor/search/{InfoItemSearchCollector.java => InfoItemsSearchCollector.java} (77%) rename src/main/java/org/schabi/newpipe/extractor/stream/{StreamInfoItemCollector.java => StreamInfoItemsCollector.java} (92%) diff --git a/src/main/java/org/schabi/newpipe/extractor/InfoItemCollector.java b/src/main/java/org/schabi/newpipe/extractor/InfoItemsCollector.java similarity index 92% rename from src/main/java/org/schabi/newpipe/extractor/InfoItemCollector.java rename to src/main/java/org/schabi/newpipe/extractor/InfoItemsCollector.java index 0a008036..706f2912 100644 --- a/src/main/java/org/schabi/newpipe/extractor/InfoItemCollector.java +++ b/src/main/java/org/schabi/newpipe/extractor/InfoItemsCollector.java @@ -11,7 +11,7 @@ import java.util.List; * Created by Christian Schabesberger on 12.02.17. * * Copyright (C) Christian Schabesberger 2017 - * InfoItemCollector.java is part of NewPipe. + * InfoItemsCollector.java is part of NewPipe. * * NewPipe is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ import java.util.List; * along with NewPipe. If not, see . */ -public abstract class InfoItemCollector implements Collector { +public abstract class InfoItemsCollector implements Collector { private final List itemList = new ArrayList<>(); private final List errors = new ArrayList<>(); @@ -37,7 +37,7 @@ public abstract class InfoItemCollector implements Collec * Create a new collector * @param serviceId the service id */ - public InfoItemCollector(int serviceId) { + public InfoItemsCollector(int serviceId) { this.serviceId = serviceId; } diff --git a/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java b/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java index d5d25c2b..aeb1463d 100644 --- a/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java @@ -1,7 +1,6 @@ package org.schabi.newpipe.extractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; -import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; import javax.annotation.Nonnull; import java.io.IOException; @@ -11,73 +10,73 @@ import java.util.List; * Base class to extractors that have a list (e.g. playlists, users). */ public abstract class ListExtractor extends Extractor { - protected String nextStreamsUrl; + protected String nextPageUrl; /** - * Get a new ListExtractor with the given nextStreamsUrl set. + * Get a new ListExtractor with the given nextPageUrl set. */ - public ListExtractor(StreamingService service, String url, String nextStreamsUrl) throws ExtractionException { + public ListExtractor(StreamingService service, String url, String nextPageUrl) throws ExtractionException { super(service, url); - setNextStreamsUrl(nextStreamsUrl); + setNextPageUrl(nextPageUrl); } @Nonnull - public abstract StreamInfoItemCollector getStreams() throws IOException, ExtractionException; + public abstract InfoItemsCollector getInfoItems() throws IOException, ExtractionException; - public abstract NextItemsResult getNextStreams() throws IOException, ExtractionException; + public abstract InfoItemPage getInfoItemPage() throws IOException, ExtractionException; - public boolean hasMoreStreams() { - return nextStreamsUrl != null && !nextStreamsUrl.isEmpty(); + public boolean hasNextPage() { + return nextPageUrl != null && !nextPageUrl.isEmpty(); } - public String getNextStreamsUrl() { - return nextStreamsUrl; + public String getNextPageUrl() { + return nextPageUrl; } - public void setNextStreamsUrl(String nextStreamsUrl) { - this.nextStreamsUrl = nextStreamsUrl; + public void setNextPageUrl(String nextPageUrl) { + this.nextPageUrl = nextPageUrl; } /*////////////////////////////////////////////////////////////////////////// // Inner //////////////////////////////////////////////////////////////////////////*/ - public static class NextItemsResult { + public static class InfoItemPage { /** * The current list of items to this result */ - public final List nextItemsList; + public final List infoItemList; /** * Next url to fetch more items */ - public final String nextItemsUrl; + public final String nextPageUrl; /** * Errors that happened during the extraction */ public final List errors; - public NextItemsResult(InfoItemCollector collector, String nextItemsUrl) { - this(collector.getItemList(), nextItemsUrl, collector.getErrors()); + public InfoItemPage(InfoItemsCollector collector, String nextPageUrl) { + this(collector.getItemList(), nextPageUrl, collector.getErrors()); } - public NextItemsResult(List nextItemsList, String nextItemsUrl, List errors) { - this.nextItemsList = nextItemsList; - this.nextItemsUrl = nextItemsUrl; + public InfoItemPage(List infoItemList, String nextPageUrl, List errors) { + this.infoItemList = infoItemList; + this.nextPageUrl = nextPageUrl; this.errors = errors; } - public boolean hasMoreStreams() { - return nextItemsUrl != null && !nextItemsUrl.isEmpty(); + public boolean hasNextPage() { + return nextPageUrl != null && !nextPageUrl.isEmpty(); } public List getNextItemsList() { - return nextItemsList; + return infoItemList; } - public String getNextItemsUrl() { - return nextItemsUrl; + public String getNextPageUrl() { + return nextPageUrl; } public List getErrors() { diff --git a/src/main/java/org/schabi/newpipe/extractor/ListInfo.java b/src/main/java/org/schabi/newpipe/extractor/ListInfo.java index f84654bd..f99ba4ba 100644 --- a/src/main/java/org/schabi/newpipe/extractor/ListInfo.java +++ b/src/main/java/org/schabi/newpipe/extractor/ListInfo.java @@ -19,7 +19,7 @@ public abstract class ListInfo extends Info { this.related_streams = related_streams; } - public boolean hasMoreStreams() { + public boolean hasNextPage() { return has_more_streams; } @@ -27,7 +27,7 @@ public abstract class ListInfo extends Info { this.has_more_streams = has_more_streams; } - public String getNextStreamsUrl() { + public String getNextPageUrl() { return next_streams_url; } diff --git a/src/main/java/org/schabi/newpipe/extractor/StreamingService.java b/src/main/java/org/schabi/newpipe/extractor/StreamingService.java index 90a7f7de..9ae75168 100644 --- a/src/main/java/org/schabi/newpipe/extractor/StreamingService.java +++ b/src/main/java/org/schabi/newpipe/extractor/StreamingService.java @@ -69,8 +69,8 @@ public abstract class StreamingService { public abstract SearchEngine getSearchEngine(); public abstract SuggestionExtractor getSuggestionExtractor(); public abstract StreamExtractor getStreamExtractor(String url) throws IOException, ExtractionException; - public abstract ChannelExtractor getChannelExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException; - public abstract PlaylistExtractor getPlaylistExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException; + public abstract ChannelExtractor getChannelExtractor(String url, String nextPageUrl) throws IOException, ExtractionException; + public abstract PlaylistExtractor getPlaylistExtractor(String url, String nextPageUrl) throws IOException, ExtractionException; public abstract KioskList getKioskList() throws ExtractionException; public abstract SubscriptionExtractor getSubscriptionExtractor(); diff --git a/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java b/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java index db909fb9..efd24c93 100644 --- a/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java @@ -1,10 +1,10 @@ package org.schabi.newpipe.extractor.channel; -import org.schabi.newpipe.extractor.ListExtractor; -import org.schabi.newpipe.extractor.StreamingService; -import org.schabi.newpipe.extractor.UrlIdHandler; +import edu.umd.cs.findbugs.annotations.NonNull; +import org.schabi.newpipe.extractor.*; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import javax.annotation.Nonnull; import java.io.IOException; @@ -31,16 +31,25 @@ import java.io.IOException; public abstract class ChannelExtractor extends ListExtractor { - public ChannelExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException { - super(service, url, nextStreamsUrl); + public ChannelExtractor(StreamingService service, String url, String nextPageUrl) + throws ExtractionException { + super(service, url, nextPageUrl); } @Nonnull @Override - protected UrlIdHandler getUrlIdHandler() throws ParsingException { + protected UrlIdHandler getUrlIdHandler() { return getService().getChannelUrlIdHandler(); } + @NonNull + @Override + public InfoItemsCollector getInfoItems() + throws IOException, ExtractionException { + return getStreams(); + } + + public abstract StreamInfoItemsCollector getStreams() throws IOException, ExtractionException; public abstract String getAvatarUrl() throws ParsingException; public abstract String getBannerUrl() throws ParsingException; public abstract String getFeedUrl() throws ParsingException; diff --git a/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java b/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java index 07a14a3e..55c67490 100644 --- a/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java +++ b/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java @@ -1,6 +1,6 @@ package org.schabi.newpipe.extractor.channel; -import org.schabi.newpipe.extractor.ListExtractor.NextItemsResult; +import org.schabi.newpipe.extractor.ListExtractor.InfoItemPage; import org.schabi.newpipe.extractor.ListInfo; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; @@ -37,8 +37,9 @@ public class ChannelInfo extends ListInfo { } - public static NextItemsResult getMoreItems(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException { - return service.getChannelExtractor(url, nextStreamsUrl).getNextStreams(); + public static InfoItemPage getMoreItems(StreamingService service, String url, String nextPageUrl) + throws IOException, ExtractionException { + return service.getChannelExtractor(url, nextPageUrl).getInfoItemPage(); } public static ChannelInfo getInfo(String url) throws IOException, ExtractionException { @@ -78,7 +79,7 @@ public class ChannelInfo extends ListInfo { info.addError(e); } - info.setRelatedStreams(ExtractorHelper.getStreamsOrLogError(info, extractor)); + info.setRelatedStreams(ExtractorHelper.getInfoItemsOrLogError(info, extractor)); try { info.setSubscriberCount(extractor.getSubscriberCount()); @@ -91,8 +92,8 @@ public class ChannelInfo extends ListInfo { info.addError(e); } - info.setHasMoreStreams(extractor.hasMoreStreams()); - info.setNextStreamsUrl(extractor.getNextStreamsUrl()); + info.setHasMoreStreams(extractor.hasNextPage()); + info.setNextStreamsUrl(extractor.getNextPageUrl()); return info; } diff --git a/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemCollector.java b/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java similarity index 87% rename from src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemCollector.java rename to src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java index cf413879..a60636b2 100644 --- a/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemCollector.java +++ b/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java @@ -1,13 +1,13 @@ package org.schabi.newpipe.extractor.channel; -import org.schabi.newpipe.extractor.InfoItemCollector; +import org.schabi.newpipe.extractor.InfoItemsCollector; import org.schabi.newpipe.extractor.exceptions.ParsingException; /* * Created by Christian Schabesberger on 12.02.17. * * Copyright (C) Christian Schabesberger 2017 - * ChannelInfoItemCollector.java is part of NewPipe. + * ChannelInfoItemsCollector.java is part of NewPipe. * * NewPipe is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,8 +23,8 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; * along with NewPipe. If not, see . */ -public class ChannelInfoItemCollector extends InfoItemCollector { - public ChannelInfoItemCollector(int serviceId) { +public class ChannelInfoItemsCollector extends InfoItemsCollector { + public ChannelInfoItemsCollector(int serviceId) { super(serviceId); } diff --git a/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java b/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java index 923f5d03..5b6b7eea 100644 --- a/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java @@ -34,10 +34,10 @@ public abstract class KioskExtractor extends ListExtractor { public KioskExtractor(StreamingService streamingService, String url, - String nextStreamsUrl, + String nextPageUrl, String kioskId) - throws IOException, ExtractionException { - super(streamingService, url, nextStreamsUrl); + throws ExtractionException { + super(streamingService, url, nextPageUrl); this.id = kioskId; } @@ -54,12 +54,12 @@ public abstract class KioskExtractor extends ListExtractor { @Nonnull @Override - public String getId() throws ParsingException { + public String getId() { return id; } /** - * Id should be the name of the kiosk, tho Id is used for identifing it in the programm, + * Id should be the name of the kiosk, tho Id is used for identifing it in the frontend, * so id should be kept in english. * In order to get the name of the kiosk in the desired language we have to * crawl if from the website. diff --git a/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java b/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java index e1347c20..36b0e3b8 100644 --- a/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java +++ b/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java @@ -35,14 +35,14 @@ public class KioskInfo extends ListInfo { super(serviceId, id, url, name); } - public static ListExtractor.NextItemsResult getMoreItems(StreamingService service, + public static ListExtractor.InfoItemPage getMoreItems(StreamingService service, String url, - String nextStreamsUrl, + String nextPageUrl, String contentCountry) throws IOException, ExtractionException { KioskList kl = service.getKioskList(); - KioskExtractor extractor = kl.getExtractorByUrl(url, nextStreamsUrl); + KioskExtractor extractor = kl.getExtractorByUrl(url, nextPageUrl); extractor.setContentCountry(contentCountry); - return extractor.getNextStreams(); + return extractor.getInfoItemPage(); } public static KioskInfo getInfo(String url, @@ -74,7 +74,7 @@ public class KioskInfo extends ListInfo { KioskInfo info = new KioskInfo(serviceId, id, name, url); - info.related_streams = ExtractorHelper.getStreamsOrLogError(info, extractor); + info.related_streams = ExtractorHelper.getInfoItemsOrLogError(info, extractor); return info; } diff --git a/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java b/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java index 5256af8e..6120b077 100644 --- a/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java +++ b/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java @@ -14,7 +14,7 @@ public class KioskList { public interface KioskExtractorFactory { KioskExtractor createNewKiosk(final StreamingService streamingService, final String url, - final String nextStreamUrl, + final String nextPageUrl, final String kioskId) throws ExtractionException, IOException; } @@ -48,15 +48,15 @@ public class KioskList { defaultKiosk = kioskType; } - public KioskExtractor getDefaultKioskExtractor(String nextStreamUrl) + public KioskExtractor getDefaultKioskExtractor(String nextPageUrl) throws ExtractionException, IOException { if(defaultKiosk != null && !defaultKiosk.equals("")) { - return getExtractorById(defaultKiosk, nextStreamUrl); + return getExtractorById(defaultKiosk, nextPageUrl); } else { if(!kioskList.isEmpty()) { // if not set get any entry Object[] keySet = kioskList.keySet().toArray(); - return getExtractorById(keySet[0].toString(), nextStreamUrl); + return getExtractorById(keySet[0].toString(), nextPageUrl); } else { return null; } @@ -67,7 +67,7 @@ public class KioskList { return defaultKiosk; } - public KioskExtractor getExtractorById(String kioskId, String nextStreamsUrl) + public KioskExtractor getExtractorById(String kioskId, String nextPageUrl) throws ExtractionException, IOException { KioskEntry ke = kioskList.get(kioskId); if(ke == null) { @@ -75,7 +75,7 @@ public class KioskList { } else { return ke.extractorFactory.createNewKiosk(NewPipe.getService(service_id), ke.handler.getUrl(kioskId), - nextStreamsUrl, kioskId); + nextPageUrl, kioskId); } } @@ -83,12 +83,12 @@ public class KioskList { return kioskList.keySet(); } - public KioskExtractor getExtractorByUrl(String url, String nextStreamsUrl) + public KioskExtractor getExtractorByUrl(String url, String nextPageUrl) throws ExtractionException, IOException { for(Map.Entry e : kioskList.entrySet()) { KioskEntry ke = e.getValue(); if(ke.handler.acceptUrl(url)) { - return getExtractorById(e.getKey(), nextStreamsUrl); + return getExtractorById(e.getKey(), nextPageUrl); } } throw new ExtractionException("Could not find a kiosk that fits to the url: " + url); diff --git a/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java b/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java index 2223c6a0..9e79cf36 100644 --- a/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java @@ -1,26 +1,37 @@ package org.schabi.newpipe.extractor.playlist; +import edu.umd.cs.findbugs.annotations.NonNull; +import org.schabi.newpipe.extractor.InfoItemsCollector; import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.UrlIdHandler; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import javax.annotation.Nonnull; import java.io.IOException; public abstract class PlaylistExtractor extends ListExtractor { - public PlaylistExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException { - super(service, url, nextStreamsUrl); + public PlaylistExtractor(StreamingService service, String url, String nextPageUrl) throws IOException, ExtractionException { + super(service, url, nextPageUrl); } @Nonnull @Override - protected UrlIdHandler getUrlIdHandler() throws ParsingException { + protected UrlIdHandler getUrlIdHandler() { return getService().getPlaylistUrlIdHandler(); } + @NonNull + @Override + public InfoItemsCollector getInfoItems() + throws IOException, ExtractionException { + return getStreams(); + } + + public abstract StreamInfoItemsCollector getStreams() throws IOException, ExtractionException; public abstract String getThumbnailUrl() throws ParsingException; public abstract String getBannerUrl() throws ParsingException; diff --git a/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java b/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java index 8124aa63..9f213eeb 100644 --- a/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java +++ b/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java @@ -1,6 +1,6 @@ package org.schabi.newpipe.extractor.playlist; -import org.schabi.newpipe.extractor.ListExtractor.NextItemsResult; +import org.schabi.newpipe.extractor.ListExtractor.InfoItemPage; import org.schabi.newpipe.extractor.ListInfo; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; @@ -9,7 +9,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import java.io.IOException; -import static org.schabi.newpipe.extractor.utils.ExtractorHelper.getStreamsOrLogError; +import static org.schabi.newpipe.extractor.utils.ExtractorHelper.getInfoItemsOrLogError; public class PlaylistInfo extends ListInfo { @@ -17,8 +17,8 @@ public class PlaylistInfo extends ListInfo { super(serviceId, id, url, name); } - public static NextItemsResult getMoreItems(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException { - return service.getPlaylistExtractor(url, nextStreamsUrl).getNextStreams(); + public static InfoItemPage getMoreItems(StreamingService service, String url, String nextPageUrl) throws IOException, ExtractionException { + return service.getPlaylistExtractor(url, nextPageUrl).getInfoItemPage(); } public static PlaylistInfo getInfo(String url) throws IOException, ExtractionException { @@ -75,9 +75,9 @@ public class PlaylistInfo extends ListInfo { info.addError(e); } - info.setRelatedStreams(getStreamsOrLogError(info, extractor)); - info.setHasMoreStreams(extractor.hasMoreStreams()); - info.setNextStreamsUrl(extractor.getNextStreamsUrl()); + info.setRelatedStreams(getInfoItemsOrLogError(info, extractor)); + info.setHasMoreStreams(extractor.hasNextPage()); + info.setNextStreamsUrl(extractor.getNextPageUrl()); return info; } diff --git a/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemCollector.java b/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemsCollector.java similarity index 80% rename from src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemCollector.java rename to src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemsCollector.java index cbdb7783..354ab8f1 100644 --- a/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemCollector.java +++ b/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemsCollector.java @@ -1,11 +1,11 @@ package org.schabi.newpipe.extractor.playlist; -import org.schabi.newpipe.extractor.InfoItemCollector; +import org.schabi.newpipe.extractor.InfoItemsCollector; import org.schabi.newpipe.extractor.exceptions.ParsingException; -public class PlaylistInfoItemCollector extends InfoItemCollector { +public class PlaylistInfoItemsCollector extends InfoItemsCollector { - public PlaylistInfoItemCollector(int serviceId) { + public PlaylistInfoItemsCollector(int serviceId) { super(serviceId); } diff --git a/src/main/java/org/schabi/newpipe/extractor/search/InfoItemSearchCollector.java b/src/main/java/org/schabi/newpipe/extractor/search/InfoItemsSearchCollector.java similarity index 77% rename from src/main/java/org/schabi/newpipe/extractor/search/InfoItemSearchCollector.java rename to src/main/java/org/schabi/newpipe/extractor/search/InfoItemsSearchCollector.java index ba0f8605..9779120e 100644 --- a/src/main/java/org/schabi/newpipe/extractor/search/InfoItemSearchCollector.java +++ b/src/main/java/org/schabi/newpipe/extractor/search/InfoItemsSearchCollector.java @@ -1,20 +1,20 @@ package org.schabi.newpipe.extractor.search; import org.schabi.newpipe.extractor.*; -import org.schabi.newpipe.extractor.channel.ChannelInfoItemCollector; +import org.schabi.newpipe.extractor.channel.ChannelInfoItemsCollector; import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.playlist.PlaylistInfoItemCollector; +import org.schabi.newpipe.extractor.playlist.PlaylistInfoItemsCollector; import org.schabi.newpipe.extractor.playlist.PlaylistInfoItemExtractor; -import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; +import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor; /* * Created by Christian Schabesberger on 12.02.17. * * Copyright (C) Christian Schabesberger 2017 - * InfoItemSearchCollector.java is part of NewPipe. + * InfoItemsSearchCollector.java is part of NewPipe. * * NewPipe is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,17 +42,17 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor; * Calling {@link #extract(InfoItemExtractor)} or {@link #commit(Object)} with any * other extractor type will raise an exception. */ -public class InfoItemSearchCollector extends InfoItemCollector { +public class InfoItemsSearchCollector extends InfoItemsCollector { private String suggestion = ""; - private final StreamInfoItemCollector streamCollector; - private final ChannelInfoItemCollector userCollector; - private final PlaylistInfoItemCollector playlistCollector; + private final StreamInfoItemsCollector streamCollector; + private final ChannelInfoItemsCollector userCollector; + private final PlaylistInfoItemsCollector playlistCollector; - InfoItemSearchCollector(int serviceId) { + InfoItemsSearchCollector(int serviceId) { super(serviceId); - streamCollector = new StreamInfoItemCollector(serviceId); - userCollector = new ChannelInfoItemCollector(serviceId); - playlistCollector = new PlaylistInfoItemCollector(serviceId); + streamCollector = new StreamInfoItemsCollector(serviceId); + userCollector = new ChannelInfoItemsCollector(serviceId); + playlistCollector = new PlaylistInfoItemsCollector(serviceId); } public void setSuggestion(String suggestion) { diff --git a/src/main/java/org/schabi/newpipe/extractor/search/SearchEngine.java b/src/main/java/org/schabi/newpipe/extractor/search/SearchEngine.java index 87888832..ce32c5f6 100644 --- a/src/main/java/org/schabi/newpipe/extractor/search/SearchEngine.java +++ b/src/main/java/org/schabi/newpipe/extractor/search/SearchEngine.java @@ -35,16 +35,16 @@ public abstract class SearchEngine { } } - private final InfoItemSearchCollector collector; + private final InfoItemsSearchCollector collector; public SearchEngine(int serviceId) { - collector = new InfoItemSearchCollector(serviceId); + collector = new InfoItemsSearchCollector(serviceId); } - protected InfoItemSearchCollector getInfoItemSearchCollector() { + protected InfoItemsSearchCollector getInfoItemSearchCollector() { return collector; } - public abstract InfoItemSearchCollector search(String query, int page, String contentCountry, Filter filter) + public abstract InfoItemsSearchCollector search(String query, int page, String contentCountry, Filter filter) throws IOException, ExtractionException; } diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java index e81fe2cb..bb66df35 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java @@ -4,12 +4,11 @@ import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonParser; import com.grack.nanojson.JsonParserException; import org.schabi.newpipe.extractor.Downloader; -import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.channel.ChannelExtractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; +import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import javax.annotation.Nonnull; import java.io.IOException; @@ -19,8 +18,8 @@ public class SoundcloudChannelExtractor extends ChannelExtractor { private String userId; private JsonObject user; - public SoundcloudChannelExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException { - super(service, url, nextStreamsUrl); + public SoundcloudChannelExtractor(StreamingService service, String url, String nextPageUrl) throws IOException, ExtractionException { + super(service, url, nextPageUrl); } @Override @@ -87,27 +86,27 @@ public class SoundcloudChannelExtractor extends ChannelExtractor { @Nonnull @Override - public StreamInfoItemCollector getStreams() throws IOException, ExtractionException { - StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId()); + public StreamInfoItemsCollector getStreams() throws IOException, ExtractionException { + StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); String apiUrl = "https://api-v2.soundcloud.com/users/" + getId() + "/tracks" + "?client_id=" + SoundcloudParsingHelper.clientId() + "&limit=20" + "&linked_partitioning=1"; - nextStreamsUrl = SoundcloudParsingHelper.getStreamsFromApiMinItems(15, collector, apiUrl); + nextPageUrl = SoundcloudParsingHelper.getStreamsFromApiMinItems(15, collector, apiUrl); return collector; } @Override - public NextItemsResult getNextStreams() throws IOException, ExtractionException { - if (!hasMoreStreams()) { + public InfoItemPage getInfoItemPage() throws IOException, ExtractionException { + if (!hasNextPage()) { throw new ExtractionException("Channel doesn't have more streams"); } - StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId()); - nextStreamsUrl = SoundcloudParsingHelper.getStreamsFromApiMinItems(15, collector, nextStreamsUrl); + StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); + nextPageUrl = SoundcloudParsingHelper.getStreamsFromApiMinItems(15, collector, nextPageUrl); - return new NextItemsResult(collector, nextStreamsUrl); + return new InfoItemPage(collector, nextPageUrl); } } diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java index e5e9348b..0f62ae87 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java @@ -8,18 +8,17 @@ import org.schabi.newpipe.extractor.Downloader; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.UrlIdHandler; import org.schabi.newpipe.extractor.exceptions.ExtractionException; -import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.kiosk.KioskExtractor; -import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; +import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import javax.annotation.Nonnull; public class SoundcloudChartsExtractor extends KioskExtractor { private String url; - public SoundcloudChartsExtractor(StreamingService service, String url, String nextStreamsUrl, String kioskId) - throws IOException, ExtractionException { - super(service, url, nextStreamsUrl, kioskId); + public SoundcloudChartsExtractor(StreamingService service, String url, String nextPageUrl, String kioskId) + throws ExtractionException { + super(service, url, nextPageUrl, kioskId); this.url = url; } @@ -29,7 +28,7 @@ public class SoundcloudChartsExtractor extends KioskExtractor { @Nonnull @Override - public String getName() throws ParsingException { + public String getName() { return "< Implement me (♥_♥) >"; } @@ -40,21 +39,21 @@ public class SoundcloudChartsExtractor extends KioskExtractor { } @Override - public NextItemsResult getNextStreams() throws IOException, ExtractionException { - if (!hasMoreStreams()) { + public InfoItemPage getInfoItemPage() throws IOException, ExtractionException { + if (!hasNextPage()) { throw new ExtractionException("Chart doesn't have more streams"); } - StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId()); - nextStreamsUrl = SoundcloudParsingHelper.getStreamsFromApi(collector, nextStreamsUrl, true); + StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); + nextPageUrl = SoundcloudParsingHelper.getStreamsFromApi(collector, nextPageUrl, true); - return new NextItemsResult(collector, nextStreamsUrl); + return new InfoItemPage(collector, nextPageUrl); } @Nonnull @Override - public StreamInfoItemCollector getStreams() throws IOException, ExtractionException { - StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId()); + public StreamInfoItemsCollector getInfoItems() throws IOException, ExtractionException { + StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); String apiUrl = "https://api-v2.soundcloud.com/charts" + "?genre=soundcloud:genres:all-music" + @@ -72,7 +71,7 @@ public class SoundcloudChartsExtractor extends KioskExtractor { apiUrl += "®ion=soundcloud:regions:" + contentCountry; } - nextStreamsUrl = SoundcloudParsingHelper.getStreamsFromApi(collector, apiUrl, true); + nextPageUrl = SoundcloudParsingHelper.getStreamsFromApi(collector, apiUrl, true); return collector; } } diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java index 40cc51c7..bdb58673 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java @@ -9,10 +9,10 @@ import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.schabi.newpipe.extractor.Downloader; import org.schabi.newpipe.extractor.NewPipe; -import org.schabi.newpipe.extractor.channel.ChannelInfoItemCollector; +import org.schabi.newpipe.extractor.channel.ChannelInfoItemsCollector; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; -import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; +import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Parser.RegexException; @@ -112,19 +112,19 @@ public class SoundcloudParsingHelper { /** * Fetch the users from the given api and commit each of them to the collector. *

- * This differ from {@link #getUsersFromApi(ChannelInfoItemCollector, String)} in the sense that they will always + * This differ from {@link #getUsersFromApi(ChannelInfoItemsCollector, String)} in the sense that they will always * get MIN_ITEMS or more. * * @param minItems the method will return only when it have extracted that many items (equal or more) */ - public static String getUsersFromApiMinItems(int minItems, ChannelInfoItemCollector collector, String apiUrl) throws IOException, ReCaptchaException, ParsingException { - String nextStreamsUrl = SoundcloudParsingHelper.getUsersFromApi(collector, apiUrl); + public static String getUsersFromApiMinItems(int minItems, ChannelInfoItemsCollector collector, String apiUrl) throws IOException, ReCaptchaException, ParsingException { + String nextPageUrl = SoundcloudParsingHelper.getUsersFromApi(collector, apiUrl); - while (!nextStreamsUrl.isEmpty() && collector.getItemList().size() < minItems) { - nextStreamsUrl = SoundcloudParsingHelper.getUsersFromApi(collector, nextStreamsUrl); + while (!nextPageUrl.isEmpty() && collector.getItemList().size() < minItems) { + nextPageUrl = SoundcloudParsingHelper.getUsersFromApi(collector, nextPageUrl); } - return nextStreamsUrl; + return nextPageUrl; } /** @@ -132,7 +132,7 @@ public class SoundcloudParsingHelper { * * @return the next streams url, empty if don't have */ - public static String getUsersFromApi(ChannelInfoItemCollector collector, String apiUrl) throws IOException, ReCaptchaException, ParsingException { + public static String getUsersFromApi(ChannelInfoItemsCollector collector, String apiUrl) throws IOException, ReCaptchaException, ParsingException { String response = NewPipe.getDownloader().download(apiUrl); JsonObject responseObject; try { @@ -149,33 +149,33 @@ public class SoundcloudParsingHelper { } } - String nextStreamsUrl; + String nextPageUrl; try { - nextStreamsUrl = responseObject.getString("next_href"); - if (!nextStreamsUrl.contains("client_id=")) nextStreamsUrl += "&client_id=" + SoundcloudParsingHelper.clientId(); + nextPageUrl = responseObject.getString("next_href"); + if (!nextPageUrl.contains("client_id=")) nextPageUrl += "&client_id=" + SoundcloudParsingHelper.clientId(); } catch (Exception ignored) { - nextStreamsUrl = ""; + nextPageUrl = ""; } - return nextStreamsUrl; + return nextPageUrl; } /** * Fetch the streams from the given api and commit each of them to the collector. *

- * This differ from {@link #getStreamsFromApi(StreamInfoItemCollector, String)} in the sense that they will always + * This differ from {@link #getStreamsFromApi(StreamInfoItemsCollector, String)} in the sense that they will always * get MIN_ITEMS or more items. * * @param minItems the method will return only when it have extracted that many items (equal or more) */ - public static String getStreamsFromApiMinItems(int minItems, StreamInfoItemCollector collector, String apiUrl) throws IOException, ReCaptchaException, ParsingException { - String nextStreamsUrl = SoundcloudParsingHelper.getStreamsFromApi(collector, apiUrl); + public static String getStreamsFromApiMinItems(int minItems, StreamInfoItemsCollector collector, String apiUrl) throws IOException, ReCaptchaException, ParsingException { + String nextPageUrl = SoundcloudParsingHelper.getStreamsFromApi(collector, apiUrl); - while (!nextStreamsUrl.isEmpty() && collector.getItemList().size() < minItems) { - nextStreamsUrl = SoundcloudParsingHelper.getStreamsFromApi(collector, nextStreamsUrl); + while (!nextPageUrl.isEmpty() && collector.getItemList().size() < minItems) { + nextPageUrl = SoundcloudParsingHelper.getStreamsFromApi(collector, nextPageUrl); } - return nextStreamsUrl; + return nextPageUrl; } /** @@ -183,7 +183,7 @@ public class SoundcloudParsingHelper { * * @return the next streams url, empty if don't have */ - public static String getStreamsFromApi(StreamInfoItemCollector collector, String apiUrl, boolean charts) throws IOException, ReCaptchaException, ParsingException { + public static String getStreamsFromApi(StreamInfoItemsCollector collector, String apiUrl, boolean charts) throws IOException, ReCaptchaException, ParsingException { String response = NewPipe.getDownloader().download(apiUrl); JsonObject responseObject; try { @@ -200,18 +200,18 @@ public class SoundcloudParsingHelper { } } - String nextStreamsUrl; + String nextPageUrl; try { - nextStreamsUrl = responseObject.getString("next_href"); - if (!nextStreamsUrl.contains("client_id=")) nextStreamsUrl += "&client_id=" + SoundcloudParsingHelper.clientId(); + nextPageUrl = responseObject.getString("next_href"); + if (!nextPageUrl.contains("client_id=")) nextPageUrl += "&client_id=" + SoundcloudParsingHelper.clientId(); } catch (Exception ignored) { - nextStreamsUrl = ""; + nextPageUrl = ""; } - return nextStreamsUrl; + return nextPageUrl; } - public static String getStreamsFromApi(StreamInfoItemCollector collector, String apiUrl) throws ReCaptchaException, ParsingException, IOException { + public static String getStreamsFromApi(StreamInfoItemsCollector collector, String apiUrl) throws ReCaptchaException, ParsingException, IOException { return getStreamsFromApi(collector, apiUrl, false); } diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java index a5391db7..9216ebaf 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java @@ -8,7 +8,7 @@ import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; -import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; +import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import javax.annotation.Nonnull; import java.io.IOException; @@ -18,8 +18,8 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor { private String playlistId; private JsonObject playlist; - public SoundcloudPlaylistExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException { - super(service, url, nextStreamsUrl); + public SoundcloudPlaylistExtractor(StreamingService service, String url, String nextPageUrl) throws IOException, ExtractionException { + super(service, url, nextPageUrl); } @Override @@ -88,8 +88,8 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor { @Nonnull @Override - public StreamInfoItemCollector getStreams() throws IOException, ExtractionException { - StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId()); + public StreamInfoItemsCollector getStreams() throws IOException, ExtractionException { + StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); // Note the "api", NOT "api-v2" String apiUrl = "https://api.soundcloud.com/playlists/" + getId() + "/tracks" @@ -97,19 +97,19 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor { + "&limit=20" + "&linked_partitioning=1"; - nextStreamsUrl = SoundcloudParsingHelper.getStreamsFromApiMinItems(15, collector, apiUrl); + nextPageUrl = SoundcloudParsingHelper.getStreamsFromApiMinItems(15, collector, apiUrl); return collector; } @Override - public NextItemsResult getNextStreams() throws IOException, ExtractionException { - if (!hasMoreStreams()) { + public InfoItemPage getInfoItemPage() throws IOException, ExtractionException { + if (!hasNextPage()) { throw new ExtractionException("Playlist doesn't have more streams"); } - StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId()); - nextStreamsUrl = SoundcloudParsingHelper.getStreamsFromApiMinItems(15, collector, nextStreamsUrl); + StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); + nextPageUrl = SoundcloudParsingHelper.getStreamsFromApiMinItems(15, collector, nextPageUrl); - return new NextItemsResult(collector, nextStreamsUrl); + return new InfoItemPage(collector, nextPageUrl); } } diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngine.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngine.java index b271d388..3cd27031 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngine.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngine.java @@ -8,7 +8,7 @@ import org.schabi.newpipe.extractor.Downloader; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.search.InfoItemSearchCollector; +import org.schabi.newpipe.extractor.search.InfoItemsSearchCollector; import org.schabi.newpipe.extractor.search.SearchEngine; import java.io.IOException; @@ -22,8 +22,8 @@ public class SoundcloudSearchEngine extends SearchEngine { } @Override - public InfoItemSearchCollector search(String query, int page, String languageCode, Filter filter) throws IOException, ExtractionException { - InfoItemSearchCollector collector = getInfoItemSearchCollector(); + public InfoItemsSearchCollector search(String query, int page, String languageCode, Filter filter) throws IOException, ExtractionException { + InfoItemsSearchCollector collector = getInfoItemSearchCollector(); Downloader dl = NewPipe.getDownloader(); diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java index a5ff0712..636e5533 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java @@ -50,13 +50,13 @@ public class SoundcloudService extends StreamingService { } @Override - public ChannelExtractor getChannelExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException { - return new SoundcloudChannelExtractor(this, url, nextStreamsUrl); + public ChannelExtractor getChannelExtractor(String url, String nextPageUrl) throws IOException, ExtractionException { + return new SoundcloudChannelExtractor(this, url, nextPageUrl); } @Override - public PlaylistExtractor getPlaylistExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException { - return new SoundcloudPlaylistExtractor(this, url, nextStreamsUrl); + public PlaylistExtractor getPlaylistExtractor(String url, String nextPageUrl) throws IOException, ExtractionException { + return new SoundcloudPlaylistExtractor(this, url, nextPageUrl); } @Override @@ -70,12 +70,12 @@ public class SoundcloudService extends StreamingService { @Override public KioskExtractor createNewKiosk(StreamingService streamingService, String url, - String nextStreamUrl, + String nextPageUrl, String id) throws ExtractionException, IOException { return new SoundcloudChartsExtractor(SoundcloudService.this, url, - nextStreamUrl, + nextPageUrl, id); } }; diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java index 9672c63c..28353c97 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java @@ -10,7 +10,6 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.stream.*; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -189,8 +188,8 @@ public class SoundcloudStreamExtractor extends StreamExtractor { } @Override - public StreamInfoItemCollector getRelatedVideos() throws IOException, ExtractionException { - StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId()); + public StreamInfoItemsCollector getRelatedVideos() throws IOException, ExtractionException { + StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); String apiUrl = "https://api-v2.soundcloud.com/tracks/" + urlEncode(getId()) + "/related" + "?client_id=" + urlEncode(SoundcloudParsingHelper.clientId()); diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSubscriptionExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSubscriptionExtractor.java index 81af0b3d..67870be4 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSubscriptionExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSubscriptionExtractor.java @@ -1,7 +1,7 @@ package org.schabi.newpipe.extractor.services.soundcloud; import org.schabi.newpipe.extractor.channel.ChannelInfoItem; -import org.schabi.newpipe.extractor.channel.ChannelInfoItemCollector; +import org.schabi.newpipe.extractor.channel.ChannelInfoItemsCollector; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; import org.schabi.newpipe.extractor.subscription.SubscriptionItem; @@ -39,7 +39,7 @@ public class SoundcloudSubscriptionExtractor extends SubscriptionExtractor { String apiUrl = "https://api.soundcloud.com/users/" + id + "/followings" + "?client_id=" + SoundcloudParsingHelper.clientId() + "&limit=200"; - ChannelInfoItemCollector collector = new ChannelInfoItemCollector(service.getServiceId()); + ChannelInfoItemsCollector collector = new ChannelInfoItemsCollector(service.getServiceId()); // ± 2000 is the limit of followings on SoundCloud, so this minimum should be enough SoundcloudParsingHelper.getUsersFromApiMinItems(2500, collector, apiUrl); diff --git a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractor.java index 654f59d4..b24db213 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractor.java @@ -14,7 +14,7 @@ import org.schabi.newpipe.extractor.channel.ChannelExtractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; -import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; +import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Utils; @@ -48,7 +48,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor { private Document doc; /** - * It's lazily initialized (when getNextStreams is called) + * It's lazily initialized (when getInfoItemPage is called) */ private Document nextStreamsAjax; @@ -60,10 +60,10 @@ public class YoutubeChannelExtractor extends ChannelExtractor { */ private boolean fetchingNextStreams; - public YoutubeChannelExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException { - super(service, url, nextStreamsUrl); + public YoutubeChannelExtractor(StreamingService service, String url, String nextPageUrl) throws IOException, ExtractionException { + super(service, url, nextPageUrl); - fetchingNextStreams = nextStreamsUrl != null && !nextStreamsUrl.isEmpty(); + fetchingNextStreams = nextPageUrl != null && !nextPageUrl.isEmpty(); } @Override @@ -73,7 +73,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor { doc = Jsoup.parse(pageContent, channelUrl); if (!fetchingNextStreams) { - nextStreamsUrl = getNextStreamsUrlFrom(doc); + nextPageUrl = getNextPageUrlFrom(doc); } nextStreamsAjax = null; } @@ -163,49 +163,49 @@ public class YoutubeChannelExtractor extends ChannelExtractor { @Nonnull @Override - public StreamInfoItemCollector getStreams() throws IOException, ExtractionException { - StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId()); + public StreamInfoItemsCollector getStreams() throws ExtractionException { + StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); Element ul = doc.select("ul[id=\"browse-items-primary\"]").first(); collectStreamsFrom(collector, ul); return collector; } @Override - public NextItemsResult getNextStreams() throws IOException, ExtractionException { - if (!hasMoreStreams()) { + public InfoItemPage getInfoItemPage() throws IOException, ExtractionException { + if (!hasNextPage()) { throw new ExtractionException("Channel doesn't have more streams"); } fetchPage(); - StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId()); + StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); - setupNextStreamsAjax(NewPipe.getDownloader()); + setupNextPageAjax(NewPipe.getDownloader()); collectStreamsFrom(collector, nextStreamsAjax.select("body").first()); - return new NextItemsResult(collector, nextStreamsUrl); + return new InfoItemPage(collector, nextPageUrl); } - private void setupNextStreamsAjax(Downloader downloader) throws IOException, ReCaptchaException, ParsingException { - String ajaxDataRaw = downloader.download(nextStreamsUrl); + private void setupNextPageAjax(Downloader downloader) throws IOException, ReCaptchaException, ParsingException { + String ajaxDataRaw = downloader.download(nextPageUrl); try { JsonObject ajaxData = JsonParser.object().from(ajaxDataRaw); String htmlDataRaw = ajaxData.getString("content_html"); - nextStreamsAjax = Jsoup.parse(htmlDataRaw, nextStreamsUrl); + nextStreamsAjax = Jsoup.parse(htmlDataRaw, nextPageUrl); String nextStreamsHtmlDataRaw = ajaxData.getString("load_more_widget_html"); if (!nextStreamsHtmlDataRaw.isEmpty()) { - nextStreamsUrl = getNextStreamsUrlFrom(Jsoup.parse(nextStreamsHtmlDataRaw, nextStreamsUrl)); + nextPageUrl = getNextPageUrlFrom(Jsoup.parse(nextStreamsHtmlDataRaw, nextPageUrl)); } else { - nextStreamsUrl = ""; + nextPageUrl = ""; } } catch (JsonParserException e) { throw new ParsingException("Could not parse json data for next streams", e); } } - private String getNextStreamsUrlFrom(Document d) throws ParsingException { + private String getNextPageUrlFrom(Document d) throws ParsingException { try { Element button = d.select("button[class*=\"yt-uix-load-more\"]").first(); if (button != null) { @@ -219,7 +219,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor { } } - private void collectStreamsFrom(StreamInfoItemCollector collector, Element element) throws ParsingException { + private void collectStreamsFrom(StreamInfoItemsCollector collector, Element element) throws ParsingException { collector.reset(); final String uploaderName = getName(); diff --git a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractor.java index 11287237..27c92c7d 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractor.java @@ -14,7 +14,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; -import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; +import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import org.schabi.newpipe.extractor.stream.StreamType; import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Utils; @@ -27,12 +27,12 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor { private Document doc; /** - * It's lazily initialized (when getNextStreams is called) + * It's lazily initialized (when getInfoItemPage is called) */ private Document nextStreamsAjax; - public YoutubePlaylistExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException { - super(service, url, nextStreamsUrl); + public YoutubePlaylistExtractor(StreamingService service, String url, String nextPageUrl) throws IOException, ExtractionException { + super(service, url, nextPageUrl); } @Override @@ -40,7 +40,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor { String pageContent = downloader.download(getCleanUrl()); doc = Jsoup.parse(pageContent, getCleanUrl()); - nextStreamsUrl = getNextStreamsUrlFrom(doc); + nextPageUrl = getNextPageUrlFrom(doc); nextStreamsAjax = null; } @@ -143,46 +143,46 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor { @Nonnull @Override - public StreamInfoItemCollector getStreams() throws IOException, ExtractionException { - StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId()); + public StreamInfoItemsCollector getStreams() throws IOException, ExtractionException { + StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); Element tbody = doc.select("tbody[id=\"pl-load-more-destination\"]").first(); collectStreamsFrom(collector, tbody); return collector; } @Override - public NextItemsResult getNextStreams() throws IOException, ExtractionException { - if (!hasMoreStreams()) { + public InfoItemPage getInfoItemPage() throws IOException, ExtractionException { + if (!hasNextPage()) { throw new ExtractionException("Playlist doesn't have more streams"); } - StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId()); + StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); setupNextStreamsAjax(NewPipe.getDownloader()); collectStreamsFrom(collector, nextStreamsAjax.select("tbody[id=\"pl-load-more-destination\"]").first()); - return new NextItemsResult(collector, nextStreamsUrl); + return new InfoItemPage(collector, nextPageUrl); } private void setupNextStreamsAjax(Downloader downloader) throws IOException, ReCaptchaException, ParsingException { - String ajaxDataRaw = downloader.download(nextStreamsUrl); + String ajaxDataRaw = downloader.download(nextPageUrl); try { JsonObject ajaxData = JsonParser.object().from(ajaxDataRaw); String htmlDataRaw = "" + ajaxData.getString("content_html") + "
"; - nextStreamsAjax = Jsoup.parse(htmlDataRaw, nextStreamsUrl); + nextStreamsAjax = Jsoup.parse(htmlDataRaw, nextPageUrl); String nextStreamsHtmlDataRaw = ajaxData.getString("load_more_widget_html"); if (!nextStreamsHtmlDataRaw.isEmpty()) { - nextStreamsUrl = getNextStreamsUrlFrom(Jsoup.parse(nextStreamsHtmlDataRaw, nextStreamsUrl)); + nextPageUrl = getNextPageUrlFrom(Jsoup.parse(nextStreamsHtmlDataRaw, nextPageUrl)); } else { - nextStreamsUrl = ""; + nextPageUrl = ""; } } catch (JsonParserException e) { throw new ParsingException("Could not parse json data for next streams", e); } } - private String getNextStreamsUrlFrom(Document d) throws ParsingException { + private String getNextPageUrlFrom(Document d) throws ParsingException { try { Element button = d.select("button[class*=\"yt-uix-load-more\"]").first(); if (button != null) { @@ -196,7 +196,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor { } } - private void collectStreamsFrom(StreamInfoItemCollector collector, Element element) throws ParsingException { + private void collectStreamsFrom(StreamInfoItemsCollector collector, Element element) throws ParsingException { collector.reset(); final UrlIdHandler streamUrlIdHandler = getService().getStreamUrlIdHandler(); diff --git a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java index 5f8cb87e..d393c360 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java @@ -6,7 +6,7 @@ import org.jsoup.nodes.Element; import org.schabi.newpipe.extractor.Downloader; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ExtractionException; -import org.schabi.newpipe.extractor.search.InfoItemSearchCollector; +import org.schabi.newpipe.extractor.search.InfoItemsSearchCollector; import org.schabi.newpipe.extractor.search.SearchEngine; import java.io.IOException; @@ -43,9 +43,9 @@ public class YoutubeSearchEngine extends SearchEngine { } @Override - public InfoItemSearchCollector search(String query, int page, String languageCode, Filter filter) + public InfoItemsSearchCollector search(String query, int page, String languageCode, Filter filter) throws IOException, ExtractionException { - InfoItemSearchCollector collector = getInfoItemSearchCollector(); + InfoItemsSearchCollector collector = getInfoItemSearchCollector(); Downloader downloader = NewPipe.getDownloader(); String url = "https://www.youtube.com/results" diff --git a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java index 51dc0b12..d52dbda7 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java @@ -70,13 +70,13 @@ public class YoutubeService extends StreamingService { } @Override - public ChannelExtractor getChannelExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException { - return new YoutubeChannelExtractor(this, url, nextStreamsUrl); + public ChannelExtractor getChannelExtractor(String url, String nextPageUrl) throws IOException, ExtractionException { + return new YoutubeChannelExtractor(this, url, nextPageUrl); } @Override - public PlaylistExtractor getPlaylistExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException { - return new YoutubePlaylistExtractor(this, url, nextStreamsUrl); + public PlaylistExtractor getPlaylistExtractor(String url, String nextPageUrl) throws IOException, ExtractionException { + return new YoutubePlaylistExtractor(this, url, nextPageUrl); } @Override @@ -92,9 +92,9 @@ public class YoutubeService extends StreamingService { try { list.addKioskEntry(new KioskList.KioskExtractorFactory() { @Override - public KioskExtractor createNewKiosk(StreamingService streamingService, String url, String nextStreamUrl, String id) + public KioskExtractor createNewKiosk(StreamingService streamingService, String url, String nextPageUrl, String id) throws ExtractionException, IOException { - return new YoutubeTrendingExtractor(YoutubeService.this, url, nextStreamUrl, id); + return new YoutubeTrendingExtractor(YoutubeService.this, url, nextPageUrl, id); } }, new YoutubeTrendingUrlIdHandler(), "Trending"); list.setDefaultKiosk("Trending"); 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 0d203558..346ea118 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 @@ -452,7 +452,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { public StreamInfoItem getNextVideo() throws IOException, ExtractionException { assertPageFetched(); try { - StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId()); + StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); collector.commit(extractVideoPreviewInfo(doc.select("div[class=\"watch-sidebar-section\"]") .first().select("li").first())); @@ -463,10 +463,10 @@ public class YoutubeStreamExtractor extends StreamExtractor { } @Override - public StreamInfoItemCollector getRelatedVideos() throws IOException, ExtractionException { + public StreamInfoItemsCollector getRelatedVideos() throws IOException, ExtractionException { assertPageFetched(); try { - StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId()); + StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); Element ul = doc.select("ul[id=\"watch-related\"]").first(); if (ul != null) { for (Element li : ul.children()) { diff --git a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractor.java index 20177ef8..95455726 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractor.java @@ -28,7 +28,7 @@ import org.schabi.newpipe.extractor.*; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.kiosk.KioskExtractor; -import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; +import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import javax.annotation.Nonnull; import java.io.IOException; @@ -37,9 +37,9 @@ public class YoutubeTrendingExtractor extends KioskExtractor { private Document doc; - public YoutubeTrendingExtractor(StreamingService service, String url, String nextStreamsUrl, String kioskId) - throws IOException, ExtractionException { - super(service, url, nextStreamsUrl, kioskId); + public YoutubeTrendingExtractor(StreamingService service, String url, String nextPageUrl, String kioskId) + throws ExtractionException { + super(service, url, nextPageUrl, kioskId); } @Override @@ -61,7 +61,7 @@ public class YoutubeTrendingExtractor extends KioskExtractor { } @Override - public ListExtractor.NextItemsResult getNextStreams() { + public ListExtractor.InfoItemPage getInfoItemPage() { return null; } @@ -80,8 +80,8 @@ public class YoutubeTrendingExtractor extends KioskExtractor { @Nonnull @Override - public StreamInfoItemCollector getStreams() throws ParsingException { - StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId()); + public StreamInfoItemsCollector getInfoItems() throws ParsingException { + StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); Elements uls = doc.select("ul[class*=\"expanded-shelf-content-list\"]"); for(Element ul : uls) { for(final Element li : ul.children()) { diff --git a/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java b/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java index bdf8179d..05317fb6 100644 --- a/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java @@ -29,7 +29,6 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.utils.Parser; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.io.IOException; import java.util.List; @@ -139,7 +138,7 @@ public abstract class StreamExtractor extends Extractor { public abstract StreamType getStreamType() throws ParsingException; public abstract StreamInfoItem getNextVideo() throws IOException, ExtractionException; - public abstract StreamInfoItemCollector getRelatedVideos() throws IOException, ExtractionException; + public abstract StreamInfoItemsCollector getRelatedVideos() throws IOException, ExtractionException; /** * Analyses the webpage's document and extracts any error message there might be. diff --git a/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemCollector.java b/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemsCollector.java similarity index 92% rename from src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemCollector.java rename to src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemsCollector.java index cbdd187c..ba9975c6 100644 --- a/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemCollector.java +++ b/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemsCollector.java @@ -1,7 +1,7 @@ package org.schabi.newpipe.extractor.stream; import org.schabi.newpipe.extractor.InfoItem; -import org.schabi.newpipe.extractor.InfoItemCollector; +import org.schabi.newpipe.extractor.InfoItemsCollector; import org.schabi.newpipe.extractor.exceptions.FoundAdException; import org.schabi.newpipe.extractor.exceptions.ParsingException; @@ -12,7 +12,7 @@ import java.util.Vector; * Created by Christian Schabesberger on 28.02.16. * * Copyright (C) Christian Schabesberger 2016 - * StreamInfoItemCollector.java is part of NewPipe. + * StreamInfoItemsCollector.java is part of NewPipe. * * NewPipe is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,9 +28,9 @@ import java.util.Vector; * along with NewPipe. If not, see . */ -public class StreamInfoItemCollector extends InfoItemCollector { +public class StreamInfoItemsCollector extends InfoItemsCollector { - public StreamInfoItemCollector(int serviceId) { + public StreamInfoItemsCollector(int serviceId) { super(serviceId); } diff --git a/src/main/java/org/schabi/newpipe/extractor/utils/ExtractorHelper.java b/src/main/java/org/schabi/newpipe/extractor/utils/ExtractorHelper.java index 86046b68..e5b961d8 100644 --- a/src/main/java/org/schabi/newpipe/extractor/utils/ExtractorHelper.java +++ b/src/main/java/org/schabi/newpipe/extractor/utils/ExtractorHelper.java @@ -2,11 +2,11 @@ package org.schabi.newpipe.extractor.utils; import org.schabi.newpipe.extractor.Info; import org.schabi.newpipe.extractor.InfoItem; -import org.schabi.newpipe.extractor.InfoItemCollector; +import org.schabi.newpipe.extractor.InfoItemsCollector; import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.stream.StreamInfo; -import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; +import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import java.util.Collections; import java.util.List; @@ -14,10 +14,10 @@ import java.util.List; public class ExtractorHelper { private ExtractorHelper() {} - public static List getStreamsOrLogError(Info info, ListExtractor extractor) { - StreamInfoItemCollector collector; + public static List getInfoItemsOrLogError(Info info, ListExtractor extractor) { + InfoItemsCollector collector; try { - collector = extractor.getStreams(); + collector = extractor.getInfoItems(); } catch (Exception e) { info.addError(e); return Collections.emptyList(); @@ -28,7 +28,7 @@ public class ExtractorHelper { public static List getRelatedVideosOrLogError(StreamInfo info, StreamExtractor extractor) { - StreamInfoItemCollector collector; + StreamInfoItemsCollector collector; try { collector = extractor.getRelatedVideos(); } catch (Exception e) { @@ -39,7 +39,7 @@ public class ExtractorHelper { return getInfoItems(info, collector); } - private static List getInfoItems(Info info, InfoItemCollector collector) { + private static List getInfoItems(Info info, InfoItemsCollector collector) { List result; try { result = collector.getItemList(); diff --git a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java index 42e9420e..bcf7dd47 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java @@ -61,7 +61,7 @@ public class SoundcloudChannelExtractorTest { public void testHasMoreStreams() throws Exception { // Setup the streams extractor.getStreams(); - assertTrue("don't have more streams", extractor.hasMoreStreams()); + assertTrue("don't have more streams", extractor.hasNextPage()); } @Test @@ -73,10 +73,10 @@ public class SoundcloudChannelExtractorTest { public void testGetNextStreams() throws Exception { // Setup the streams extractor.getStreams(); - ListExtractor.NextItemsResult nextItemsResult = extractor.getNextStreams(); - assertTrue("extractor didn't have next streams", !nextItemsResult.nextItemsList.isEmpty()); + ListExtractor.InfoItemPage nextItemsResult = extractor.getInfoItemPage(); + assertTrue("extractor didn't have next streams", !nextItemsResult.infoItemList.isEmpty()); assertTrue("errors occurred during extraction of the next streams", nextItemsResult.errors.isEmpty()); - assertTrue("extractor didn't have more streams after getNextStreams", extractor.hasMoreStreams()); + assertTrue("extractor didn't have more streams after getInfoItemPage", extractor.hasNextPage()); } } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java index 565bdac9..c6446eec 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java @@ -4,9 +4,11 @@ import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; import org.schabi.newpipe.Downloader; +import org.schabi.newpipe.extractor.InfoItemsCollector; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.kiosk.KioskExtractor; -import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; + +import java.util.List; import static org.junit.Assert.*; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; @@ -39,16 +41,17 @@ public class SoundcloudChartsExtractorTest { } @Test - public void testId() throws Exception { + public void testId() { assertEquals(extractor.getId(), "Top 50"); } @Test public void testGetStreams() throws Exception { - StreamInfoItemCollector collector = extractor.getStreams(); + InfoItemsCollector collector = extractor.getInfoItems(); if(!collector.getErrors().isEmpty()) { System.err.println("----------"); - for(Throwable e: collector.getErrors()) { + List errors = collector.getErrors(); + for(Throwable e: errors) { e.printStackTrace(); System.err.println("----------"); } @@ -60,21 +63,21 @@ public class SoundcloudChartsExtractorTest { @Test public void testGetStreamsErrors() throws Exception { - assertTrue("errors during stream list extraction", extractor.getStreams().getErrors().isEmpty()); + assertTrue("errors during stream list extraction", extractor.getInfoItems().getErrors().isEmpty()); } @Test public void testHasMoreStreams() throws Exception { // Setup the streams - extractor.getStreams(); - assertTrue("has more streams", extractor.hasMoreStreams()); + extractor.getInfoItems(); + assertTrue("has more streams", extractor.hasNextPage()); } @Test public void testGetNextStreams() throws Exception { - extractor.getStreams(); - assertFalse("extractor has next streams", extractor.getNextStreams() == null - || extractor.getNextStreams().nextItemsList.isEmpty()); + extractor.getInfoItems(); + assertFalse("extractor has next streams", extractor.getInfoItemPage() == null + || extractor.getInfoItemPage().infoItemList.isEmpty()); } @Test diff --git a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java index 52aef60a..3a327778 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java @@ -81,7 +81,7 @@ public class SoundcloudPlaylistExtractorTest { public void testHasMoreStreams() throws Exception { // Setup the streams extractor.getStreams(); - assertTrue("extractor didn't have more streams", !extractor.hasMoreStreams()); + assertTrue("extractor didn't have more streams", !extractor.hasNextPage()); } @Test(expected = ExtractionException.class) @@ -90,7 +90,7 @@ public class SoundcloudPlaylistExtractorTest { extractor.getStreams(); // This playlist don't have more streams, it should throw an error - extractor.getNextStreams(); + extractor.getInfoItemPage(); fail("Expected exception wasn't thrown"); } 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 bd773fd7..37b3e088 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 @@ -7,7 +7,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.stream.StreamExtractor; -import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; +import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import org.schabi.newpipe.extractor.stream.StreamType; import java.io.IOException; @@ -100,7 +100,7 @@ public class SoundcloudStreamExtractorDefaultTest { @Test public void testGetRelatedVideos() throws ExtractionException, IOException { - StreamInfoItemCollector relatedVideos = extractor.getRelatedVideos(); + StreamInfoItemsCollector relatedVideos = extractor.getRelatedVideos(); assertFalse(relatedVideos.getItemList().isEmpty()); assertTrue(relatedVideos.getErrors().isEmpty()); } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java index 96d29c24..94800728 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java @@ -100,7 +100,7 @@ public class YoutubeChannelExtractorTest { public void testHasMoreStreams() throws Exception { // Setup the streams extractor.getStreams(); - assertTrue("don't have more streams", extractor.hasMoreStreams()); + assertTrue("don't have more streams", extractor.hasNextPage()); } @Test @@ -112,9 +112,9 @@ public class YoutubeChannelExtractorTest { public void testGetNextStreams() throws Exception { // Setup the streams extractor.getStreams(); - ListExtractor.NextItemsResult nextItemsResult = extractor.getNextStreams(); - assertTrue("extractor didn't have next streams", !nextItemsResult.nextItemsList.isEmpty()); + ListExtractor.InfoItemPage nextItemsResult = extractor.getInfoItemPage(); + assertTrue("extractor didn't have next streams", !nextItemsResult.infoItemList.isEmpty()); assertEmptyErrors("errors occurred during extraction of the next streams", nextItemsResult.errors); - assertTrue("extractor didn't have more streams after getNextStreams", extractor.hasMoreStreams()); + assertTrue("extractor didn't have more streams after getInfoItemPage", extractor.hasNextPage()); } } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java index dd4e58c7..d472c5d6 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java @@ -102,18 +102,18 @@ public class YoutubePlaylistExtractorTest { public void testHasMoreStreams() throws Exception { // Setup the streams extractor.getStreams(); - assertTrue("extractor didn't have more streams", extractor.hasMoreStreams()); + assertTrue("extractor didn't have more streams", extractor.hasNextPage()); } @Test @Ignore - public void testGetNextStreams() throws Exception { + public void testGetNextPage() throws Exception { // Setup the streams extractor.getStreams(); - ListExtractor.NextItemsResult nextItemsResult = extractor.getNextStreams(); - assertTrue("extractor didn't have next streams", !nextItemsResult.nextItemsList.isEmpty()); - assertEmptyErrors("errors occurred during extraction of the next streams", nextItemsResult.errors); - assertTrue("extractor didn't have more streams after getNextStreams", extractor.hasMoreStreams()); + ListExtractor.InfoItemPage infoItemPage = extractor.getInfoItemPage(); + assertTrue("extractor didn't have next streams", !infoItemPage.infoItemList.isEmpty()); + assertEmptyErrors("errors occurred during extraction of the next streams", infoItemPage.errors); + assertTrue("extractor didn't have more streams after getInfoItemPage", extractor.hasNextPage()); } } 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 790ea4ac..ae5920a9 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 @@ -138,7 +138,7 @@ public class YoutubeStreamExtractorDefaultTest { @Test public void testGetRelatedVideos() throws ExtractionException, IOException { - StreamInfoItemCollector relatedVideos = extractor.getRelatedVideos(); + StreamInfoItemsCollector relatedVideos = extractor.getRelatedVideos(); Utils.printErrors(relatedVideos); assertFalse(relatedVideos.getItemList().isEmpty()); assertTrue(relatedVideos.getErrors().isEmpty()); diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java index 23b90bfe..f372f283 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java @@ -23,8 +23,8 @@ package org.schabi.newpipe.extractor.services.youtube; import org.junit.BeforeClass; import org.junit.Test; import org.schabi.newpipe.Downloader; +import org.schabi.newpipe.extractor.InfoItemsCollector; import org.schabi.newpipe.extractor.NewPipe; -import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; import org.schabi.newpipe.extractor.utils.Utils; import static junit.framework.TestCase.assertFalse; @@ -66,27 +66,27 @@ public class YoutubeTrendingExtractorTest { @Test public void testGetStreamsQuantity() throws Exception { - StreamInfoItemCollector collector = extractor.getStreams(); + InfoItemsCollector collector = extractor.getInfoItems(); Utils.printErrors(collector); assertTrue("no streams are received", collector.getItemList().size() >= 20); } @Test public void testGetStreamsErrors() throws Exception { - assertEmptyErrors("errors during stream list extraction", extractor.getStreams().getErrors()); + assertEmptyErrors("errors during stream list extraction", extractor.getInfoItems().getErrors()); } @Test public void testHasMoreStreams() throws Exception { // Setup the streams - extractor.getStreams(); - assertFalse("has more streams", extractor.hasMoreStreams()); + extractor.getInfoItems(); + assertFalse("has more streams", extractor.hasNextPage()); } @Test public void testGetNextStreams() throws Exception { - assertTrue("extractor has next streams", extractor.getNextStreams() == null - || extractor.getNextStreams().getNextItemsList().isEmpty()); + assertTrue("extractor has next streams", extractor.getInfoItemPage() == null + || extractor.getInfoItemPage().getNextItemsList().isEmpty()); } @Test