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