Skip to content

Commit 5119dab

Browse files
committed
add contentCountry to Kiosk
1 parent c76f39c commit 5119dab

3 files changed

Lines changed: 43 additions & 11 deletions

File tree

src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,24 @@
2828
import java.io.IOException;
2929

3030
public abstract class KioskExtractor extends ListExtractor {
31-
public KioskExtractor(StreamingService streamingService, String url, String nextStreamsUrl)
31+
private String contentCountry = null;
32+
33+
public KioskExtractor(StreamingService streamingService,
34+
String url,
35+
String nextStreamsUrl)
3236
throws IOException, ExtractionException {
3337
super(streamingService, url, nextStreamsUrl);
38+
this.contentCountry = contentCountry;
39+
}
40+
41+
/**
42+
* For certain Websites the content of a kiosk will be different depending
43+
* on the country you want to poen the website in. Therefore you should
44+
* set the contentCountry.
45+
* @param contentCountry Set the country decoded as Country Code: http://www.1728.org/countries.htm
46+
*/
47+
public void setContentCountry(String contentCountry) {
48+
this.contentCountry = contentCountry;
3449
}
3550

3651
/**
@@ -49,4 +64,8 @@ public String getId() throws ParsingException {
4964
public String getName() throws ParsingException {
5065
return getType();
5166
}
67+
68+
public String getContentCountry() {
69+
return contentCountry;
70+
}
5271
}

src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,30 @@
3333
public class KioskInfo extends ListInfo {
3434
public String type;
3535

36-
public static KioskInfo getInfo(String url) throws IOException, ExtractionException {
37-
return getInfo(NewPipe.getServiceByUrl(url), url);
36+
public static KioskInfo getInfo(String url,
37+
String contentCountry) throws IOException, ExtractionException {
38+
return getInfo(NewPipe.getServiceByUrl(url), url, contentCountry);
3839
}
3940

40-
public static KioskInfo getInfo(ServiceList serviceItem, String url) throws IOException, ExtractionException {
41-
return getInfo(serviceItem.getService(), url);
41+
public static KioskInfo getInfo(ServiceList serviceItem,
42+
String url,
43+
String contentContry) throws IOException, ExtractionException {
44+
return getInfo(serviceItem.getService(), url, contentContry);
4245
}
4346

44-
public static KioskInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
47+
public static KioskInfo getInfo(StreamingService service,
48+
String url,
49+
String contentCountry) throws IOException, ExtractionException {
4550
KioskList kl = service.getKioskList();
4651
KioskExtractor extractor = kl.getExtryctorByUrl(url);
47-
return getInfo(extractor);
52+
return getInfo(extractor, contentCountry);
4853
}
4954

50-
public static KioskInfo getInfo(KioskExtractor extractor) throws ParsingException {
55+
public static KioskInfo getInfo(KioskExtractor extractor,
56+
String contentCountry) throws IOException, ExtractionException {
5157
KioskInfo info = new KioskInfo();
58+
extractor.setContentCountry(contentCountry);
59+
extractor.fetchPage();
5260
info.type = extractor.getType();
5361
info.name = extractor.getName();
5462
info.id = extractor.getId();

src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractor.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,14 @@ public YoutubeTrendingExtractor(StreamingService service, String url, String nex
4444
public void fetchPage() throws IOException, ExtractionException {
4545
Downloader downloader = NewPipe.getDownloader();
4646

47-
String channelUrl = getCleanUrl();
48-
String pageContent = downloader.download(channelUrl);
49-
doc = Jsoup.parse(pageContent, channelUrl);
47+
final String contentCountry = getContentCountry();
48+
String url = getCleanUrl();
49+
if(contentCountry != null && !contentCountry.isEmpty()) {
50+
url += "?gl=" + contentCountry;
51+
}
52+
53+
String pageContent = downloader.download(url);
54+
doc = Jsoup.parse(pageContent, url);
5055
}
5156

5257
@Override

0 commit comments

Comments
 (0)