mirror of
https://github.com/TeamNewPipe/NewPipeExtractor
synced 2025-01-05 16:36:06 +01:00
add contentCountry to Kiosk
This commit is contained in:
parent
c76f39c81b
commit
5119dabb63
@ -28,9 +28,24 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public abstract class KioskExtractor extends ListExtractor {
|
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 {
|
throws IOException, ExtractionException {
|
||||||
super(streamingService, url, nextStreamsUrl);
|
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 {
|
public String getName() throws ParsingException {
|
||||||
return getType();
|
return getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getContentCountry() {
|
||||||
|
return contentCountry;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,22 +33,30 @@ import java.io.IOException;
|
|||||||
public class KioskInfo extends ListInfo {
|
public class KioskInfo extends ListInfo {
|
||||||
public String type;
|
public String type;
|
||||||
|
|
||||||
public static KioskInfo getInfo(String url) throws IOException, ExtractionException {
|
public static KioskInfo getInfo(String url,
|
||||||
return getInfo(NewPipe.getServiceByUrl(url), url);
|
String contentCountry) throws IOException, ExtractionException {
|
||||||
|
return getInfo(NewPipe.getServiceByUrl(url), url, contentCountry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KioskInfo getInfo(ServiceList serviceItem, String url) throws IOException, ExtractionException {
|
public static KioskInfo getInfo(ServiceList serviceItem,
|
||||||
return getInfo(serviceItem.getService(), url);
|
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();
|
KioskList kl = service.getKioskList();
|
||||||
KioskExtractor extractor = kl.getExtryctorByUrl(url);
|
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();
|
KioskInfo info = new KioskInfo();
|
||||||
|
extractor.setContentCountry(contentCountry);
|
||||||
|
extractor.fetchPage();
|
||||||
info.type = extractor.getType();
|
info.type = extractor.getType();
|
||||||
info.name = extractor.getName();
|
info.name = extractor.getName();
|
||||||
info.id = extractor.getId();
|
info.id = extractor.getId();
|
||||||
|
@ -44,9 +44,14 @@ public class YoutubeTrendingExtractor extends KioskExtractor {
|
|||||||
public void fetchPage() throws IOException, ExtractionException {
|
public void fetchPage() throws IOException, ExtractionException {
|
||||||
Downloader downloader = NewPipe.getDownloader();
|
Downloader downloader = NewPipe.getDownloader();
|
||||||
|
|
||||||
String channelUrl = getCleanUrl();
|
final String contentCountry = getContentCountry();
|
||||||
String pageContent = downloader.download(channelUrl);
|
String url = getCleanUrl();
|
||||||
doc = Jsoup.parse(pageContent, channelUrl);
|
if(contentCountry != null && !contentCountry.isEmpty()) {
|
||||||
|
url += "?gl=" + contentCountry;
|
||||||
|
}
|
||||||
|
|
||||||
|
String pageContent = downloader.download(url);
|
||||||
|
doc = Jsoup.parse(pageContent, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user