mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-21 18:42:35 +01:00
remove StreamInfoItemSearchCollector
This commit is contained in:
parent
5c8bcf15ba
commit
7186f58374
@ -4,11 +4,9 @@ import android.test.AndroidTestCase;
|
||||
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.search.SuggestionExtractor;
|
||||
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
||||
import org.schabi.newpipe.extractor.services.youtube.YoutubeSuggestionExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ public class InfoItemCollector {
|
||||
public List<Throwable> getErrors() {
|
||||
return errors;
|
||||
}
|
||||
public void addFromCollector(InfoItemCollector otherC) throws ExtractionException {
|
||||
protected void addFromCollector(InfoItemCollector otherC) throws ExtractionException {
|
||||
if(serviceId != otherC.serviceId) {
|
||||
throw new ExtractionException("Service Id does not equal: "
|
||||
+ NewPipe.getNameOfService(serviceId)
|
||||
|
@ -3,7 +3,6 @@ package org.schabi.newpipe.extractor;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||
import org.schabi.newpipe.extractor.search.SuggestionExtractor;
|
||||
import org.schabi.newpipe.extractor.stream_info.StreamExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.schabi.newpipe.extractor.search;
|
||||
package org.schabi.newpipe.extractor;
|
||||
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
|
@ -2,6 +2,10 @@ package org.schabi.newpipe.extractor.search;
|
||||
|
||||
import org.schabi.newpipe.extractor.InfoItemCollector;
|
||||
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_info.StreamInfoItemCollector;
|
||||
import org.schabi.newpipe.extractor.stream_info.StreamInfoItemExtractor;
|
||||
|
||||
/**
|
||||
* Created by Christian Schabesberger on 12.02.17.
|
||||
@ -25,20 +29,29 @@ import org.schabi.newpipe.extractor.UrlIdHandler;
|
||||
|
||||
public class InfoItemSearchCollector extends InfoItemCollector {
|
||||
private String suggestion = "";
|
||||
private StreamInfoItemCollector streamCollector;
|
||||
|
||||
InfoItemSearchCollector(UrlIdHandler handler, int serviceId) {
|
||||
super(handler, serviceId);
|
||||
streamCollector = new StreamInfoItemCollector(handler, serviceId);
|
||||
}
|
||||
|
||||
public void setSuggestion(String suggestion) {
|
||||
this.suggestion = suggestion;
|
||||
}
|
||||
|
||||
public SearchResult getSearchResult() {
|
||||
public SearchResult getSearchResult() throws ExtractionException {
|
||||
SearchResult result = new SearchResult();
|
||||
|
||||
addFromCollector(streamCollector);
|
||||
|
||||
result.suggestion = suggestion;
|
||||
result.errors = getErrors();
|
||||
result.resultList = getItemList();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void commit(StreamInfoItemExtractor extractor) throws ParsingException {
|
||||
streamCollector.commit(extractor);
|
||||
}
|
||||
}
|
||||
|
@ -32,19 +32,12 @@ public abstract class SearchEngine {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
private StreamInfoItemCollector streamCollector;
|
||||
private InfoItemSearchCollector collector;
|
||||
|
||||
public SearchEngine(UrlIdHandler urlIdHandler, int serviceId) {
|
||||
streamCollector = new StreamInfoItemCollector(urlIdHandler, serviceId);
|
||||
collector = new InfoItemSearchCollector(urlIdHandler, serviceId);
|
||||
}
|
||||
|
||||
protected StreamInfoItemCollector getStreamPreviewInfoCollector() {
|
||||
return streamCollector;
|
||||
}
|
||||
|
||||
protected InfoItemSearchCollector getInfoItemSearchCollector() {
|
||||
return collector;
|
||||
}
|
||||
|
@ -48,7 +48,6 @@ public class YoutubeSearchEngine extends SearchEngine {
|
||||
@Override
|
||||
public InfoItemSearchCollector search(String query, int page, String languageCode)
|
||||
throws IOException, ExtractionException {
|
||||
StreamInfoItemCollector streamCollector = getStreamPreviewInfoCollector();
|
||||
InfoItemSearchCollector collector = getInfoItemSearchCollector();
|
||||
|
||||
|
||||
@ -100,17 +99,13 @@ public class YoutubeSearchEngine extends SearchEngine {
|
||||
|
||||
// video item type
|
||||
} else if ((el = item.select("div[class*=\"yt-lockup-video\"").first()) != null) {
|
||||
streamCollector.commit(extractPreviewInfo(el));
|
||||
collector.commit(new YoutubeStreamInfoItemExtractor(el));
|
||||
} else {
|
||||
//noinspection ConstantConditions
|
||||
throw new ExtractionException("unexpected element found:\"" + el + "\"");
|
||||
}
|
||||
}
|
||||
collector.addFromCollector(streamCollector);
|
||||
|
||||
return collector;
|
||||
}
|
||||
|
||||
private StreamInfoItemExtractor extractPreviewInfo(final Element item) {
|
||||
return new YoutubeStreamInfoItemExtractor(item);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import org.schabi.newpipe.extractor.UrlIdHandler;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||
import org.schabi.newpipe.extractor.search.SuggestionExtractor;
|
||||
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
||||
import org.schabi.newpipe.extractor.stream_info.StreamExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -4,7 +4,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.SuggestionExtractor;
|
||||
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
@ -15,7 +15,6 @@ import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
@ -8,7 +8,7 @@ import android.widget.Toast;
|
||||
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.search.SuggestionExtractor;
|
||||
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
||||
import org.schabi.newpipe.report.ErrorActivity;
|
||||
import org.schabi.newpipe.R;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user