Commit 5119dabb authored by Christian Schabesberger's avatar Christian Schabesberger
Browse files

add contentCountry to Kiosk

parent c76f39c8
......@@ -28,9 +28,24 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.io.IOException;
public abstract class KioskExtractor extends ListExtractor {
public KioskExtractor(StreamingService streamingService, String url, String nextStreamsUrl)
private String contentCountry = null;
public KioskExtractor(StreamingService streamingService,
String url,
String nextStreamsUrl)
throws IOException, ExtractionException {
super(streamingService, url, nextStreamsUrl);
this.contentCountry = contentCountry;
}
/**
* For certain Websites the content of a kiosk will be different depending
* on the country you want to poen the website in. Therefore you should
* set the contentCountry.
* @param contentCountry Set the country decoded as Country Code: http://www.1728.org/countries.htm
*/
public void setContentCountry(String contentCountry) {
this.contentCountry = contentCountry;
}
/**
......@@ -49,4 +64,8 @@ public abstract class KioskExtractor extends ListExtractor {
public String getName() throws ParsingException {
return getType();
}
public String getContentCountry() {
return contentCountry;
}
}
......@@ -33,22 +33,30 @@ import java.io.IOException;
public class KioskInfo extends ListInfo {
public String type;
public static KioskInfo getInfo(String url) throws IOException, ExtractionException {
return getInfo(NewPipe.getServiceByUrl(url), url);
public static KioskInfo getInfo(String url,
String contentCountry) throws IOException, ExtractionException {
return getInfo(NewPipe.getServiceByUrl(url), url, contentCountry);
}
public static KioskInfo getInfo(ServiceList serviceItem, String url) throws IOException, ExtractionException {
return getInfo(serviceItem.getService(), url);
public static KioskInfo getInfo(ServiceList serviceItem,
String url,
String contentContry) throws IOException, ExtractionException {
return getInfo(serviceItem.getService(), url, contentContry);
}
public static KioskInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
public static KioskInfo getInfo(StreamingService service,
String url,
String contentCountry) throws IOException, ExtractionException {
KioskList kl = service.getKioskList();
KioskExtractor extractor = kl.getExtryctorByUrl(url);
return getInfo(extractor);
return getInfo(extractor, contentCountry);
}
public static KioskInfo getInfo(KioskExtractor extractor) throws ParsingException {
public static KioskInfo getInfo(KioskExtractor extractor,
String contentCountry) throws IOException, ExtractionException {
KioskInfo info = new KioskInfo();
extractor.setContentCountry(contentCountry);
extractor.fetchPage();
info.type = extractor.getType();
info.name = extractor.getName();
info.id = extractor.getId();
......
......@@ -44,9 +44,14 @@ public class YoutubeTrendingExtractor extends KioskExtractor {
public void fetchPage() throws IOException, ExtractionException {
Downloader downloader = NewPipe.getDownloader();
String channelUrl = getCleanUrl();
String pageContent = downloader.download(channelUrl);
doc = Jsoup.parse(pageContent, channelUrl);
final String contentCountry = getContentCountry();
String url = getCleanUrl();
if(contentCountry != null && !contentCountry.isEmpty()) {
url += "?gl=" + contentCountry;
}
String pageContent = downloader.download(url);
doc = Jsoup.parse(pageContent, url);
}
@Override
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment