Refactor Extractor

- Renaming and removal of duplicate code
- New base class for list extractors
This commit is contained in:
Mauricio Colli
2017-07-09 19:43:04 -03:00
parent 729930802e
commit bda65e83d6
7 changed files with 47 additions and 26 deletions

View File

@@ -49,7 +49,6 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
* It's lazily initialized (when getNextStreams is called)
*/
private Document nextStreamsAjax;
private String nextStreamsUrl = "";
/*//////////////////////////////////////////////////////////////////////////
// Variables for cache purposes (not "select" the current document all over again)
@@ -61,7 +60,6 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
private String feedUrl;
private long subscriberCount = -1;
public YoutubeChannelExtractor(UrlIdHandler urlIdHandler, String url, int serviceId) throws ExtractionException, IOException {
super(urlIdHandler, urlIdHandler.cleanUrl(url), serviceId);
fetchDocument();
@@ -160,14 +158,11 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
}
}
@Override
public boolean hasMoreStreams() {
return nextStreamsUrl != null && !nextStreamsUrl.isEmpty();
}
@Override
public StreamInfoItemCollector getNextStreams() throws ExtractionException, IOException {
if (!hasMoreStreams()) throw new ExtractionException("Channel doesn't have more streams");
if (!hasMoreStreams()) {
throw new ExtractionException("Channel doesn't have more streams");
}
StreamInfoItemCollector collector = new StreamInfoItemCollector(getUrlIdHandler(), getServiceId());
setupNextStreamsAjax(NewPipe.getDownloader());