Refactor Extractor
- Renaming and removal of duplicate code - New base class for list extractors
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -27,7 +27,6 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
|
||||
* It's lazily initialized (when getNextStreams is called)
|
||||
*/
|
||||
private Document nextStreamsAjax = null;
|
||||
private String nextStreamsUrl = "";
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Variables for cache purposes (not "select" the current document all over again)
|
||||
@@ -181,14 +180,11 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
|
||||
return collector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreStreams() {
|
||||
return nextStreamsUrl != null && !nextStreamsUrl.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamInfoItemCollector getNextStreams() throws ExtractionException, IOException {
|
||||
if (!hasMoreStreams()) throw new ExtractionException("Playlist doesn't have more streams");
|
||||
if (!hasMoreStreams()){
|
||||
throw new ExtractionException("Playlist doesn't have more streams");
|
||||
}
|
||||
|
||||
StreamInfoItemCollector collector = new StreamInfoItemCollector(getUrlIdHandler(), getServiceId());
|
||||
setupNextStreamsAjax(NewPipe.getDownloader());
|
||||
|
||||
@@ -46,7 +46,7 @@ public class YoutubeService extends StreamingService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamExtractor getExtractorInstance(String url)
|
||||
public StreamExtractor getStreamExtractorInstance(String url)
|
||||
throws ExtractionException, IOException {
|
||||
UrlIdHandler urlIdHandler = YoutubeStreamUrlIdHandler.getInstance();
|
||||
if (urlIdHandler.acceptUrl(url)) {
|
||||
|
||||
Reference in New Issue
Block a user