commit
ad4b15ac66
62 changed files with 475 additions and 308 deletions
|
@ -1,6 +1,7 @@
|
|||
package org.schabi.newpipe.extractor;
|
||||
|
||||
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
@ -32,11 +33,11 @@ public interface Downloader {
|
|||
* but set the HTTP header field "Accept-Language" to the supplied string.
|
||||
*
|
||||
* @param siteUrl the URL of the text file to return the contents of
|
||||
* @param language the language (usually a 2-character code) to set as the preferred language
|
||||
* @param localization the language and country (usually a 2-character code for each)
|
||||
* @return the contents of the specified text file
|
||||
* @throws IOException
|
||||
*/
|
||||
String download(String siteUrl, String language) throws IOException, ReCaptchaException;
|
||||
String download(String siteUrl, Localization localization) throws IOException, ReCaptchaException;
|
||||
|
||||
/**
|
||||
* Download the text file at the supplied URL as in download(String),
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.schabi.newpipe.extractor;
|
|||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -15,18 +16,20 @@ public abstract class Extractor {
|
|||
*/
|
||||
private final StreamingService service;
|
||||
|
||||
private final LinkHandler uIHandler;
|
||||
private final LinkHandler linkHandler;
|
||||
private final Localization localization;
|
||||
|
||||
@Nullable
|
||||
private boolean pageFetched = false;
|
||||
private final Downloader downloader;
|
||||
|
||||
public Extractor(final StreamingService service, final LinkHandler uIHandler) {
|
||||
public Extractor(final StreamingService service, final LinkHandler linkHandler, final Localization localization) {
|
||||
if(service == null) throw new NullPointerException("service is null");
|
||||
if(uIHandler == null) throw new NullPointerException("LinkHandler is null");
|
||||
if(linkHandler == null) throw new NullPointerException("LinkHandler is null");
|
||||
this.service = service;
|
||||
this.uIHandler = uIHandler;
|
||||
this.linkHandler = linkHandler;
|
||||
this.downloader = NewPipe.getDownloader();
|
||||
this.localization = localization;
|
||||
if(downloader == null) throw new NullPointerException("downloader is null");
|
||||
}
|
||||
|
||||
|
@ -34,8 +37,8 @@ public abstract class Extractor {
|
|||
* @return The {@link LinkHandler} of the current extractor object (e.g. a ChannelExtractor should return a channel url handler).
|
||||
*/
|
||||
@Nonnull
|
||||
public LinkHandler getUIHandler() {
|
||||
return uIHandler;
|
||||
public LinkHandler getLinkHandler() {
|
||||
return linkHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,7 +70,7 @@ public abstract class Extractor {
|
|||
|
||||
@Nonnull
|
||||
public String getId() throws ParsingException {
|
||||
return uIHandler.getId();
|
||||
return linkHandler.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,12 +83,12 @@ public abstract class Extractor {
|
|||
|
||||
@Nonnull
|
||||
public String getOriginalUrl() throws ParsingException {
|
||||
return uIHandler.getOriginalUrl();
|
||||
return linkHandler.getOriginalUrl();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public String getUrl() throws ParsingException {
|
||||
return uIHandler.getUrl();
|
||||
return linkHandler.getUrl();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -100,4 +103,9 @@ public abstract class Extractor {
|
|||
public Downloader getDownloader() {
|
||||
return downloader;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public Localization getLocalization() {
|
||||
return localization;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.schabi.newpipe.extractor;
|
|||
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
|
@ -13,8 +14,8 @@ import java.util.List;
|
|||
*/
|
||||
public abstract class ListExtractor<R extends InfoItem> extends Extractor {
|
||||
|
||||
public ListExtractor(StreamingService service, ListLinkHandler uiHandler) {
|
||||
super(service, uiHandler);
|
||||
public ListExtractor(StreamingService service, ListLinkHandler linkHandler, Localization localization) {
|
||||
super(service, linkHandler, localization);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,8 +52,8 @@ public abstract class ListExtractor<R extends InfoItem> extends Extractor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ListLinkHandler getUIHandler() {
|
||||
return (ListLinkHandler) super.getUIHandler();
|
||||
public ListLinkHandler getLinkHandler() {
|
||||
return (ListLinkHandler) super.getLinkHandler();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.schabi.newpipe.extractor;
|
|||
*/
|
||||
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -29,12 +30,14 @@ import java.util.List;
|
|||
*/
|
||||
public class NewPipe {
|
||||
private static Downloader downloader = null;
|
||||
private static Localization localization = null;
|
||||
|
||||
private NewPipe() {
|
||||
}
|
||||
|
||||
public static void init(Downloader d) {
|
||||
public static void init(Downloader d, Localization l) {
|
||||
downloader = d;
|
||||
localization = l;
|
||||
}
|
||||
|
||||
public static Downloader getDownloader() {
|
||||
|
@ -95,4 +98,12 @@ public class NewPipe {
|
|||
return "<unknown>";
|
||||
}
|
||||
}
|
||||
|
||||
public static void setLocalization(Localization localization) {
|
||||
NewPipe.localization = localization;
|
||||
}
|
||||
|
||||
public static Localization getLocalization() {
|
||||
return localization;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.search.SearchExtractor;
|
|||
import org.schabi.newpipe.extractor.linkhandler.*;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -76,45 +77,99 @@ public abstract class StreamingService {
|
|||
////////////////////////////////////////////
|
||||
// Extractor
|
||||
////////////////////////////////////////////
|
||||
public abstract SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, String contentCountry);
|
||||
public abstract SuggestionExtractor getSuggestionExtractor();
|
||||
public abstract SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, Localization localization);
|
||||
public abstract SuggestionExtractor getSuggestionExtractor(Localization localization);
|
||||
public abstract SubscriptionExtractor getSubscriptionExtractor();
|
||||
public abstract KioskList getKioskList() throws ExtractionException;
|
||||
public abstract KioskList getKioskList(Localization localization) throws ExtractionException;
|
||||
|
||||
public abstract ChannelExtractor getChannelExtractor(ListLinkHandler urlIdHandler) throws ExtractionException;
|
||||
public abstract PlaylistExtractor getPlaylistExtractor(ListLinkHandler urlIdHandler) throws ExtractionException;
|
||||
public abstract StreamExtractor getStreamExtractor(LinkHandler UIHFactory) throws ExtractionException;
|
||||
public abstract ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler,
|
||||
Localization localization) throws ExtractionException;
|
||||
public abstract PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler,
|
||||
Localization localization) throws ExtractionException;
|
||||
public abstract StreamExtractor getStreamExtractor(LinkHandler linkHandler,
|
||||
Localization localization) throws ExtractionException;
|
||||
////////////////////////////////////////////
|
||||
// Extractor with default localization
|
||||
////////////////////////////////////////////
|
||||
|
||||
public SearchExtractor getSearchExtractor(String query, List<String> contentFilter, String sortFilter, String contentCountry) throws ExtractionException {
|
||||
return getSearchExtractor(getSearchQHFactory().fromQuery(query, contentFilter, sortFilter), contentCountry);
|
||||
public SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler) {
|
||||
return getSearchExtractor(queryHandler, NewPipe.getLocalization());
|
||||
}
|
||||
|
||||
public ChannelExtractor getChannelExtractor(String id, List<String> contentFilter, String sortFilter) throws ExtractionException {
|
||||
return getChannelExtractor(getChannelLHFactory().fromQuery(id, contentFilter, sortFilter));
|
||||
public SuggestionExtractor getSuggestionExtractor() {
|
||||
return getSuggestionExtractor(NewPipe.getLocalization());
|
||||
}
|
||||
|
||||
public PlaylistExtractor getPlaylistExtractor(String id, List<String> contentFilter, String sortFilter) throws ExtractionException {
|
||||
return getPlaylistExtractor(getPlaylistLHFactory().fromQuery(id, contentFilter, sortFilter));
|
||||
public KioskList getKioskList() throws ExtractionException {
|
||||
return getKioskList(NewPipe.getLocalization());
|
||||
}
|
||||
|
||||
public SearchExtractor getSearchExtractor(String query, String contentCountry) throws ExtractionException {
|
||||
return getSearchExtractor(getSearchQHFactory().fromQuery(query), contentCountry);
|
||||
public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler) throws ExtractionException {
|
||||
return getChannelExtractor(linkHandler, NewPipe.getLocalization());
|
||||
}
|
||||
|
||||
public PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler) throws ExtractionException {
|
||||
return getPlaylistExtractor(linkHandler, NewPipe.getLocalization());
|
||||
}
|
||||
|
||||
public StreamExtractor getStreamExtractor(LinkHandler linkHandler) throws ExtractionException {
|
||||
return getStreamExtractor(linkHandler, NewPipe.getLocalization());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
// Extractor without link handler
|
||||
////////////////////////////////////////////
|
||||
|
||||
public SearchExtractor getSearchExtractor(String query,
|
||||
List<String> contentFilter,
|
||||
String sortFilter,
|
||||
Localization localization) throws ExtractionException {
|
||||
return getSearchExtractor(getSearchQHFactory()
|
||||
.fromQuery(query,
|
||||
contentFilter,
|
||||
sortFilter),
|
||||
localization);
|
||||
}
|
||||
|
||||
public ChannelExtractor getChannelExtractor(String id,
|
||||
List<String> contentFilter,
|
||||
String sortFilter,
|
||||
Localization localization) throws ExtractionException {
|
||||
return getChannelExtractor(getChannelLHFactory().fromQuery(id, contentFilter, sortFilter), localization);
|
||||
}
|
||||
|
||||
public PlaylistExtractor getPlaylistExtractor(String id,
|
||||
List<String> contentFilter,
|
||||
String sortFilter,
|
||||
Localization localization) throws ExtractionException {
|
||||
return getPlaylistExtractor(getPlaylistLHFactory()
|
||||
.fromQuery(id,
|
||||
contentFilter,
|
||||
sortFilter),
|
||||
localization);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
// Short extractor without localization
|
||||
////////////////////////////////////////////
|
||||
|
||||
public SearchExtractor getSearchExtractor(String query) throws ExtractionException {
|
||||
return getSearchExtractor(getSearchQHFactory().fromQuery(query), NewPipe.getLocalization());
|
||||
}
|
||||
|
||||
public ChannelExtractor getChannelExtractor(String url) throws ExtractionException {
|
||||
return getChannelExtractor(getChannelLHFactory().fromUrl(url));
|
||||
return getChannelExtractor(getChannelLHFactory().fromUrl(url), NewPipe.getLocalization());
|
||||
}
|
||||
|
||||
public PlaylistExtractor getPlaylistExtractor(String url) throws ExtractionException {
|
||||
return getPlaylistExtractor(getPlaylistLHFactory().fromUrl(url));
|
||||
return getPlaylistExtractor(getPlaylistLHFactory().fromUrl(url), NewPipe.getLocalization());
|
||||
}
|
||||
|
||||
public StreamExtractor getStreamExtractor(String url) throws ExtractionException {
|
||||
return getStreamExtractor(getStreamLHFactory().fromUrl(url));
|
||||
return getStreamExtractor(getStreamLHFactory().fromUrl(url), NewPipe.getLocalization());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* figure out where the link is pointing to (a channel, video, playlist, etc.)
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.schabi.newpipe.extractor;
|
||||
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
@ -28,14 +29,20 @@ import java.util.List;
|
|||
public abstract class SuggestionExtractor {
|
||||
|
||||
private final int serviceId;
|
||||
private final Localization localization;
|
||||
|
||||
public SuggestionExtractor(int serviceId) {
|
||||
public SuggestionExtractor(int serviceId, Localization localization) {
|
||||
this.serviceId = serviceId;
|
||||
this.localization = localization;
|
||||
}
|
||||
|
||||
public abstract List<String> suggestionList(String query, String contentCountry) throws IOException, ExtractionException;
|
||||
public abstract List<String> suggestionList(String query) throws IOException, ExtractionException;
|
||||
|
||||
public int getServiceId() {
|
||||
return serviceId;
|
||||
}
|
||||
|
||||
protected Localization getLocalization() {
|
||||
return localization;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.schabi.newpipe.extractor.StreamingService;
|
|||
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.utils.Localization;
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 25.07.16.
|
||||
|
@ -28,8 +29,8 @@ import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
|||
|
||||
public abstract class ChannelExtractor extends ListExtractor<StreamInfoItem> {
|
||||
|
||||
public ChannelExtractor(StreamingService service, ListLinkHandler urlIdHandler) {
|
||||
super(service, urlIdHandler);
|
||||
public ChannelExtractor(StreamingService service, ListLinkHandler linkHandler, Localization localization) {
|
||||
super(service, linkHandler, localization);
|
||||
}
|
||||
|
||||
public abstract String getAvatarUrl() throws ParsingException;
|
||||
|
|
|
@ -9,6 +9,7 @@ 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.utils.ExtractorHelper;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -34,8 +35,8 @@ import java.io.IOException;
|
|||
|
||||
public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
||||
|
||||
public ChannelInfo(int serviceId, ListLinkHandler urlIdHandler, String name) throws ParsingException {
|
||||
super(serviceId, urlIdHandler, name);
|
||||
public ChannelInfo(int serviceId, ListLinkHandler linkHandler, String name) throws ParsingException {
|
||||
super(serviceId, linkHandler, name);
|
||||
}
|
||||
|
||||
public static ChannelInfo getInfo(String url) throws IOException, ExtractionException {
|
||||
|
@ -48,14 +49,17 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
|||
return getInfo(extractor);
|
||||
}
|
||||
|
||||
public static InfoItemsPage<StreamInfoItem> getMoreItems(StreamingService service, String url, String pageUrl) throws IOException, ExtractionException {
|
||||
public static InfoItemsPage<StreamInfoItem> getMoreItems(StreamingService service,
|
||||
String url,
|
||||
String pageUrl,
|
||||
Localization localization) throws IOException, ExtractionException {
|
||||
return service.getChannelExtractor(url).getPage(pageUrl);
|
||||
}
|
||||
|
||||
public static ChannelInfo getInfo(ChannelExtractor extractor) throws IOException, ExtractionException {
|
||||
|
||||
ChannelInfo info = new ChannelInfo(extractor.getServiceId(),
|
||||
extractor.getUIHandler(),
|
||||
extractor.getLinkHandler(),
|
||||
extractor.getName());
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.schabi.newpipe.extractor.StreamingService;
|
|||
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.utils.Localization;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
@ -33,9 +34,10 @@ public abstract class KioskExtractor extends ListExtractor<StreamInfoItem> {
|
|||
private final String id;
|
||||
|
||||
public KioskExtractor(StreamingService streamingService,
|
||||
ListLinkHandler urlIdHandler,
|
||||
String kioskId) {
|
||||
super(streamingService, urlIdHandler);
|
||||
ListLinkHandler linkHandler,
|
||||
String kioskId,
|
||||
Localization localization) {
|
||||
super(streamingService, linkHandler, localization);
|
||||
this.id = kioskId;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ import java.io.IOException;
|
|||
|
||||
public class KioskInfo extends ListInfo<StreamInfoItem> {
|
||||
|
||||
private KioskInfo(int serviceId, ListLinkHandler urlIdHandler, String name) throws ParsingException {
|
||||
super(serviceId, urlIdHandler, name);
|
||||
private KioskInfo(int serviceId, ListLinkHandler linkHandler, String name) throws ParsingException {
|
||||
super(serviceId, linkHandler, name);
|
||||
}
|
||||
|
||||
public static ListExtractor.InfoItemsPage<StreamInfoItem> getMoreItems(StreamingService service,
|
||||
|
@ -68,7 +68,7 @@ public class KioskInfo extends ListInfo<StreamInfoItem> {
|
|||
public static KioskInfo getInfo(KioskExtractor extractor) throws ExtractionException {
|
||||
|
||||
final KioskInfo info = new KioskInfo(extractor.getServiceId(),
|
||||
extractor.getUIHandler(),
|
||||
extractor.getLinkHandler(),
|
||||
extractor.getName());
|
||||
|
||||
final ListExtractor.InfoItemsPage<StreamInfoItem> itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor);
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.schabi.newpipe.extractor.NewPipe;
|
|||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
@ -14,13 +15,15 @@ public class KioskList {
|
|||
public interface KioskExtractorFactory {
|
||||
KioskExtractor createNewKiosk(final StreamingService streamingService,
|
||||
final String url,
|
||||
final String kioskId)
|
||||
final String kioskId,
|
||||
final Localization localization)
|
||||
throws ExtractionException, IOException;
|
||||
}
|
||||
|
||||
private final int service_id;
|
||||
private final HashMap<String, KioskEntry> kioskList = new HashMap<>();
|
||||
private String defaultKiosk = null;
|
||||
private final Localization localization;
|
||||
|
||||
private class KioskEntry {
|
||||
public KioskEntry(KioskExtractorFactory ef, ListLinkHandlerFactory h) {
|
||||
|
@ -31,8 +34,9 @@ public class KioskList {
|
|||
final ListLinkHandlerFactory handlerFactory;
|
||||
}
|
||||
|
||||
public KioskList(int service_id) {
|
||||
public KioskList(int service_id, Localization localization) {
|
||||
this.service_id = service_id;
|
||||
this.localization = localization;
|
||||
}
|
||||
|
||||
public void addKioskEntry(KioskExtractorFactory extractorFactory, ListLinkHandlerFactory handlerFactory, String id)
|
||||
|
@ -73,7 +77,7 @@ public class KioskList {
|
|||
throw new ExtractionException("No kiosk found with the type: " + kioskId);
|
||||
} else {
|
||||
return ke.extractorFactory.createNewKiosk(NewPipe.getService(service_id),
|
||||
ke.handlerFactory.fromId(kioskId).getUrl(), kioskId);
|
||||
ke.handlerFactory.fromId(kioskId).getUrl(), kioskId, localization);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,11 +5,12 @@ import org.schabi.newpipe.extractor.StreamingService;
|
|||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
|
||||
|
||||
public PlaylistExtractor(StreamingService service, ListLinkHandler urlIdHandler) {
|
||||
super(service, urlIdHandler);
|
||||
public PlaylistExtractor(StreamingService service, ListLinkHandler linkHandler, Localization localization) {
|
||||
super(service, linkHandler, localization);
|
||||
}
|
||||
|
||||
public abstract String getThumbnailUrl() throws ParsingException;
|
||||
|
|
|
@ -9,13 +9,14 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||
|
||||
private PlaylistInfo(int serviceId, ListLinkHandler urlIdHandler, String name) throws ParsingException {
|
||||
super(serviceId, urlIdHandler, name);
|
||||
private PlaylistInfo(int serviceId, ListLinkHandler linkHandler, String name) throws ParsingException {
|
||||
super(serviceId, linkHandler, name);
|
||||
}
|
||||
|
||||
public static PlaylistInfo getInfo(String url) throws IOException, ExtractionException {
|
||||
|
@ -28,7 +29,9 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
|||
return getInfo(extractor);
|
||||
}
|
||||
|
||||
public static InfoItemsPage<StreamInfoItem> getMoreItems(StreamingService service, String url, String pageUrl) throws IOException, ExtractionException {
|
||||
public static InfoItemsPage<StreamInfoItem> getMoreItems(StreamingService service,
|
||||
String url,
|
||||
String pageUrl) throws IOException, ExtractionException {
|
||||
return service.getPlaylistExtractor(url).getPage(pageUrl);
|
||||
}
|
||||
|
||||
|
@ -41,7 +44,7 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
|||
|
||||
final PlaylistInfo info = new PlaylistInfo(
|
||||
extractor.getServiceId(),
|
||||
extractor.getUIHandler(),
|
||||
extractor.getLinkHandler(),
|
||||
extractor.getName());
|
||||
|
||||
try {
|
||||
|
|
|
@ -6,6 +6,7 @@ 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.linkhandler.SearchQueryHandler;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
public abstract class SearchExtractor extends ListExtractor<InfoItem> {
|
||||
|
||||
|
@ -16,16 +17,16 @@ public abstract class SearchExtractor extends ListExtractor<InfoItem> {
|
|||
}
|
||||
|
||||
private final InfoItemsSearchCollector collector;
|
||||
private final String contentCountry;
|
||||
|
||||
public SearchExtractor(StreamingService service, SearchQueryHandler urlIdHandler, String contentCountry) {
|
||||
super(service, urlIdHandler);
|
||||
public SearchExtractor(StreamingService service,
|
||||
SearchQueryHandler linkHandler,
|
||||
Localization localization) {
|
||||
super(service, linkHandler, localization);
|
||||
collector = new InfoItemsSearchCollector(service.getServiceId());
|
||||
this.contentCountry = contentCountry;
|
||||
}
|
||||
|
||||
public String getSearchString() {
|
||||
return getUIHandler().getSearchString();
|
||||
return getLinkHandler().getSearchString();
|
||||
}
|
||||
|
||||
public abstract String getSearchSuggestion() throws ParsingException;
|
||||
|
@ -35,16 +36,12 @@ public abstract class SearchExtractor extends ListExtractor<InfoItem> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SearchQueryHandler getUIHandler() {
|
||||
return (SearchQueryHandler) super.getUIHandler();
|
||||
public SearchQueryHandler getLinkHandler() {
|
||||
return (SearchQueryHandler) super.getLinkHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getUIHandler().getSearchString();
|
||||
}
|
||||
|
||||
protected String getContentCountry() {
|
||||
return contentCountry;
|
||||
return getLinkHandler().getSearchString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.schabi.newpipe.extractor.StreamingService;
|
|||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
|
||||
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -24,8 +25,8 @@ public class SearchInfo extends ListInfo<InfoItem> {
|
|||
}
|
||||
|
||||
|
||||
public static SearchInfo getInfo(StreamingService service, SearchQueryHandler searchQuery, String contentCountry) throws ExtractionException, IOException {
|
||||
SearchExtractor extractor = service.getSearchExtractor(searchQuery, contentCountry);
|
||||
public static SearchInfo getInfo(StreamingService service, SearchQueryHandler searchQuery) throws ExtractionException, IOException {
|
||||
SearchExtractor extractor = service.getSearchExtractor(searchQuery);
|
||||
extractor.fetchPage();
|
||||
return getInfo(extractor);
|
||||
}
|
||||
|
@ -33,7 +34,7 @@ public class SearchInfo extends ListInfo<InfoItem> {
|
|||
public static SearchInfo getInfo(SearchExtractor extractor) throws ExtractionException, IOException {
|
||||
final SearchInfo info = new SearchInfo(
|
||||
extractor.getServiceId(),
|
||||
extractor.getUIHandler(),
|
||||
extractor.getLinkHandler(),
|
||||
extractor.getSearchString());
|
||||
|
||||
try {
|
||||
|
@ -52,10 +53,9 @@ public class SearchInfo extends ListInfo<InfoItem> {
|
|||
|
||||
public static ListExtractor.InfoItemsPage<InfoItem> getMoreItems(StreamingService service,
|
||||
SearchQueryHandler query,
|
||||
String contentCountry,
|
||||
String pageUrl)
|
||||
throws IOException, ExtractionException {
|
||||
return service.getSearchExtractor(query, contentCountry).getPage(pageUrl);
|
||||
return service.getSearchExtractor(query).getPage(pageUrl);
|
||||
}
|
||||
|
||||
// Getter
|
||||
|
|
|
@ -12,6 +12,7 @@ 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.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
|
@ -24,14 +25,14 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
|
|||
private StreamInfoItemsCollector streamInfoItemsCollector = null;
|
||||
private String nextPageUrl = null;
|
||||
|
||||
public SoundcloudChannelExtractor(StreamingService service, ListLinkHandler urlIdHandler) {
|
||||
super(service, urlIdHandler);
|
||||
public SoundcloudChannelExtractor(StreamingService service, ListLinkHandler linkHandler, Localization localization) {
|
||||
super(service, linkHandler, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
|
||||
|
||||
userId = getUIHandler().getId();
|
||||
userId = getLinkHandler().getId();
|
||||
String apiUrl = "https://api-v2.soundcloud.com/users/" + userId +
|
||||
"?client_id=" + SoundcloudParsingHelper.clientId();
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
|||
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
|
@ -17,8 +18,11 @@ public class SoundcloudChartsExtractor extends KioskExtractor {
|
|||
private StreamInfoItemsCollector collector = null;
|
||||
private String nextPageUrl = null;
|
||||
|
||||
public SoundcloudChartsExtractor(StreamingService service, ListLinkHandler urlIdHandler, String kioskId) {
|
||||
super(service, urlIdHandler, kioskId);
|
||||
public SoundcloudChartsExtractor(StreamingService service,
|
||||
ListLinkHandler linkHandler,
|
||||
String kioskId,
|
||||
Localization localization) {
|
||||
super(service, linkHandler, kioskId, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
|
@ -23,14 +24,14 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
|
|||
private StreamInfoItemsCollector streamInfoItemsCollector = null;
|
||||
private String nextPageUrl = null;
|
||||
|
||||
public SoundcloudPlaylistExtractor(StreamingService service, ListLinkHandler urlIdHandler) {
|
||||
super(service, urlIdHandler);
|
||||
public SoundcloudPlaylistExtractor(StreamingService service, ListLinkHandler linkHandler, Localization localization) {
|
||||
super(service, linkHandler, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
|
||||
|
||||
playlistId = getUIHandler().getId();
|
||||
playlistId = getLinkHandler().getId();
|
||||
String apiUrl = "https://api.soundcloud.com/playlists/" + playlistId +
|
||||
"?client_id=" + SoundcloudParsingHelper.clientId() +
|
||||
"&representation=compact";
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||
import org.schabi.newpipe.extractor.search.InfoItemsSearchCollector;
|
||||
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||||
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.utils.Parser;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -25,13 +26,13 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
|
|||
private JsonArray searchCollection;
|
||||
|
||||
public SoundcloudSearchExtractor(StreamingService service,
|
||||
SearchQueryHandler urlIdHandler,
|
||||
String contentCountry) {
|
||||
super(service, urlIdHandler, contentCountry);
|
||||
SearchQueryHandler linkHandler,
|
||||
Localization localization) {
|
||||
super(service, linkHandler, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSearchSuggestion() throws ParsingException {
|
||||
public String getSearchSuggestion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
|||
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO;
|
||||
|
@ -21,8 +22,8 @@ public class SoundcloudService extends StreamingService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, String contentCountry) {
|
||||
return new SoundcloudSearchExtractor(this, queryHandler, contentCountry);
|
||||
public SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, Localization localization) {
|
||||
return new SoundcloudSearchExtractor(this, queryHandler, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,39 +48,40 @@ public class SoundcloudService extends StreamingService {
|
|||
|
||||
|
||||
@Override
|
||||
public StreamExtractor getStreamExtractor(LinkHandler LinkHandler) {
|
||||
return new SoundcloudStreamExtractor(this, LinkHandler);
|
||||
public StreamExtractor getStreamExtractor(LinkHandler LinkHandler, Localization localization) {
|
||||
return new SoundcloudStreamExtractor(this, LinkHandler, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelExtractor getChannelExtractor(ListLinkHandler urlIdHandler) {
|
||||
return new SoundcloudChannelExtractor(this, urlIdHandler);
|
||||
public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler, Localization localization) {
|
||||
return new SoundcloudChannelExtractor(this, linkHandler, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlaylistExtractor getPlaylistExtractor(ListLinkHandler urlIdHandler) {
|
||||
return new SoundcloudPlaylistExtractor(this, urlIdHandler);
|
||||
public PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler, Localization localization) {
|
||||
return new SoundcloudPlaylistExtractor(this, linkHandler, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestionExtractor getSuggestionExtractor() {
|
||||
return new SoundcloudSuggestionExtractor(getServiceId());
|
||||
public SuggestionExtractor getSuggestionExtractor(Localization localization) {
|
||||
return new SoundcloudSuggestionExtractor(getServiceId(), localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KioskList getKioskList() throws ExtractionException {
|
||||
public KioskList getKioskList(Localization localization) throws ExtractionException {
|
||||
KioskList.KioskExtractorFactory chartsFactory = new KioskList.KioskExtractorFactory() {
|
||||
@Override
|
||||
public KioskExtractor createNewKiosk(StreamingService streamingService,
|
||||
String url,
|
||||
String id)
|
||||
String id,
|
||||
Localization local)
|
||||
throws ExtractionException {
|
||||
return new SoundcloudChartsExtractor(SoundcloudService.this,
|
||||
new SoundcloudChartsLinkHandlerFactory().fromUrl(url), id);
|
||||
new SoundcloudChartsLinkHandlerFactory().fromUrl(url), id, local);
|
||||
}
|
||||
};
|
||||
|
||||
KioskList list = new KioskList(getServiceId());
|
||||
KioskList list = new KioskList(getServiceId(), localization);
|
||||
|
||||
// add kiosks here e.g.:
|
||||
final SoundcloudChartsLinkHandlerFactory h = new SoundcloudChartsLinkHandlerFactory();
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
|||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
|
||||
import org.schabi.newpipe.extractor.stream.*;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
|
@ -21,8 +22,8 @@ import java.util.List;
|
|||
public class SoundcloudStreamExtractor extends StreamExtractor {
|
||||
private JsonObject track;
|
||||
|
||||
public SoundcloudStreamExtractor(StreamingService service, LinkHandler uIHandler) {
|
||||
super(service, uIHandler);
|
||||
public SoundcloudStreamExtractor(StreamingService service, LinkHandler linkHandler, Localization localization) {
|
||||
super(service, linkHandler, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.NewPipe;
|
|||
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
|
@ -19,12 +20,12 @@ public class SoundcloudSuggestionExtractor extends SuggestionExtractor {
|
|||
|
||||
public static final String CHARSET_UTF_8 = "UTF-8";
|
||||
|
||||
public SoundcloudSuggestionExtractor(int serviceId) {
|
||||
super(serviceId);
|
||||
public SoundcloudSuggestionExtractor(int serviceId, Localization localization) {
|
||||
super(serviceId, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggestionList(String query, String contentCountry) throws IOException, ExtractionException {
|
||||
public List<String> suggestionList(String query) throws IOException, ExtractionException {
|
||||
List<String> suggestions = new ArrayList<>();
|
||||
|
||||
Downloader dl = NewPipe.getDownloader();
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.services.youtube.extractors.*;
|
|||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.*;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.*;
|
||||
|
@ -44,8 +45,8 @@ public class YoutubeService extends StreamingService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SearchExtractor getSearchExtractor(SearchQueryHandler query, String contentCountry) {
|
||||
return new YoutubeSearchExtractor(this, query, contentCountry);
|
||||
public SearchExtractor getSearchExtractor(SearchQueryHandler query, Localization localization) {
|
||||
return new YoutubeSearchExtractor(this, query, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,37 +70,40 @@ public class YoutubeService extends StreamingService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public StreamExtractor getStreamExtractor(LinkHandler linkHandler) throws ExtractionException {
|
||||
return new YoutubeStreamExtractor(this, linkHandler);
|
||||
public StreamExtractor getStreamExtractor(LinkHandler linkHandler, Localization localization) {
|
||||
return new YoutubeStreamExtractor(this, linkHandler, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelExtractor getChannelExtractor(ListLinkHandler urlIdHandler) throws ExtractionException {
|
||||
return new YoutubeChannelExtractor(this, urlIdHandler);
|
||||
public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler, Localization localization) {
|
||||
return new YoutubeChannelExtractor(this, linkHandler, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlaylistExtractor getPlaylistExtractor(ListLinkHandler urlIdHandler) throws ExtractionException {
|
||||
return new YoutubePlaylistExtractor(this, urlIdHandler);
|
||||
public PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler, Localization localization) {
|
||||
return new YoutubePlaylistExtractor(this, linkHandler, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestionExtractor getSuggestionExtractor() {
|
||||
return new YoutubeSuggestionExtractor(getServiceId());
|
||||
public SuggestionExtractor getSuggestionExtractor(Localization localization) {
|
||||
return new YoutubeSuggestionExtractor(getServiceId(), localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KioskList getKioskList() throws ExtractionException {
|
||||
KioskList list = new KioskList(getServiceId());
|
||||
public KioskList getKioskList(final Localization localization) throws ExtractionException {
|
||||
KioskList list = new KioskList(getServiceId(), localization);
|
||||
|
||||
// add kiosks here e.g.:
|
||||
try {
|
||||
list.addKioskEntry(new KioskList.KioskExtractorFactory() {
|
||||
@Override
|
||||
public KioskExtractor createNewKiosk(StreamingService streamingService, String url, String id)
|
||||
public KioskExtractor createNewKiosk(StreamingService streamingService,
|
||||
String url,
|
||||
String id,
|
||||
Localization local)
|
||||
throws ExtractionException {
|
||||
return new YoutubeTrendingExtractor(YoutubeService.this,
|
||||
new YoutubeTrendingLinkHandlerFactory().fromUrl(url), id);
|
||||
new YoutubeTrendingLinkHandlerFactory().fromUrl(url), id, local);
|
||||
}
|
||||
}, new YoutubeTrendingLinkHandlerFactory(), "Trending");
|
||||
list.setDefaultKiosk("Trending");
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
|||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.utils.DonationLinkHelper;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.utils.Parser;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
|
@ -51,8 +52,8 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
|
||||
private Document doc;
|
||||
|
||||
public YoutubeChannelExtractor(StreamingService service, ListLinkHandler urlIdHandler) {
|
||||
super(service, urlIdHandler);
|
||||
public YoutubeChannelExtractor(StreamingService service, ListLinkHandler linkHandler, Localization localization) {
|
||||
super(service, linkHandler, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingH
|
|||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -28,8 +29,8 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
|
|||
|
||||
private Document doc;
|
||||
|
||||
public YoutubePlaylistExtractor(StreamingService service, ListLinkHandler urlIdHandler) throws ExtractionException {
|
||||
super(service, urlIdHandler);
|
||||
public YoutubePlaylistExtractor(StreamingService service, ListLinkHandler linkHandler, Localization localization) {
|
||||
super(service, linkHandler, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||
import org.schabi.newpipe.extractor.search.InfoItemsSearchCollector;
|
||||
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||||
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.utils.Parser;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -44,21 +45,21 @@ public class YoutubeSearchExtractor extends SearchExtractor {
|
|||
private Document doc;
|
||||
|
||||
public YoutubeSearchExtractor(StreamingService service,
|
||||
SearchQueryHandler urlIdHandler,
|
||||
String contentCountry) {
|
||||
super(service, urlIdHandler, contentCountry);
|
||||
SearchQueryHandler linkHandler,
|
||||
Localization localization) {
|
||||
super(service, linkHandler, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
|
||||
final String site;
|
||||
final String url = getUrl();
|
||||
final String contentCountry = getContentCountry();
|
||||
final String contentCountry = getLocalization().getCountry();
|
||||
//String url = builder.build().toString();
|
||||
//if we've been passed a valid language code, append it to the URL
|
||||
if (!contentCountry.isEmpty()) {
|
||||
//assert Pattern.matches("[a-z]{2}(-([A-Z]{2}|[0-9]{1,3}))?", languageCode);
|
||||
site = downloader.download(url, contentCountry);
|
||||
site = downloader.download(url, getLocalization());
|
||||
} else {
|
||||
site = downloader.download(url);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
|
|||
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
|
||||
import org.schabi.newpipe.extractor.services.youtube.ItagItem;
|
||||
import org.schabi.newpipe.extractor.stream.*;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.utils.Parser;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
|
@ -87,8 +88,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
|
||||
private boolean isAgeRestricted;
|
||||
|
||||
public YoutubeStreamExtractor(StreamingService service, LinkHandler linkHandler) {
|
||||
super(service, linkHandler);
|
||||
public YoutubeStreamExtractor(StreamingService service, LinkHandler linkHandler, Localization localization) {
|
||||
super(service, linkHandler, localization);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.schabi.newpipe.extractor.NewPipe;
|
|||
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
|
@ -38,12 +39,12 @@ public class YoutubeSuggestionExtractor extends SuggestionExtractor {
|
|||
|
||||
public static final String CHARSET_UTF_8 = "UTF-8";
|
||||
|
||||
public YoutubeSuggestionExtractor(int serviceId) {
|
||||
super(serviceId);
|
||||
public YoutubeSuggestionExtractor(int serviceId, Localization localization) {
|
||||
super(serviceId, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggestionList(String query, String contentCountry) throws IOException, ExtractionException {
|
||||
public List<String> suggestionList(String query) throws IOException, ExtractionException {
|
||||
Downloader dl = NewPipe.getDownloader();
|
||||
List<String> suggestions = new ArrayList<>();
|
||||
|
||||
|
@ -51,7 +52,7 @@ public class YoutubeSuggestionExtractor extends SuggestionExtractor {
|
|||
+ "?client=" + "youtube" //"firefox" for JSON, 'toolbar' for xml
|
||||
+ "&jsonp=" + "JP"
|
||||
+ "&ds=" + "yt"
|
||||
+ "&hl=" + URLEncoder.encode(contentCountry, CHARSET_UTF_8)
|
||||
+ "&hl=" + URLEncoder.encode(getLocalization().getCountry(), CHARSET_UTF_8)
|
||||
+ "&q=" + URLEncoder.encode(query, CHARSET_UTF_8);
|
||||
|
||||
String response = dl.download(url);
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
|
@ -41,9 +42,10 @@ public class YoutubeTrendingExtractor extends KioskExtractor {
|
|||
private Document doc;
|
||||
|
||||
public YoutubeTrendingExtractor(StreamingService service,
|
||||
ListLinkHandler urlIdHandler,
|
||||
String kioskId) {
|
||||
super(service, urlIdHandler, kioskId);
|
||||
ListLinkHandler linkHandler,
|
||||
String kioskId,
|
||||
Localization localization) {
|
||||
super(service, linkHandler, kioskId, localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.schabi.newpipe.extractor.Subtitles;
|
|||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.utils.Parser;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -39,8 +40,8 @@ public abstract class StreamExtractor extends Extractor {
|
|||
|
||||
public static final int NO_AGE_LIMIT = 0;
|
||||
|
||||
public StreamExtractor(StreamingService service, LinkHandler linkHandler) {
|
||||
super(service, linkHandler);
|
||||
public StreamExtractor(StreamingService service, LinkHandler linkHandler, Localization localization) {
|
||||
super(service, linkHandler, localization);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
|||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.utils.DashMpdParser;
|
||||
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package org.schabi.newpipe.extractor.utils;
|
||||
|
||||
public class Localization {
|
||||
private final String country;
|
||||
private final String language;
|
||||
|
||||
public Localization(String country, String language) {
|
||||
this.country = country;
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package org.schabi.newpipe;
|
||||
|
||||
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.BufferedReader;
|
||||
|
@ -66,12 +67,12 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader {
|
|||
* but set the HTTP header field "Accept-Language" to the supplied string.
|
||||
*
|
||||
* @param siteUrl the URL of the text file to return the contents of
|
||||
* @param language the language (usually a 2-character code) to set as the preferred language
|
||||
* @param localization the language and country (usually a 2-character code for both values)
|
||||
* @return the contents of the specified text file
|
||||
*/
|
||||
public String download(String siteUrl, String language) throws IOException, ReCaptchaException {
|
||||
public String download(String siteUrl, Localization localization) throws IOException, ReCaptchaException {
|
||||
Map<String, String> requestProperties = new HashMap<>();
|
||||
requestProperties.put("Accept-Language", language);
|
||||
requestProperties.put("Accept-Language", localization.getLanguage());
|
||||
return download(siteUrl, requestProperties);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.schabi.newpipe.extractor.NewPipe;
|
|||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
|
||||
|
@ -23,7 +24,7 @@ public class SoundcloudChannelExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (SoundcloudChannelExtractor) SoundCloud
|
||||
.getChannelExtractor("http://soundcloud.com/liluzivert/sets");
|
||||
extractor.fetchPage();
|
||||
|
@ -107,7 +108,7 @@ public class SoundcloudChannelExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (SoundcloudChannelExtractor) SoundCloud
|
||||
.getChannelExtractor("https://soundcloud.com/dubmatix");
|
||||
extractor.fetchPage();
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.schabi.newpipe.extractor.ListExtractor;
|
|||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -23,7 +24,7 @@ public class SoundcloudChartsExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = SoundCloud
|
||||
.getKioskList()
|
||||
.getExtractorById("Top 50", null);
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.junit.Test;
|
|||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -14,37 +15,37 @@ import static org.junit.Assert.assertTrue;
|
|||
* Test for {@link SoundcloudChartsLinkHandlerFactory}
|
||||
*/
|
||||
public class SoundcloudChartsLinkHandlerFactoryTest {
|
||||
private static SoundcloudChartsLinkHandlerFactory urlIdHandler;
|
||||
private static SoundcloudChartsLinkHandlerFactory linkHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
urlIdHandler = new SoundcloudChartsLinkHandlerFactory();
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
public static void setUp() {
|
||||
linkHandler = new SoundcloudChartsLinkHandlerFactory();
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUrl() throws Exception {
|
||||
assertEquals(urlIdHandler.fromId("Top 50").getUrl(), "https://soundcloud.com/charts/top");
|
||||
assertEquals(urlIdHandler.fromId("New & hot").getUrl(), "https://soundcloud.com/charts/new");
|
||||
assertEquals(linkHandler.fromId("Top 50").getUrl(), "https://soundcloud.com/charts/top");
|
||||
assertEquals(linkHandler.fromId("New & hot").getUrl(), "https://soundcloud.com/charts/new");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getId() throws ParsingException {
|
||||
assertEquals(urlIdHandler.fromUrl("http://soundcloud.com/charts/top?genre=all-music").getId(), "Top 50");
|
||||
assertEquals(urlIdHandler.fromUrl("HTTP://www.soundcloud.com/charts/new/?genre=all-music&country=all-countries").getId(), "New & hot");
|
||||
assertEquals(linkHandler.fromUrl("http://soundcloud.com/charts/top?genre=all-music").getId(), "Top 50");
|
||||
assertEquals(linkHandler.fromUrl("HTTP://www.soundcloud.com/charts/new/?genre=all-music&country=all-countries").getId(), "New & hot");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acceptUrl() throws ParsingException {
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/charts"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/charts/"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://www.soundcloud.com/charts/new"));
|
||||
assertTrue(urlIdHandler.acceptUrl("http://soundcloud.com/charts/top?genre=all-music"));
|
||||
assertTrue(urlIdHandler.acceptUrl("HTTP://www.soundcloud.com/charts/new/?genre=all-music&country=all-countries"));
|
||||
assertTrue(linkHandler.acceptUrl("https://soundcloud.com/charts"));
|
||||
assertTrue(linkHandler.acceptUrl("https://soundcloud.com/charts/"));
|
||||
assertTrue(linkHandler.acceptUrl("https://www.soundcloud.com/charts/new"));
|
||||
assertTrue(linkHandler.acceptUrl("http://soundcloud.com/charts/top?genre=all-music"));
|
||||
assertTrue(linkHandler.acceptUrl("HTTP://www.soundcloud.com/charts/new/?genre=all-music&country=all-countries"));
|
||||
|
||||
assertFalse(urlIdHandler.acceptUrl("kdskjfiiejfia"));
|
||||
assertFalse(urlIdHandler.acceptUrl("soundcloud.com/charts askjkf"));
|
||||
assertFalse(urlIdHandler.acceptUrl(" soundcloud.com/charts"));
|
||||
assertFalse(urlIdHandler.acceptUrl(""));
|
||||
assertFalse(linkHandler.acceptUrl("kdskjfiiejfia"));
|
||||
assertFalse(linkHandler.acceptUrl("soundcloud.com/charts askjkf"));
|
||||
assertFalse(linkHandler.acceptUrl(" soundcloud.com/charts"));
|
||||
assertFalse(linkHandler.acceptUrl(""));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,11 +5,12 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
public class SoundcloudParsingHelperTest {
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.ServiceList;
|
|||
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||
import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
|
@ -25,7 +26,7 @@ public class SoundcloudPlaylistExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
||||
.getPlaylistExtractor("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r?test=123");
|
||||
extractor.fetchPage();
|
||||
|
@ -123,7 +124,7 @@ public class SoundcloudPlaylistExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
||||
.getPlaylistExtractor("https://soundcloud.com/hunter-leader/sets/house-electro-dance-music-2");
|
||||
extractor.fetchPage();
|
||||
|
@ -215,7 +216,7 @@ public class SoundcloudPlaylistExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
||||
.getPlaylistExtractor("https://soundcloud.com/user350509423/sets/edm-xxx");
|
||||
extractor.fetchPage();
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -24,7 +25,7 @@ public class SoundcloudStreamExtractorDefaultTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (SoundcloudStreamExtractor) SoundCloud.getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.junit.Test;
|
|||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -15,17 +16,17 @@ import static org.junit.Assert.*;
|
|||
* Test for {@link SoundcloudStreamLinkHandlerFactory}
|
||||
*/
|
||||
public class SoundcloudStreamLinkHandlerFactoryTest {
|
||||
private static SoundcloudStreamLinkHandlerFactory urlIdHandler;
|
||||
private static SoundcloudStreamLinkHandlerFactory linkHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
urlIdHandler = SoundcloudStreamLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
linkHandler = SoundcloudStreamLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void getIdWithNullAsUrl() throws ParsingException {
|
||||
urlIdHandler.fromUrl(null).getId();
|
||||
linkHandler.fromUrl(null).getId();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -37,7 +38,7 @@ public class SoundcloudStreamLinkHandlerFactoryTest {
|
|||
for (String invalidUrl : invalidUrls) {
|
||||
Throwable exception = null;
|
||||
try {
|
||||
urlIdHandler.fromUrl(invalidUrl).getId();
|
||||
linkHandler.fromUrl(invalidUrl).getId();
|
||||
} catch (ParsingException e) {
|
||||
exception = e;
|
||||
}
|
||||
|
@ -49,30 +50,30 @@ public class SoundcloudStreamLinkHandlerFactoryTest {
|
|||
|
||||
@Test
|
||||
public void getId() throws Exception {
|
||||
assertEquals("309689103", urlIdHandler.fromUrl("https://soundcloud.com/liluzivert/15-ysl").getId());
|
||||
assertEquals("309689082", urlIdHandler.fromUrl("https://www.soundcloud.com/liluzivert/15-luv-scars-ko").getId());
|
||||
assertEquals("309689035", urlIdHandler.fromUrl("http://soundcloud.com/liluzivert/15-boring-shit").getId());
|
||||
assertEquals("294488599", urlIdHandler.fromUrl("http://www.soundcloud.com/liluzivert/secure-the-bag-produced-by-glohan-beats").getId());
|
||||
assertEquals("294488438", urlIdHandler.fromUrl("HtTpS://sOuNdClOuD.cOm/LiLuZiVeRt/In-O4-pRoDuCeD-bY-dP-bEaTz").getId());
|
||||
assertEquals("294488147", urlIdHandler.fromUrl("https://soundcloud.com/liluzivert/fresh-produced-by-zaytoven#t=69").getId());
|
||||
assertEquals("294487876", urlIdHandler.fromUrl("https://soundcloud.com/liluzivert/threesome-produced-by-zaytoven#t=1:09").getId());
|
||||
assertEquals("294487684", urlIdHandler.fromUrl("https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9").getId());
|
||||
assertEquals("294487428", urlIdHandler.fromUrl("https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s").getId());
|
||||
assertEquals("294487157", urlIdHandler.fromUrl("https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s").getId());
|
||||
assertEquals("309689103", linkHandler.fromUrl("https://soundcloud.com/liluzivert/15-ysl").getId());
|
||||
assertEquals("309689082", linkHandler.fromUrl("https://www.soundcloud.com/liluzivert/15-luv-scars-ko").getId());
|
||||
assertEquals("309689035", linkHandler.fromUrl("http://soundcloud.com/liluzivert/15-boring-shit").getId());
|
||||
assertEquals("294488599", linkHandler.fromUrl("http://www.soundcloud.com/liluzivert/secure-the-bag-produced-by-glohan-beats").getId());
|
||||
assertEquals("294488438", linkHandler.fromUrl("HtTpS://sOuNdClOuD.cOm/LiLuZiVeRt/In-O4-pRoDuCeD-bY-dP-bEaTz").getId());
|
||||
assertEquals("294488147", linkHandler.fromUrl("https://soundcloud.com/liluzivert/fresh-produced-by-zaytoven#t=69").getId());
|
||||
assertEquals("294487876", linkHandler.fromUrl("https://soundcloud.com/liluzivert/threesome-produced-by-zaytoven#t=1:09").getId());
|
||||
assertEquals("294487684", linkHandler.fromUrl("https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9").getId());
|
||||
assertEquals("294487428", linkHandler.fromUrl("https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s").getId());
|
||||
assertEquals("294487157", linkHandler.fromUrl("https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s").getId());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAcceptUrl() throws ParsingException {
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/15-ysl"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://www.soundcloud.com/liluzivert/15-luv-scars-ko"));
|
||||
assertTrue(urlIdHandler.acceptUrl("http://soundcloud.com/liluzivert/15-boring-shit"));
|
||||
assertTrue(urlIdHandler.acceptUrl("http://www.soundcloud.com/liluzivert/secure-the-bag-produced-by-glohan-beats"));
|
||||
assertTrue(urlIdHandler.acceptUrl("HtTpS://sOuNdClOuD.cOm/LiLuZiVeRt/In-O4-pRoDuCeD-bY-dP-bEaTz"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/fresh-produced-by-zaytoven#t=69"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/threesome-produced-by-zaytoven#t=1:09"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s"));
|
||||
assertTrue(linkHandler.acceptUrl("https://soundcloud.com/liluzivert/15-ysl"));
|
||||
assertTrue(linkHandler.acceptUrl("https://www.soundcloud.com/liluzivert/15-luv-scars-ko"));
|
||||
assertTrue(linkHandler.acceptUrl("http://soundcloud.com/liluzivert/15-boring-shit"));
|
||||
assertTrue(linkHandler.acceptUrl("http://www.soundcloud.com/liluzivert/secure-the-bag-produced-by-glohan-beats"));
|
||||
assertTrue(linkHandler.acceptUrl("HtTpS://sOuNdClOuD.cOm/LiLuZiVeRt/In-O4-pRoDuCeD-bY-dP-bEaTz"));
|
||||
assertTrue(linkHandler.acceptUrl("https://soundcloud.com/liluzivert/fresh-produced-by-zaytoven#t=69"));
|
||||
assertTrue(linkHandler.acceptUrl("https://soundcloud.com/liluzivert/threesome-produced-by-zaytoven#t=1:09"));
|
||||
assertTrue(linkHandler.acceptUrl("https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9"));
|
||||
assertTrue(linkHandler.acceptUrl("https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s"));
|
||||
assertTrue(linkHandler.acceptUrl("https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s"));
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
|||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
@ -25,7 +26,7 @@ public class SoundcloudSubscriptionExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setupClass() {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
subscriptionExtractor = new SoundcloudSubscriptionExtractor(ServiceList.SoundCloud);
|
||||
urlHandler = ServiceList.SoundCloud.getChannelLHFactory();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.schabi.newpipe.Downloader;
|
|||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,13 +20,13 @@ public class SoundcloudSuggestionExtractorTest {
|
|||
private static SuggestionExtractor suggestionExtractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
public static void setUp() {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
suggestionExtractor = SoundCloud.getSuggestionExtractor();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIfSuggestions() throws IOException, ExtractionException {
|
||||
assertFalse(suggestionExtractor.suggestionList("lil uzi vert", "de").isEmpty());
|
||||
assertFalse(suggestionExtractor.suggestionList("lil uzi vert").isEmpty());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.NewPipe;
|
|||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchQueryHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.Assert.*;
|
||||
|
@ -18,9 +19,9 @@ public class SoundcloudSearchExtractorChannelOnlyTest extends SoundcloudSearchEx
|
|||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("DE", "de"));
|
||||
extractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert",
|
||||
asList(SoundcloudSearchQueryHandlerFactory.USERS), null, "de");
|
||||
asList(SoundcloudSearchQueryHandlerFactory.USERS), null, new Localization("DE", "de"));
|
||||
extractor.fetchPage();
|
||||
itemsPage = extractor.getInitialPage();
|
||||
}
|
||||
|
@ -28,7 +29,7 @@ public class SoundcloudSearchExtractorChannelOnlyTest extends SoundcloudSearchEx
|
|||
@Test
|
||||
public void testGetSecondPage() throws Exception {
|
||||
SoundcloudSearchExtractor secondExtractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert",
|
||||
asList(SoundcloudSearchQueryHandlerFactory.USERS), null, "de");
|
||||
asList(SoundcloudSearchQueryHandlerFactory.USERS), null, new Localization("DE", "de"));
|
||||
ListExtractor.InfoItemsPage<InfoItem> secondPage = secondExtractor.getPage(itemsPage.getNextPageUrl());
|
||||
assertTrue(Integer.toString(secondPage.getItems().size()),
|
||||
secondPage.getItems().size() >= 3);
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
|||
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
|
@ -42,8 +43,8 @@ public class SoundcloudSearchExtractorDefaultTest extends SoundcloudSearchExtrac
|
|||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
extractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert", "de");
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert");
|
||||
extractor.fetchPage();
|
||||
itemsPage = extractor.getInitialPage();
|
||||
}
|
||||
|
@ -76,7 +77,8 @@ public class SoundcloudSearchExtractorDefaultTest extends SoundcloudSearchExtrac
|
|||
|
||||
@Test
|
||||
public void testGetSecondPage() throws Exception {
|
||||
SoundcloudSearchExtractor secondExtractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert", "de");
|
||||
SoundcloudSearchExtractor secondExtractor =
|
||||
(SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert");
|
||||
ListExtractor.InfoItemsPage<InfoItem> secondPage = secondExtractor.getPage(itemsPage.getNextPageUrl());
|
||||
assertTrue(Integer.toString(secondPage.getItems().size()),
|
||||
secondPage.getItems().size() >= 10);
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -16,7 +17,7 @@ public class SoundcloudSearchQHTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
}
|
||||
|
||||
private static String removeClientId(String url) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
|||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
|
@ -24,7 +25,7 @@ public class YoutubeChannelExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (YoutubeChannelExtractor) YouTube
|
||||
.getChannelExtractor("http://www.youtube.com/user/Gronkh");
|
||||
extractor.fetchPage();
|
||||
|
@ -120,7 +121,7 @@ public class YoutubeChannelExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (YoutubeChannelExtractor) YouTube
|
||||
.getChannelExtractor("https://www.youtube.com/user/Vsauce");
|
||||
extractor.fetchPage();
|
||||
|
@ -216,7 +217,7 @@ public class YoutubeChannelExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (YoutubeChannelExtractor) YouTube
|
||||
.getChannelExtractor("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q");
|
||||
extractor.fetchPage();
|
||||
|
@ -323,7 +324,7 @@ public class YoutubeChannelExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (YoutubeChannelExtractor) YouTube
|
||||
.getChannelExtractor("https://www.youtube.com/user/CaptainDisillusion/videos");
|
||||
extractor.fetchPage();
|
||||
|
@ -412,7 +413,7 @@ public class YoutubeChannelExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (YoutubeChannelExtractor) YouTube
|
||||
.getChannelExtractor("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w");
|
||||
extractor.fetchPage();
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.schabi.newpipe.Downloader;
|
|||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -15,42 +16,42 @@ import static org.junit.Assert.assertTrue;
|
|||
*/
|
||||
public class YoutubeChannelLinkHandlerFactoryTest {
|
||||
|
||||
private static YoutubeChannelLinkHandlerFactory urlIdHandler;
|
||||
private static YoutubeChannelLinkHandlerFactory linkHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
urlIdHandler = YoutubeChannelLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
linkHandler = YoutubeChannelLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acceptrUrlTest() throws ParsingException {
|
||||
assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/user/Gronkh"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/user/Netzkino/videos"));
|
||||
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/user/Gronkh"));
|
||||
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/user/Netzkino/videos"));
|
||||
|
||||
assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1"));
|
||||
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA"));
|
||||
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1"));
|
||||
|
||||
assertTrue(urlIdHandler.acceptUrl("https://hooktube.com/user/Gronkh"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://hooktube.com/user/Netzkino/videos"));
|
||||
assertTrue(linkHandler.acceptUrl("https://hooktube.com/user/Gronkh"));
|
||||
assertTrue(linkHandler.acceptUrl("https://hooktube.com/user/Netzkino/videos"));
|
||||
|
||||
assertTrue(urlIdHandler.acceptUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1"));
|
||||
assertTrue(linkHandler.acceptUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA"));
|
||||
assertTrue(linkHandler.acceptUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIdFromUrl() throws ParsingException {
|
||||
assertEquals("user/Gronkh", urlIdHandler.fromUrl("https://www.youtube.com/user/Gronkh").getId());
|
||||
assertEquals("user/Netzkino", urlIdHandler.fromUrl("https://www.youtube.com/user/Netzkino/videos").getId());
|
||||
assertEquals("user/Gronkh", linkHandler.fromUrl("https://www.youtube.com/user/Gronkh").getId());
|
||||
assertEquals("user/Netzkino", linkHandler.fromUrl("https://www.youtube.com/user/Netzkino/videos").getId());
|
||||
|
||||
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", urlIdHandler.fromUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA").getId());
|
||||
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", urlIdHandler.fromUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1").getId());
|
||||
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA").getId());
|
||||
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1").getId());
|
||||
|
||||
|
||||
assertEquals("user/Gronkh", urlIdHandler.fromUrl("https://hooktube.com/user/Gronkh").getId());
|
||||
assertEquals("user/Netzkino", urlIdHandler.fromUrl("https://hooktube.com/user/Netzkino/videos").getId());
|
||||
assertEquals("user/Gronkh", linkHandler.fromUrl("https://hooktube.com/user/Gronkh").getId());
|
||||
assertEquals("user/Netzkino", linkHandler.fromUrl("https://hooktube.com/user/Netzkino/videos").getId());
|
||||
|
||||
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", urlIdHandler.fromUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA").getId());
|
||||
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", urlIdHandler.fromUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1").getId());
|
||||
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA").getId());
|
||||
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1").getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
|||
import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubePlaylistExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -28,7 +29,7 @@ public class YoutubePlaylistExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (YoutubePlaylistExtractor) YouTube
|
||||
.getPlaylistExtractor("http://www.youtube.com/watch?v=lp-EO5I60KA&list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj");
|
||||
extractor.fetchPage();
|
||||
|
@ -125,7 +126,7 @@ public class YoutubePlaylistExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (YoutubePlaylistExtractor) YouTube
|
||||
.getPlaylistExtractor("https://www.youtube.com/watch?v=8SbUC-UaAxE&list=PLWwAypAcFRgKAIIFqBr9oy-ZYZnixa_Fj");
|
||||
extractor.fetchPage();
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.schabi.newpipe.Downloader;
|
|||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskList;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -40,7 +41,7 @@ public class YoutubeServiceTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
service = YouTube;
|
||||
kioskList = service.getKioskList();
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLi
|
|||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.SubtitlesFormat;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -30,7 +31,7 @@ public class YoutubeStreamExtractorAgeRestrictedTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=MmBeUZqv1QA");
|
||||
extractor.fetchPage();
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLi
|
|||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.SubtitlesFormat;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -29,7 +30,7 @@ public class YoutubeStreamExtractorControversialTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=T4XJQO3qol8");
|
||||
extractor.fetchPage();
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.schabi.newpipe.Downloader;
|
|||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -40,7 +41,7 @@ public class YoutubeStreamExtractorDASHTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
info = StreamInfo.getInfo(YouTube, "https://www.youtube.com/watch?v=00Q4SUnVQK4");
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.*;
|
||||
import org.schabi.newpipe.extractor.utils.DashMpdParser;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -48,7 +49,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=rYEDA3JcQqw");
|
||||
extractor.fetchPage();
|
||||
|
@ -174,7 +175,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=LUldijpMUew");
|
||||
extractor.fetchPage();
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.schabi.newpipe.extractor.NewPipe;
|
|||
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -18,22 +19,22 @@ import static org.junit.Assert.*;
|
|||
*/
|
||||
public class YoutubeStreamLinkHandlerFactoryTest {
|
||||
private static String AD_URL = "https://googleads.g.doubleclick.net/aclk?sa=l&ai=C-2IPgeVTWPf4GcOStgfOnIOADf78n61GvKmmobYDrgIQASDj-5MDKAJg9ZXOgeAEoAGgy_T-A8gBAakC2gkpmquIsT6oAwGqBJMBT9BgD5kVgbN0dX602bFFaDw9vsxq-We-S8VkrXVBi6W_e7brZ36GCz1WO3EPEeklYuJjXLUowwCOKsd-8xr1UlS_tusuFJv9iX35xoBHKTRvs8-0aDbfEIm6in37QDfFuZjqgEMB8-tg0Jn_Pf1RU5OzbuU40B4Gy25NUTnOxhDKthOhKBUSZEksCEerUV8GMu10iAXCxquwApIFBggDEAEYAaAGGsgGlIjthrUDgAfItIsBqAemvhvYBwHSCAUIgGEQAbgT6AE&num=1&sig=AOD64_1DybDd4qAm5O7o9UAbTNRdqXXHFQ&ctype=21&video_id=dMO_IXYPZew&client=ca-pub-6219811747049371&adurl=http://www.youtube.com/watch%3Fv%3DdMO_IXYPZew";
|
||||
private static YoutubeStreamLinkHandlerFactory urlIdHandler;
|
||||
private static YoutubeStreamLinkHandlerFactory linkHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
urlIdHandler = YoutubeStreamLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
linkHandler = YoutubeStreamLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void getIdWithNullAsUrl() throws ParsingException {
|
||||
urlIdHandler.fromId(null);
|
||||
linkHandler.fromId(null);
|
||||
}
|
||||
|
||||
@Test(expected = FoundAdException.class)
|
||||
public void getIdForAd() throws ParsingException {
|
||||
urlIdHandler.fromUrl(AD_URL).getId();
|
||||
linkHandler.fromUrl(AD_URL).getId();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -45,7 +46,7 @@ public class YoutubeStreamLinkHandlerFactoryTest {
|
|||
for (String invalidUrl : invalidUrls) {
|
||||
Throwable exception = null;
|
||||
try {
|
||||
urlIdHandler.fromUrl(invalidUrl).getId();
|
||||
linkHandler.fromUrl(invalidUrl).getId();
|
||||
} catch (ParsingException e) {
|
||||
exception = e;
|
||||
}
|
||||
|
@ -57,67 +58,67 @@ public class YoutubeStreamLinkHandlerFactoryTest {
|
|||
|
||||
@Test
|
||||
public void getIdfromYt() throws Exception {
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("https://www.youtube.com/watch?v=jZViOEv90dI").getId());
|
||||
assertEquals("W-fFHeTX70Q", urlIdHandler.fromUrl("https://www.youtube.com/watch?v=W-fFHeTX70Q").getId());
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("https://www.youtube.com/watch?v=jZViOEv90dI?t=100").getId());
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("https://WWW.YouTube.com/watch?v=jZViOEv90dI?t=100").getId());
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("HTTPS://www.youtube.com/watch?v=jZViOEv90dI?t=100").getId());
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("https://youtu.be/jZViOEv90dI?t=9s").getId());
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("HTTPS://Youtu.be/jZViOEv90dI?t=9s").getId());
|
||||
assertEquals("uEJuoEs1UxY", urlIdHandler.fromUrl("http://www.youtube.com/watch_popup?v=uEJuoEs1UxY").getId());
|
||||
assertEquals("uEJuoEs1UxY", urlIdHandler.fromUrl("http://www.Youtube.com/watch_popup?v=uEJuoEs1UxY").getId());
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("https://www.youtube.com/embed/jZViOEv90dI").getId());
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("https://www.youtube-nocookie.com/embed/jZViOEv90dI").getId());
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("http://www.youtube.com/watch?v=jZViOEv90dI").getId());
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("http://youtube.com/watch?v=jZViOEv90dI").getId());
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("http://youtu.be/jZViOEv90dI?t=9s").getId());
|
||||
assertEquals("7_WWz2DSnT8", urlIdHandler.fromUrl("https://youtu.be/7_WWz2DSnT8").getId());
|
||||
assertEquals("oy6NvWeVruY", urlIdHandler.fromUrl("https://m.youtube.com/watch?v=oy6NvWeVruY").getId());
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("http://www.youtube.com/embed/jZViOEv90dI").getId());
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("http://www.Youtube.com/embed/jZViOEv90dI").getId());
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("http://www.youtube-nocookie.com/embed/jZViOEv90dI").getId());
|
||||
assertEquals("EhxJLojIE_o", urlIdHandler.fromUrl("http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare").getId());
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("vnd.youtube://www.youtube.com/watch?v=jZViOEv90dI").getId());
|
||||
assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("vnd.youtube:jZViOEv90dI").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("https://www.youtube.com/watch?v=jZViOEv90dI").getId());
|
||||
assertEquals("W-fFHeTX70Q", linkHandler.fromUrl("https://www.youtube.com/watch?v=W-fFHeTX70Q").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("https://www.youtube.com/watch?v=jZViOEv90dI?t=100").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("https://WWW.YouTube.com/watch?v=jZViOEv90dI?t=100").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("HTTPS://www.youtube.com/watch?v=jZViOEv90dI?t=100").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("https://youtu.be/jZViOEv90dI?t=9s").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("HTTPS://Youtu.be/jZViOEv90dI?t=9s").getId());
|
||||
assertEquals("uEJuoEs1UxY", linkHandler.fromUrl("http://www.youtube.com/watch_popup?v=uEJuoEs1UxY").getId());
|
||||
assertEquals("uEJuoEs1UxY", linkHandler.fromUrl("http://www.Youtube.com/watch_popup?v=uEJuoEs1UxY").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("https://www.youtube.com/embed/jZViOEv90dI").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("https://www.youtube-nocookie.com/embed/jZViOEv90dI").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://www.youtube.com/watch?v=jZViOEv90dI").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://youtube.com/watch?v=jZViOEv90dI").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://youtu.be/jZViOEv90dI?t=9s").getId());
|
||||
assertEquals("7_WWz2DSnT8", linkHandler.fromUrl("https://youtu.be/7_WWz2DSnT8").getId());
|
||||
assertEquals("oy6NvWeVruY", linkHandler.fromUrl("https://m.youtube.com/watch?v=oy6NvWeVruY").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://www.youtube.com/embed/jZViOEv90dI").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://www.Youtube.com/embed/jZViOEv90dI").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://www.youtube-nocookie.com/embed/jZViOEv90dI").getId());
|
||||
assertEquals("EhxJLojIE_o", linkHandler.fromUrl("http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("vnd.youtube://www.youtube.com/watch?v=jZViOEv90dI").getId());
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("vnd.youtube:jZViOEv90dI").getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptYtUrl() throws ParsingException {
|
||||
assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/watch?v=jZViOEv90dI"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/watch?v=jZViOEv90dI?t=100"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://WWW.YouTube.com/watch?v=jZViOEv90dI?t=100"));
|
||||
assertTrue(urlIdHandler.acceptUrl("HTTPS://www.youtube.com/watch?v=jZViOEv90dI?t=100"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://youtu.be/jZViOEv90dI?t=9s"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/embed/jZViOEv90dI"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://www.youtube-nocookie.com/embed/jZViOEv90dI"));
|
||||
assertTrue(urlIdHandler.acceptUrl("http://www.youtube.com/watch?v=jZViOEv90dI"));
|
||||
assertTrue(urlIdHandler.acceptUrl("http://youtu.be/jZViOEv90dI?t=9s"));
|
||||
assertTrue(urlIdHandler.acceptUrl("http://www.youtube.com/embed/jZViOEv90dI"));
|
||||
assertTrue(urlIdHandler.acceptUrl("http://www.youtube-nocookie.com/embed/jZViOEv90dI"));
|
||||
assertTrue(urlIdHandler.acceptUrl("http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare"));
|
||||
assertTrue(urlIdHandler.acceptUrl("vnd.youtube://www.youtube.com/watch?v=jZViOEv90dI"));
|
||||
assertTrue(urlIdHandler.acceptUrl("vnd.youtube:jZViOEv90dI"));
|
||||
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/watch?v=jZViOEv90dI"));
|
||||
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/watch?v=jZViOEv90dI?t=100"));
|
||||
assertTrue(linkHandler.acceptUrl("https://WWW.YouTube.com/watch?v=jZViOEv90dI?t=100"));
|
||||
assertTrue(linkHandler.acceptUrl("HTTPS://www.youtube.com/watch?v=jZViOEv90dI?t=100"));
|
||||
assertTrue(linkHandler.acceptUrl("https://youtu.be/jZViOEv90dI?t=9s"));
|
||||
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/embed/jZViOEv90dI"));
|
||||
assertTrue(linkHandler.acceptUrl("https://www.youtube-nocookie.com/embed/jZViOEv90dI"));
|
||||
assertTrue(linkHandler.acceptUrl("http://www.youtube.com/watch?v=jZViOEv90dI"));
|
||||
assertTrue(linkHandler.acceptUrl("http://youtu.be/jZViOEv90dI?t=9s"));
|
||||
assertTrue(linkHandler.acceptUrl("http://www.youtube.com/embed/jZViOEv90dI"));
|
||||
assertTrue(linkHandler.acceptUrl("http://www.youtube-nocookie.com/embed/jZViOEv90dI"));
|
||||
assertTrue(linkHandler.acceptUrl("http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare"));
|
||||
assertTrue(linkHandler.acceptUrl("vnd.youtube://www.youtube.com/watch?v=jZViOEv90dI"));
|
||||
assertTrue(linkHandler.acceptUrl("vnd.youtube:jZViOEv90dI"));
|
||||
|
||||
assertTrue(urlIdHandler.acceptUrl("vnd.youtube:jZViOEv90dI"));
|
||||
assertTrue(linkHandler.acceptUrl("vnd.youtube:jZViOEv90dI"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHookUrl() throws ParsingException {
|
||||
assertTrue(urlIdHandler.acceptUrl("https://hooktube.com/watch?v=TglNG-yjabU"));
|
||||
assertTrue(urlIdHandler.acceptUrl("hooktube.com/watch?v=3msbfr6pBNE"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://hooktube.com/watch?v=ocH3oSnZG3c&list=PLS2VU1j4vzuZwooPjV26XM9UEBY2CPNn2"));
|
||||
assertTrue(urlIdHandler.acceptUrl("hooktube.com/watch/3msbfr6pBNE"));
|
||||
assertTrue(urlIdHandler.acceptUrl("hooktube.com/v/3msbfr6pBNE"));
|
||||
assertTrue(urlIdHandler.acceptUrl("hooktube.com/embed/3msbfr6pBNE"));
|
||||
assertTrue(linkHandler.acceptUrl("https://hooktube.com/watch?v=TglNG-yjabU"));
|
||||
assertTrue(linkHandler.acceptUrl("hooktube.com/watch?v=3msbfr6pBNE"));
|
||||
assertTrue(linkHandler.acceptUrl("https://hooktube.com/watch?v=ocH3oSnZG3c&list=PLS2VU1j4vzuZwooPjV26XM9UEBY2CPNn2"));
|
||||
assertTrue(linkHandler.acceptUrl("hooktube.com/watch/3msbfr6pBNE"));
|
||||
assertTrue(linkHandler.acceptUrl("hooktube.com/v/3msbfr6pBNE"));
|
||||
assertTrue(linkHandler.acceptUrl("hooktube.com/embed/3msbfr6pBNE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetHookIdfromUrl() throws ParsingException {
|
||||
assertEquals("TglNG-yjabU", urlIdHandler.fromUrl("https://hooktube.com/watch?v=TglNG-yjabU").getId());
|
||||
assertEquals("3msbfr6pBNE", urlIdHandler.fromUrl("hooktube.com/watch?v=3msbfr6pBNE").getId());
|
||||
assertEquals("ocH3oSnZG3c", urlIdHandler.fromUrl("https://hooktube.com/watch?v=ocH3oSnZG3c&list=PLS2VU1j4vzuZwooPjV26XM9UEBY2CPNn2").getId());
|
||||
assertEquals("3msbfr6pBNE", urlIdHandler.fromUrl("hooktube.com/watch/3msbfr6pBNE").getId());
|
||||
assertEquals("3msbfr6pBNE", urlIdHandler.fromUrl("hooktube.com/v/3msbfr6pBNE").getId());
|
||||
assertEquals("3msbfr6pBNE", urlIdHandler.fromUrl("hooktube.com/embed/3msbfr6pBNE").getId());
|
||||
assertEquals("TglNG-yjabU", linkHandler.fromUrl("https://hooktube.com/watch?v=TglNG-yjabU").getId());
|
||||
assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/watch?v=3msbfr6pBNE").getId());
|
||||
assertEquals("ocH3oSnZG3c", linkHandler.fromUrl("https://hooktube.com/watch?v=ocH3oSnZG3c&list=PLS2VU1j4vzuZwooPjV26XM9UEBY2CPNn2").getId());
|
||||
assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/watch/3msbfr6pBNE").getId());
|
||||
assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/v/3msbfr6pBNE").getId());
|
||||
assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/embed/3msbfr6pBNE").getId());
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
|||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSubscriptionExtractor;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
|
@ -27,7 +28,7 @@ public class YoutubeSubscriptionExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setupClass() {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
subscriptionExtractor = new YoutubeSubscriptionExtractor(ServiceList.YouTube);
|
||||
urlHandler = ServiceList.YouTube.getChannelLHFactory();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.schabi.newpipe.Downloader;
|
|||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -40,12 +41,12 @@ public class YoutubeSuggestionExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("DE", "de"));
|
||||
suggestionExtractor = YouTube.getSuggestionExtractor();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIfSuggestions() throws IOException, ExtractionException {
|
||||
assertFalse(suggestionExtractor.suggestionList("hello", "de").isEmpty());
|
||||
assertFalse(suggestionExtractor.suggestionList("hello").isEmpty());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.schabi.newpipe.extractor.NewPipe;
|
|||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeTrendingExtractor;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
|
@ -45,7 +46,7 @@ public class YoutubeTrendingExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (YoutubeTrendingExtractor) YouTube
|
||||
.getKioskList()
|
||||
.getExtractorById("Trending", null);
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.schabi.newpipe.extractor.NewPipe;
|
|||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskInfo;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -41,7 +42,7 @@ public class YoutubeTrendingKioskInfoTest {
|
|||
@BeforeClass
|
||||
public static void setUp()
|
||||
throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
StreamingService service = YouTube;
|
||||
LinkHandlerFactory LinkHandlerFactory = service.getKioskList().getListLinkHandlerFactoryByType("Trending");
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.schabi.newpipe.extractor.NewPipe;
|
|||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -42,7 +43,7 @@ public class YoutubeTrendingLinkHandlerFactoryTest {
|
|||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
LinkHandlerFactory = YouTube.getKioskList().getListLinkHandlerFactoryByType("Trending");
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -3,11 +3,11 @@ package org.schabi.newpipe.extractor.services.youtube.search;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
@ -17,16 +17,15 @@ public class YoutubeSearchCountTest {
|
|||
public static class YoutubeChannelViewCountTest extends YoutubeSearchExtractorBaseTest {
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie",
|
||||
singletonList(YoutubeSearchQueryHandlerFactory.CHANNELS), null,"de");
|
||||
singletonList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, new Localization("GB", "en"));
|
||||
extractor.fetchPage();
|
||||
itemsPage = extractor.getInitialPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testViewCount() throws Exception {
|
||||
boolean foundKnownChannel = false;
|
||||
public void testViewCount() {
|
||||
ChannelInfoItem ci = (ChannelInfoItem) itemsPage.getItems().get(0);
|
||||
assertTrue("Count does not fit: " + Long.toString(ci.getSubscriberCount()),
|
||||
65043316 < ci.getSubscriberCount() && ci.getSubscriberCount() < 68043316);
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.NewPipe;
|
|||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.Assert.*;
|
||||
|
@ -18,9 +19,9 @@ public class YoutubeSearchExtractorChannelOnlyTest extends YoutubeSearchExtracto
|
|||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie",
|
||||
asList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, "de");
|
||||
asList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, new Localization("GB", "en"));
|
||||
extractor.fetchPage();
|
||||
itemsPage = extractor.getInitialPage();
|
||||
}
|
||||
|
@ -28,7 +29,7 @@ public class YoutubeSearchExtractorChannelOnlyTest extends YoutubeSearchExtracto
|
|||
@Test
|
||||
public void testGetSecondPage() throws Exception {
|
||||
YoutubeSearchExtractor secondExtractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie",
|
||||
asList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, "de");
|
||||
asList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, new Localization("GB", "en"));
|
||||
ListExtractor.InfoItemsPage<InfoItem> secondPage = secondExtractor.getPage(itemsPage.getNextPageUrl());
|
||||
assertTrue(Integer.toString(secondPage.getItems().size()),
|
||||
secondPage.getItems().size() > 10);
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.NewPipe;
|
|||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -42,8 +43,8 @@ public class YoutubeSearchExtractorDefaultTest extends YoutubeSearchExtractorBas
|
|||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie", "de");
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie");
|
||||
extractor.fetchPage();
|
||||
itemsPage = extractor.getInitialPage();
|
||||
}
|
||||
|
@ -79,7 +80,7 @@ public class YoutubeSearchExtractorDefaultTest extends YoutubeSearchExtractorBas
|
|||
@Test
|
||||
public void testGetSecondPage() throws Exception {
|
||||
YoutubeSearchExtractor secondExtractor =
|
||||
(YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie", "de");
|
||||
(YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie");
|
||||
ListExtractor.InfoItemsPage<InfoItem> secondPage = secondExtractor.getPage(itemsPage.getNextPageUrl());
|
||||
assertTrue(Integer.toString(secondPage.getItems().size()),
|
||||
secondPage.getItems().size() > 10);
|
||||
|
|
Loading…
Reference in a new issue