Add content language option

This commit is contained in:
Vasily 2018-09-02 09:51:15 +03:00
parent db1832a551
commit 3c4d585759
4 changed files with 44 additions and 6 deletions

View File

@ -6,8 +6,8 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
import java.io.IOException;
@ -38,12 +38,23 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
super(serviceId, urlIdHandler, name);
}
@Deprecated
public static ChannelInfo getInfo(String url) throws IOException, ExtractionException {
return getInfo(NewPipe.getServiceByUrl(url), url);
return getInfo(NewPipe.getServiceByUrl(url), url, null);
}
public static ChannelInfo getInfo(String url, String language) throws IOException, ExtractionException {
return getInfo(NewPipe.getServiceByUrl(url), url, language);
}
@Deprecated
public static ChannelInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
return getInfo(service, url, null);
}
public static ChannelInfo getInfo(StreamingService service, String url, String language) throws IOException, ExtractionException {
ChannelExtractor extractor = service.getChannelExtractor(url);
extractor.setLanguage(language);
extractor.fetchPage();
return getInfo(extractor);
}

View File

@ -35,27 +35,53 @@ public class KioskInfo extends ListInfo<StreamInfoItem> {
super(serviceId, urlIdHandler, name);
}
@Deprecated
public static ListExtractor.InfoItemsPage<StreamInfoItem> getMoreItems(StreamingService service,
String url,
String pageUrl,
String contentCountry) throws IOException, ExtractionException {
return getMoreItems(service, url, pageUrl, contentCountry, null);
}
public static ListExtractor.InfoItemsPage<StreamInfoItem> getMoreItems(StreamingService service,
String url,
String pageUrl,
String contentCountry,
String language) throws IOException, ExtractionException {
KioskList kl = service.getKioskList();
KioskExtractor extractor = kl.getExtractorByUrl(url, pageUrl);
extractor.setContentCountry(contentCountry);
extractor.setLanguage(language);
return extractor.getPage(pageUrl);
}
@Deprecated
public static KioskInfo getInfo(String url,
String contentCountry) throws IOException, ExtractionException {
return getInfo(NewPipe.getServiceByUrl(url), url, contentCountry);
return getInfo(url, contentCountry, null);
}
public static KioskInfo getInfo(String url,
String contentCountry,
String language) throws IOException, ExtractionException {
return getInfo(NewPipe.getServiceByUrl(url), url, contentCountry, language);
}
@Deprecated
public static KioskInfo getInfo(StreamingService service,
String url,
String contentCountry) throws IOException, ExtractionException {
return getInfo(service, url, contentCountry, null);
}
public static KioskInfo getInfo(StreamingService service,
String url,
String contentCountry) throws IOException, ExtractionException {
String contentCountry,
String language) throws IOException, ExtractionException {
KioskList kl = service.getKioskList();
KioskExtractor extractor = kl.getExtractorByUrl(url, null);
extractor.setContentCountry(contentCountry);
extractor.setLanguage(language);
extractor.fetchPage();
return getInfo(extractor);
}

View File

@ -49,8 +49,9 @@ public class YoutubeTrendingExtractorTest {
extractor = (YoutubeTrendingExtractor) YouTube
.getKioskList()
.getExtractorById("Trending", null);
extractor.fetchPage();
extractor.setLanguage("ru");
extractor.setContentCountry("de");
extractor.fetchPage();
}
@Test

View File

@ -45,7 +45,7 @@ public class YoutubeTrendingKioskInfoTest {
StreamingService service = YouTube;
LinkHandlerFactory LinkHandlerFactory = service.getKioskList().getListLinkHandlerFactoryByType("Trending");
kioskInfo = KioskInfo.getInfo(YouTube, LinkHandlerFactory.fromId("Trending").getUrl(), null);
kioskInfo = KioskInfo.getInfo(YouTube, LinkHandlerFactory.fromId("Trending").getUrl(), null, null);
}
@Test