rename UrlIdHandler to UIHFactory

This commit is contained in:
Christian Schabesberger 2018-06-21 17:18:26 +02:00
parent fdf726852e
commit e8ceb3e574
57 changed files with 369 additions and 427 deletions

View File

@ -14,27 +14,27 @@ public abstract class Extractor {
*/
private final StreamingService service;
private final UrlIdHandler urlIdHandler;
private final UIHFactory UIHFactory;
@Nullable
private boolean pageFetched = false;
private final Downloader downloader;
public Extractor(final StreamingService service, final UrlIdHandler urlIdHandler) {
public Extractor(final StreamingService service, final UIHFactory UIHFactory) {
if(service == null) throw new NullPointerException("service is null");
if(urlIdHandler == null) throw new NullPointerException("UrlIdHandler is null");
if(UIHFactory == null) throw new NullPointerException("UIHFactory is null");
this.service = service;
this.urlIdHandler = urlIdHandler;
this.UIHFactory = UIHFactory;
this.downloader = NewPipe.getDownloader();
if(downloader == null) throw new NullPointerException("downloader is null");
}
/**
* @return The {@link UrlIdHandler} of the current extractor object (e.g. a ChannelExtractor should return a channel url handler).
* @return The {@link UIHFactory} of the current extractor object (e.g. a ChannelExtractor should return a channel url handler).
*/
@Nonnull
public UrlIdHandler getUrlIdHandler() {
return urlIdHandler;
public UIHFactory getUIHFactory() {
return UIHFactory;
}
/**
@ -66,7 +66,7 @@ public abstract class Extractor {
@Nonnull
public String getId() throws ParsingException {
return urlIdHandler.getId();
return UIHFactory.getId();
}
/**
@ -79,12 +79,12 @@ public abstract class Extractor {
@Nonnull
public String getOriginalUrl() throws ParsingException {
return urlIdHandler.getOriginalUrl();
return UIHFactory.getOriginalUrl();
}
@Nonnull
public String getUrl() throws ParsingException {
return urlIdHandler.getUrl();
return UIHFactory.getUrl();
}
@Nonnull

View File

@ -18,7 +18,7 @@ public abstract class Info implements Serializable {
/**
* Different than the {@link #originalUrl} in the sense that it <i>may</i> be set as a cleaned url.
*
* @see UrlIdHandler#getUrl()
* @see UIHFactory#getUrl()
* @see Extractor#getOriginalUrl()
*/
private final String url;
@ -48,11 +48,11 @@ public abstract class Info implements Serializable {
this.name = name;
}
public Info(int serviceId, UrlIdHandler urlIdHandler, String name) throws ParsingException {
public Info(int serviceId, UIHFactory UIHFactory, String name) throws ParsingException {
this(serviceId,
urlIdHandler.getId(),
urlIdHandler.getUrl(),
urlIdHandler.getOriginalUrl(),
UIHFactory.getId(),
UIHFactory.getUrl(),
UIHFactory.getOriginalUrl(),
name);
}

View File

@ -12,7 +12,7 @@ import java.util.List;
*/
public abstract class ListExtractor<R extends InfoItem> extends Extractor {
public ListExtractor(StreamingService service, ListUrlIdHandler urlIdHandler) {
public ListExtractor(StreamingService service, ListUIHFactory urlIdHandler) {
super(service, urlIdHandler);
}
@ -50,8 +50,8 @@ public abstract class ListExtractor<R extends InfoItem> extends Extractor {
}
@Override
public ListUrlIdHandler getUrlIdHandler() {
return (ListUrlIdHandler) super.getUrlIdHandler();
public ListUIHFactory getUIHFactory() {
return (ListUIHFactory) super.getUIHFactory();
}
/*//////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,5 @@
package org.schabi.newpipe.extractor;
import com.sun.org.apache.xerces.internal.xs.StringList;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.util.ArrayList;
@ -24,7 +23,7 @@ public abstract class ListInfo<T extends InfoItem> extends Info {
this.sortFilter = sortFilter;
}
public ListInfo(int serviceId, ListUrlIdHandler listUrlIdHandler, String name) throws ParsingException {
public ListInfo(int serviceId, ListUIHFactory listUrlIdHandler, String name) throws ParsingException {
super(serviceId, listUrlIdHandler, name);
this.contentFilter = listUrlIdHandler.getContentFilter();
this.sortFilter = listUrlIdHandler.getSortFilter();

View File

@ -5,14 +5,14 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.util.ArrayList;
import java.util.List;
public abstract class ListUrlIdHandler extends UrlIdHandler {
public abstract class ListUIHFactory extends UIHFactory {
protected List<String> contentFilter = new ArrayList<>(0);
protected String sortFilter = "";
public ListUrlIdHandler setQuery(String id,
List<String> contentFilter,
String sortFilter) throws ParsingException {
public ListUIHFactory setQuery(String id,
List<String> contentFilter,
String sortFilter) throws ParsingException {
setId(id);
this.contentFilter = contentFilter;
this.sortFilter = sortFilter;
@ -20,17 +20,17 @@ public abstract class ListUrlIdHandler extends UrlIdHandler {
}
public ListUrlIdHandler setQuery(String id) throws ParsingException {
public ListUIHFactory setQuery(String id) throws ParsingException {
setQuery(id, new ArrayList<String>(), "");
return this;
}
public ListUrlIdHandler setUrl(String url) throws ParsingException {
return (ListUrlIdHandler) super.setUrl(url);
public ListUIHFactory setUrl(String url) throws ParsingException {
return (ListUIHFactory) super.setUrl(url);
}
public ListUrlIdHandler setId(String id) throws ParsingException {
return (ListUrlIdHandler) super.setId(id);
public ListUIHFactory setId(String id) throws ParsingException {
return (ListUIHFactory) super.setId(id);
}
/**

View File

@ -1,14 +1,12 @@
package org.schabi.newpipe.extractor;
import com.sun.org.apache.xerces.internal.xs.StringList;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.kiosk.KioskList;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.search.SearchEngine;
import org.schabi.newpipe.extractor.search.SearchExtractor;
import org.schabi.newpipe.extractor.search.SearchQueryUrlHandler;
import org.schabi.newpipe.extractor.search.SearchQIHFactory;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
@ -69,51 +67,50 @@ public abstract class StreamingService {
////////////////////////////////////////////
// Url Id handler
////////////////////////////////////////////
public abstract UrlIdHandler getStreamUrlIdHandler();
public abstract ListUrlIdHandler getChannelUrlIdHandler();
public abstract ListUrlIdHandler getPlaylistUrlIdHandler();
public abstract SearchQueryUrlHandler getSearchQueryHandler();
public abstract UIHFactory getStreamUIHFactory();
public abstract ListUIHFactory getChannelUIHFactory();
public abstract ListUIHFactory getPlaylistUIHFactory();
public abstract SearchQIHFactory getSearchQIHFactory();
////////////////////////////////////////////
// Extractor
////////////////////////////////////////////
public abstract SearchEngine getSearchEngine();
public abstract SearchExtractor getSearchExtractor(SearchQueryUrlHandler queryHandler, String contentCountry);
public abstract SearchExtractor getSearchExtractor(SearchQIHFactory queryHandler, String contentCountry);
public abstract SuggestionExtractor getSuggestionExtractor();
public abstract SubscriptionExtractor getSubscriptionExtractor();
public abstract KioskList getKioskList() throws ExtractionException;
public abstract ChannelExtractor getChannelExtractor(ListUrlIdHandler urlIdHandler) throws ExtractionException;
public abstract PlaylistExtractor getPlaylistExtractor(ListUrlIdHandler urlIdHandler) throws ExtractionException;
public abstract StreamExtractor getStreamExtractor(UrlIdHandler urlIdHandler) throws ExtractionException;
public abstract ChannelExtractor getChannelExtractor(ListUIHFactory urlIdHandler) throws ExtractionException;
public abstract PlaylistExtractor getPlaylistExtractor(ListUIHFactory urlIdHandler) throws ExtractionException;
public abstract StreamExtractor getStreamExtractor(UIHFactory UIHFactory) throws ExtractionException;
public SearchExtractor getSearchExtractor(String query, List<String> contentFilter, String sortFilter, String contentCountry) throws ExtractionException {
return getSearchExtractor(getSearchQueryHandler().setQuery(query, contentFilter, sortFilter), contentCountry);
return getSearchExtractor(getSearchQIHFactory().setQuery(query, contentFilter, sortFilter), contentCountry);
}
public ChannelExtractor getChannelExtractor(String id, List<String> contentFilter, String sortFilter) throws ExtractionException {
return getChannelExtractor(getChannelUrlIdHandler().setQuery(id, contentFilter, sortFilter));
return getChannelExtractor(getChannelUIHFactory().setQuery(id, contentFilter, sortFilter));
}
public PlaylistExtractor getPlaylistExtractor(String id, List<String> contentFilter, String sortFilter) throws ExtractionException {
return getPlaylistExtractor(getPlaylistUrlIdHandler().setQuery(id, contentFilter, sortFilter));
return getPlaylistExtractor(getPlaylistUIHFactory().setQuery(id, contentFilter, sortFilter));
}
public SearchExtractor getSearchExtractor(String query, String contentCountry) throws ExtractionException {
return getSearchExtractor(getSearchQueryHandler().setQuery(query), contentCountry);
return getSearchExtractor(getSearchQIHFactory().setQuery(query), contentCountry);
}
public ChannelExtractor getChannelExtractor(String url) throws ExtractionException {
return getChannelExtractor(getChannelUrlIdHandler().setUrl(url));
return getChannelExtractor(getChannelUIHFactory().setUrl(url));
}
public PlaylistExtractor getPlaylistExtractor(String url) throws ExtractionException {
return getPlaylistExtractor(getPlaylistUrlIdHandler().setUrl(url));
return getPlaylistExtractor(getPlaylistUIHFactory().setUrl(url));
}
public StreamExtractor getStreamExtractor(String url) throws ExtractionException {
return getStreamExtractor(getStreamUrlIdHandler().setUrl(url));
return getStreamExtractor(getStreamUIHFactory().setUrl(url));
}
@ -122,9 +119,9 @@ public abstract class StreamingService {
* figure out where the link is pointing to (a channel, video, playlist, etc.)
*/
public final LinkType getLinkTypeByUrl(String url) throws ParsingException {
UrlIdHandler sH = getStreamUrlIdHandler();
UrlIdHandler cH = getChannelUrlIdHandler();
UrlIdHandler pH = getPlaylistUrlIdHandler();
UIHFactory sH = getStreamUIHFactory();
UIHFactory cH = getChannelUIHFactory();
UIHFactory pH = getPlaylistUIHFactory();
if (sH.acceptUrl(url)) {
return LinkType.STREAM;

View File

@ -1,13 +1,12 @@
package org.schabi.newpipe.extractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
/*
* Created by Christian Schabesberger on 26.07.16.
*
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
* UrlIdHandler.java is part of NewPipe.
* UIHFactory.java is part of NewPipe.
*
* NewPipe is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,7 +22,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
public abstract class UrlIdHandler {
public abstract class UIHFactory {
protected String id = "";
protected String originalUrl = "";
@ -33,14 +32,14 @@ public abstract class UrlIdHandler {
public abstract boolean onAcceptUrl(final String url) throws ParsingException;
public UrlIdHandler setUrl(String url) throws ParsingException {
public UIHFactory setUrl(String url) throws ParsingException {
if(url == null) throw new IllegalArgumentException("url can not be null");
originalUrl = url;
id = onGetIdFromUrl(url);
return this;
}
public UrlIdHandler setId(String id) throws ParsingException {
public UIHFactory setId(String id) throws ParsingException {
if(id == null) throw new IllegalArgumentException("id can not be null");
this.id = id;
if(!acceptUrl(getUrl())) {

View File

@ -1,15 +1,11 @@
package org.schabi.newpipe.extractor.channel;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import javax.annotation.Nonnull;
/*
* Created by Christian Schabesberger on 25.07.16.
*
@ -32,7 +28,7 @@ import javax.annotation.Nonnull;
public abstract class ChannelExtractor extends ListExtractor<StreamInfoItem> {
public ChannelExtractor(StreamingService service, ListUrlIdHandler urlIdHandler) {
public ChannelExtractor(StreamingService service, ListUIHFactory urlIdHandler) {
super(service, urlIdHandler);
}

View File

@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.channel;
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
import org.schabi.newpipe.extractor.ListInfo;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
@ -34,7 +34,7 @@ import java.io.IOException;
public class ChannelInfo extends ListInfo<StreamInfoItem> {
public ChannelInfo(int serviceId, ListUrlIdHandler urlIdHandler, String name) throws ParsingException {
public ChannelInfo(int serviceId, ListUIHFactory urlIdHandler, String name) throws ParsingException {
super(serviceId, urlIdHandler, name);
}
@ -55,7 +55,7 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
public static ChannelInfo getInfo(ChannelExtractor extractor) throws IOException, ExtractionException {
ChannelInfo info = new ChannelInfo(extractor.getServiceId(),
extractor.getUrlIdHandler(),
extractor.getUIHFactory(),
extractor.getName());

View File

@ -21,9 +21,8 @@ package org.schabi.newpipe.extractor.kiosk;
*/
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
@ -34,7 +33,7 @@ public abstract class KioskExtractor extends ListExtractor<StreamInfoItem> {
private final String id;
public KioskExtractor(StreamingService streamingService,
ListUrlIdHandler urlIdHandler,
ListUIHFactory urlIdHandler,
String kioskId) {
super(streamingService, urlIdHandler);
this.id = kioskId;

View File

@ -30,7 +30,7 @@ import java.io.IOException;
public class KioskInfo extends ListInfo<StreamInfoItem> {
private KioskInfo(int serviceId, ListUrlIdHandler urlIdHandler, String name) throws ParsingException {
private KioskInfo(int serviceId, ListUIHFactory urlIdHandler, String name) throws ParsingException {
super(serviceId, urlIdHandler, name);
}
@ -67,7 +67,7 @@ public class KioskInfo extends ListInfo<StreamInfoItem> {
public static KioskInfo getInfo(KioskExtractor extractor) throws ExtractionException {
final KioskInfo info = new KioskInfo(extractor.getServiceId(),
extractor.getUrlIdHandler(),
extractor.getUIHFactory(),
extractor.getName());
final ListExtractor.InfoItemsPage<StreamInfoItem> itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor);

View File

@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.kiosk;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.UIHFactory;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import java.io.IOException;
@ -23,19 +23,19 @@ public class KioskList {
private String defaultKiosk = null;
private class KioskEntry {
public KioskEntry(KioskExtractorFactory ef, UrlIdHandler h) {
public KioskEntry(KioskExtractorFactory ef, UIHFactory h) {
extractorFactory = ef;
handler = h;
}
final KioskExtractorFactory extractorFactory;
final UrlIdHandler handler;
final UIHFactory handler;
}
public KioskList(int service_id) {
this.service_id = service_id;
}
public void addKioskEntry(KioskExtractorFactory extractorFactory, UrlIdHandler handler, String id)
public void addKioskEntry(KioskExtractorFactory extractorFactory, UIHFactory handler, String id)
throws Exception {
if(kioskList.get(id) != null) {
throw new Exception("Kiosk with type " + id + " already exists.");
@ -92,7 +92,7 @@ public class KioskList {
throw new ExtractionException("Could not find a kiosk that fits to the url: " + url);
}
public UrlIdHandler getUrlIdHandlerByType(String type) {
public UIHFactory getUrlIdHandlerByType(String type) {
return kioskList.get(type).handler;
}
}

View File

@ -1,18 +1,14 @@
package org.schabi.newpipe.extractor.playlist;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import javax.annotation.Nonnull;
public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
public PlaylistExtractor(StreamingService service, ListUrlIdHandler urlIdHandler) {
public PlaylistExtractor(StreamingService service, ListUIHFactory urlIdHandler) {
super(service, urlIdHandler);
}

View File

@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.playlist;
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
import org.schabi.newpipe.extractor.ListInfo;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
@ -14,7 +14,7 @@ import java.io.IOException;
public class PlaylistInfo extends ListInfo<StreamInfoItem> {
public PlaylistInfo(int serviceId, ListUrlIdHandler urlIdHandler, String name) throws ParsingException {
public PlaylistInfo(int serviceId, ListUIHFactory urlIdHandler, String name) throws ParsingException {
super(serviceId, urlIdHandler, name);
}
@ -41,7 +41,7 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
final PlaylistInfo info = new PlaylistInfo(
extractor.getServiceId(),
extractor.getUrlIdHandler(),
extractor.getUIHFactory(),
extractor.getName());
try {

View File

@ -17,14 +17,14 @@ public abstract class SearchExtractor extends ListExtractor<InfoItem> {
private final InfoItemsSearchCollector collector;
private final String contentCountry;
public SearchExtractor(StreamingService service, SearchQueryUrlHandler urlIdHandler, String contentCountry) {
public SearchExtractor(StreamingService service, SearchQIHFactory urlIdHandler, String contentCountry) {
super(service, urlIdHandler);
collector = new InfoItemsSearchCollector(service.getServiceId());
this.contentCountry = contentCountry;
}
public String getSearchString() {
return getUrlIdHandler().getSearchString();
return getUIHFactory().getSearchString();
}
public abstract String getSearchSuggestion() throws ParsingException;
@ -34,13 +34,13 @@ public abstract class SearchExtractor extends ListExtractor<InfoItem> {
}
@Override
public SearchQueryUrlHandler getUrlIdHandler() {
return (SearchQueryUrlHandler) super.getUrlIdHandler();
public SearchQIHFactory getUIHFactory() {
return (SearchQIHFactory) super.getUIHFactory();
}
@Override
public String getName() {
return getUrlIdHandler().getSearchString();
return getUIHFactory().getSearchString();
}
protected String getContentCountry() {

View File

@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.search;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListInfo;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
@ -13,7 +13,7 @@ public class SearchInfo extends ListInfo<InfoItem> {
public SearchInfo(int serviceId,
ListUrlIdHandler urlIdHandler,
ListUIHFactory urlIdHandler,
String searchString) throws ParsingException {
super(serviceId, urlIdHandler, "Search");
this.searchString = searchString;
@ -23,7 +23,7 @@ public class SearchInfo extends ListInfo<InfoItem> {
public static SearchInfo getInfo(SearchExtractor extractor) throws ExtractionException {
final SearchInfo info = new SearchInfo(
extractor.getServiceId(),
extractor.getUrlIdHandler(),
extractor.getUIHFactory(),
extractor.getSearchString());
try {

View File

@ -0,0 +1,44 @@
package org.schabi.newpipe.extractor.search;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.util.List;
public abstract class SearchQIHFactory extends ListUIHFactory {
@Override
public String onGetIdFromUrl(String url) {
return "Search";
}
public String getSearchString() {
return getId();
}
@Override
public SearchQIHFactory setQuery(String querry,
List<String> contentFilter,
String sortFilter) throws ParsingException {
return (SearchQIHFactory) super.setQuery(querry, contentFilter, sortFilter);
}
@Override
public SearchQIHFactory setQuery(String querry) throws ParsingException {
return (SearchQIHFactory) super.setQuery(querry);
}
@Override
public boolean onAcceptUrl(String url) {
return false;
}
public SearchQIHFactory setId(String query) throws ParsingException {
if(query == null) throw new IllegalArgumentException("id can not be null");
this.id = query;
return this;
}
}

View File

@ -1,44 +0,0 @@
package org.schabi.newpipe.extractor.search;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.util.List;
public abstract class SearchQueryUrlHandler extends ListUrlIdHandler {
@Override
public String onGetIdFromUrl(String url) {
return "Search";
}
public String getSearchString() {
return getId();
}
@Override
public SearchQueryUrlHandler setQuery(String querry,
List<String> contentFilter,
String sortFilter) throws ParsingException {
return (SearchQueryUrlHandler) super.setQuery(querry, contentFilter, sortFilter);
}
@Override
public SearchQueryUrlHandler setQuery(String querry) throws ParsingException {
return (SearchQueryUrlHandler) super.setQuery(querry);
}
@Override
public boolean onAcceptUrl(String url) {
return false;
}
public SearchQueryUrlHandler setId(String query) throws ParsingException {
if(query == null) throw new IllegalArgumentException("id can not be null");
this.id = query;
return this;
}
}

View File

@ -5,7 +5,7 @@ import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException;
import org.schabi.newpipe.extractor.Downloader;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
@ -16,8 +16,6 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
import javax.annotation.Nonnull;
import java.io.IOException;
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
@SuppressWarnings("WeakerAccess")
public class SoundcloudChannelExtractor extends ChannelExtractor {
private String userId;
@ -26,14 +24,14 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
private StreamInfoItemsCollector streamInfoItemsCollector = null;
private String nextPageUrl = null;
public SoundcloudChannelExtractor(StreamingService service, ListUrlIdHandler urlIdHandler) {
public SoundcloudChannelExtractor(StreamingService service, ListUIHFactory urlIdHandler) {
super(service, urlIdHandler);
}
@Override
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
userId = getUrlIdHandler().getId();
userId = getUIHFactory().getId();
String apiUrl = "https://api-v2.soundcloud.com/users/" + userId +
"?client_id=" + SoundcloudParsingHelper.clientId();

View File

@ -1,22 +1,16 @@
package org.schabi.newpipe.extractor.services.soundcloud;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.utils.Parser;
import org.schabi.newpipe.extractor.utils.Utils;
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
public class SoundcloudChannelUrlIdHandler extends ListUrlIdHandler {
private static final SoundcloudChannelUrlIdHandler instance = new SoundcloudChannelUrlIdHandler();
public class SoundcloudChannelUIHFactory extends ListUIHFactory {
private static final SoundcloudChannelUIHFactory instance = new SoundcloudChannelUIHFactory();
private final String URL_PATTERN = "^https?://(www\\.|m\\.)?soundcloud.com/[0-9a-z_-]+" +
"(/((tracks|albums|sets|reposts|followers|following)/?)?)?([#?].*)?$";
public static SoundcloudChannelUrlIdHandler getInstance() {
public static SoundcloudChannelUIHFactory getInstance() {
return instance;
}

View File

@ -1,9 +1,8 @@
package org.schabi.newpipe.extractor.services.soundcloud;
import org.schabi.newpipe.extractor.Downloader;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
@ -18,7 +17,7 @@ public class SoundcloudChartsExtractor extends KioskExtractor {
private StreamInfoItemsCollector collector = null;
private String nextPageUrl = null;
public SoundcloudChartsExtractor(StreamingService service, ListUrlIdHandler urlIdHandler, String kioskId) {
public SoundcloudChartsExtractor(StreamingService service, ListUIHFactory urlIdHandler, String kioskId) {
super(service, urlIdHandler, kioskId);
}

View File

@ -1,11 +1,9 @@
package org.schabi.newpipe.extractor.services.soundcloud;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.utils.Parser;
public class SoundcloudChartsUrlIdHandler extends ListUrlIdHandler {
public class SoundcloudChartsUIHFactory extends ListUIHFactory {
private final String TOP_URL_PATTERN = "^https?://(www\\.|m\\.)?soundcloud.com/charts(/top)?/?([#?].*)?$";
private final String URL_PATTERN = "^https?://(www\\.|m\\.)?soundcloud.com/charts(/top|/new)?/?([#?].*)?$";

View File

@ -4,7 +4,7 @@ import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException;
import org.schabi.newpipe.extractor.Downloader;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
@ -15,8 +15,6 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
import javax.annotation.Nonnull;
import java.io.IOException;
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
@SuppressWarnings("WeakerAccess")
public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
private String playlistId;
@ -25,14 +23,14 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
private StreamInfoItemsCollector streamInfoItemsCollector = null;
private String nextPageUrl = null;
public SoundcloudPlaylistExtractor(StreamingService service, ListUrlIdHandler urlIdHandler) {
public SoundcloudPlaylistExtractor(StreamingService service, ListUIHFactory urlIdHandler) {
super(service, urlIdHandler);
}
@Override
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
playlistId = getUrlIdHandler().getId();
playlistId = getUIHFactory().getId();
String apiUrl = "https://api.soundcloud.com/playlists/" + playlistId +
"?client_id=" + SoundcloudParsingHelper.clientId() +
"&representation=compact";

View File

@ -1,16 +1,16 @@
package org.schabi.newpipe.extractor.services.soundcloud;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.utils.Parser;
import org.schabi.newpipe.extractor.utils.Utils;
public class SoundcloudPlaylistUrlIdHandler extends ListUrlIdHandler {
private static final SoundcloudPlaylistUrlIdHandler instance = new SoundcloudPlaylistUrlIdHandler();
public class SoundcloudPlaylistUIHFactory extends ListUIHFactory {
private static final SoundcloudPlaylistUIHFactory instance = new SoundcloudPlaylistUIHFactory();
private final String URL_PATTERN = "^https?://(www\\.|m\\.)?soundcloud.com/[0-9a-z_-]+" +
"/sets/[0-9a-z_-]+/?([#?].*)?$";
public static SoundcloudPlaylistUrlIdHandler getInstance() {
public static SoundcloudPlaylistUIHFactory getInstance() {
return instance;
}

View File

@ -10,7 +10,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.search.InfoItemsSearchCollector;
import org.schabi.newpipe.extractor.search.SearchEngine;
import org.schabi.newpipe.extractor.search.SearchExtractor;
import org.schabi.newpipe.extractor.search.SearchQueryUrlHandler;
import org.schabi.newpipe.extractor.search.SearchQIHFactory;
import org.schabi.newpipe.extractor.utils.Parser;
import javax.annotation.Nonnull;
@ -19,14 +19,14 @@ import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchQueryUrlHandler.ITEMS_PER_PAGE;
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchQIHFactory.ITEMS_PER_PAGE;
public class SoundcloudSearchExtractor extends SearchExtractor {
private JsonArray searchCollection;
public SoundcloudSearchExtractor(StreamingService service,
SearchQueryUrlHandler urlIdHandler,
SearchQIHFactory urlIdHandler,
String contentCountry) {
super(service, urlIdHandler, contentCountry);
}

View File

@ -2,13 +2,13 @@ package org.schabi.newpipe.extractor.services.soundcloud;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
import org.schabi.newpipe.extractor.search.SearchQueryUrlHandler;
import org.schabi.newpipe.extractor.search.SearchQIHFactory;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class SoundcloudSearchQueryUrlHandler extends SearchQueryUrlHandler {
public class SoundcloudSearchQIHFactory extends SearchQIHFactory {
public static final String CHARSET_UTF_8 = "UTF-8";
public static final String TRACKS = "tracks";

View File

@ -1,9 +1,8 @@
package org.schabi.newpipe.extractor.services.soundcloud;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.SuggestionExtractor;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.*;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.UIHFactory;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
@ -11,7 +10,7 @@ import org.schabi.newpipe.extractor.kiosk.KioskList;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.search.SearchEngine;
import org.schabi.newpipe.extractor.search.SearchExtractor;
import org.schabi.newpipe.extractor.search.SearchQueryUrlHandler;
import org.schabi.newpipe.extractor.search.SearchQIHFactory;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
@ -25,48 +24,43 @@ public class SoundcloudService extends StreamingService {
}
@Override
public SearchEngine getSearchEngine() {
return new SoundcloudSearchEngine(getServiceId());
}
@Override
public SearchExtractor getSearchExtractor(SearchQueryUrlHandler queryHandler, String contentCountry) {
public SearchExtractor getSearchExtractor(SearchQIHFactory queryHandler, String contentCountry) {
return new SoundcloudSearchExtractor(this, queryHandler, contentCountry);
}
@Override
public SearchQueryUrlHandler getSearchQueryHandler() {
return new SoundcloudSearchQueryUrlHandler();
public SearchQIHFactory getSearchQIHFactory() {
return new SoundcloudSearchQIHFactory();
}
@Override
public UrlIdHandler getStreamUrlIdHandler() {
return SoundcloudStreamUrlIdHandler.getInstance();
public UIHFactory getStreamUIHFactory() {
return SoundcloudStreamUIHFactory.getInstance();
}
@Override
public ListUrlIdHandler getChannelUrlIdHandler() {
return SoundcloudChannelUrlIdHandler.getInstance();
public ListUIHFactory getChannelUIHFactory() {
return SoundcloudChannelUIHFactory.getInstance();
}
@Override
public ListUrlIdHandler getPlaylistUrlIdHandler() {
return SoundcloudPlaylistUrlIdHandler.getInstance();
public ListUIHFactory getPlaylistUIHFactory() {
return SoundcloudPlaylistUIHFactory.getInstance();
}
@Override
public StreamExtractor getStreamExtractor(UrlIdHandler urlIdHandler) {
return new SoundcloudStreamExtractor(this, urlIdHandler);
public StreamExtractor getStreamExtractor(UIHFactory UIHFactory) {
return new SoundcloudStreamExtractor(this, UIHFactory);
}
@Override
public ChannelExtractor getChannelExtractor(ListUrlIdHandler urlIdHandler) {
public ChannelExtractor getChannelExtractor(ListUIHFactory urlIdHandler) {
return new SoundcloudChannelExtractor(this, urlIdHandler);
}
@Override
public PlaylistExtractor getPlaylistExtractor(ListUrlIdHandler urlIdHandler) {
public PlaylistExtractor getPlaylistExtractor(ListUIHFactory urlIdHandler) {
return new SoundcloudPlaylistExtractor(this, urlIdHandler);
}
@ -84,14 +78,14 @@ public class SoundcloudService extends StreamingService {
String id)
throws ExtractionException {
return new SoundcloudChartsExtractor(SoundcloudService.this,
new SoundcloudChartsUrlIdHandler().setUrl(url), id);
new SoundcloudChartsUIHFactory().setUrl(url), id);
}
};
KioskList list = new KioskList(getServiceId());
// add kiosks here e.g.:
final SoundcloudChartsUrlIdHandler h = new SoundcloudChartsUrlIdHandler();
final SoundcloudChartsUIHFactory h = new SoundcloudChartsUIHFactory();
try {
list.addKioskEntry(chartsFactory, h, "Top 50");
list.addKioskEntry(chartsFactory, h, "New & hot");

View File

@ -17,13 +17,11 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
public class SoundcloudStreamExtractor extends StreamExtractor {
private JsonObject track;
public SoundcloudStreamExtractor(StreamingService service, UrlIdHandler urlIdHandler) {
super(service, urlIdHandler);
public SoundcloudStreamExtractor(StreamingService service, UIHFactory UIHFactory) {
super(service, UIHFactory);
}
@Override

View File

@ -1,24 +1,19 @@
package org.schabi.newpipe.extractor.services.soundcloud;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.UIHFactory;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.utils.Parser;
import org.schabi.newpipe.extractor.utils.Utils;
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
public class SoundcloudStreamUrlIdHandler extends UrlIdHandler {
private static final SoundcloudStreamUrlIdHandler instance = new SoundcloudStreamUrlIdHandler();
public class SoundcloudStreamUIHFactory extends UIHFactory {
private static final SoundcloudStreamUIHFactory instance = new SoundcloudStreamUIHFactory();
private final String URL_PATTERN = "^https?://(www\\.|m\\.)?soundcloud.com/[0-9a-z_-]+" +
"/(?!(tracks|albums|sets|reposts|followers|following)/?$)[0-9a-z_-]+/?([#?].*)?$";
private SoundcloudStreamUrlIdHandler() {
private SoundcloudStreamUIHFactory() {
}
public static SoundcloudStreamUrlIdHandler getInstance() {
public static SoundcloudStreamUIHFactory getInstance() {
return instance;
}

View File

@ -31,7 +31,7 @@ public class SoundcloudSubscriptionExtractor extends SubscriptionExtractor {
String id;
try {
id = service.getChannelUrlIdHandler().setUrl(getUrlFrom(channelUrl)).getId();
id = service.getChannelUIHFactory().setUrl(getUrlFrom(channelUrl)).getId();
} catch (ExtractionException e) {
throw new InvalidSourceException(e);
}

View File

@ -1,9 +1,8 @@
package org.schabi.newpipe.extractor.services.youtube;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.SuggestionExtractor;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.*;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.UIHFactory;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
@ -11,7 +10,7 @@ import org.schabi.newpipe.extractor.kiosk.KioskList;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.search.SearchEngine;
import org.schabi.newpipe.extractor.search.SearchExtractor;
import org.schabi.newpipe.extractor.search.SearchQueryUrlHandler;
import org.schabi.newpipe.extractor.search.SearchQIHFactory;
import org.schabi.newpipe.extractor.services.youtube.extractors.*;
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.*;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
@ -48,47 +47,42 @@ public class YoutubeService extends StreamingService {
}
@Override
public SearchEngine getSearchEngine() {
return new YoutubeSearchEngine(getServiceId());
}
@Override
public SearchExtractor getSearchExtractor(SearchQueryUrlHandler query, String contentCountry) {
public SearchExtractor getSearchExtractor(SearchQIHFactory query, String contentCountry) {
return new YoutubeSearchExtractor(this, query, contentCountry);
}
@Override
public UrlIdHandler getStreamUrlIdHandler() {
return YoutubeStreamUrlIdHandler.getInstance();
public UIHFactory getStreamUIHFactory() {
return YoutubeStreamUIHFactory.getInstance();
}
@Override
public ListUrlIdHandler getChannelUrlIdHandler() {
return YoutubeChannelUrlIdHandler.getInstance();
public ListUIHFactory getChannelUIHFactory() {
return YoutubeChannelUIHFactory.getInstance();
}
@Override
public ListUrlIdHandler getPlaylistUrlIdHandler() {
return YoutubePlaylistUrlIdHandler.getInstance();
public ListUIHFactory getPlaylistUIHFactory() {
return YoutubePlaylistUIHFactory.getInstance();
}
@Override
public SearchQueryUrlHandler getSearchQueryHandler() {
return YoutubeSearchQueryUrlHandler.getInstance();
public SearchQIHFactory getSearchQIHFactory() {
return YoutubeSearchQIHFactory.getInstance();
}
@Override
public StreamExtractor getStreamExtractor(UrlIdHandler urlIdHandler) throws ExtractionException {
return new YoutubeStreamExtractor(this, urlIdHandler);
public StreamExtractor getStreamExtractor(UIHFactory UIHFactory) throws ExtractionException {
return new YoutubeStreamExtractor(this, UIHFactory);
}
@Override
public ChannelExtractor getChannelExtractor(ListUrlIdHandler urlIdHandler) throws ExtractionException {
public ChannelExtractor getChannelExtractor(ListUIHFactory urlIdHandler) throws ExtractionException {
return new YoutubeChannelExtractor(this, urlIdHandler);
}
@Override
public PlaylistExtractor getPlaylistExtractor(ListUrlIdHandler urlIdHandler) throws ExtractionException {
public PlaylistExtractor getPlaylistExtractor(ListUIHFactory urlIdHandler) throws ExtractionException {
return new YoutubePlaylistExtractor(this, urlIdHandler);
}
@ -108,9 +102,9 @@ public class YoutubeService extends StreamingService {
public KioskExtractor createNewKiosk(StreamingService streamingService, String url, String id)
throws ExtractionException {
return new YoutubeTrendingExtractor(YoutubeService.this,
new YoutubeTrendingUrlIdHandler().setUrl(url), id);
new YoutubeTrendingUIHFactory().setUrl(url), id);
}
}, new YoutubeTrendingUrlIdHandler(), "Trending");
}, new YoutubeTrendingUIHFactory(), "Trending");
list.setDefaultKiosk("Trending");
} catch (Exception e) {
throw new ExtractionException(e);

View File

@ -48,7 +48,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
private Document doc;
public YoutubeChannelExtractor(StreamingService service, ListUrlIdHandler urlIdHandler) {
public YoutubeChannelExtractor(StreamingService service, ListUIHFactory urlIdHandler) {
super(service, urlIdHandler);
}

View File

@ -19,14 +19,12 @@ import org.schabi.newpipe.extractor.utils.Utils;
import javax.annotation.Nonnull;
import java.io.IOException;
import static org.schabi.newpipe.extractor.NewPipe.getDownloader;
@SuppressWarnings("WeakerAccess")
public class YoutubePlaylistExtractor extends PlaylistExtractor {
private Document doc;
public YoutubePlaylistExtractor(StreamingService service, ListUrlIdHandler urlIdHandler) throws ExtractionException {
public YoutubePlaylistExtractor(StreamingService service, ListUIHFactory urlIdHandler) throws ExtractionException {
super(service, urlIdHandler);
}
@ -175,7 +173,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
private void collectStreamsFrom(StreamInfoItemsCollector collector, Element element) throws ParsingException {
collector.reset();
final UrlIdHandler streamUrlIdHandler = getService().getStreamUrlIdHandler();
final UIHFactory streamUIHFactory = getService().getStreamUIHFactory();
for (final Element li : element.children()) {
if(isDeletedItem(li)) {
continue;
@ -192,7 +190,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
@Override
public String getUrl() throws ParsingException {
try {
return streamUrlIdHandler.setId(li.attr("data-video-id")).getUrl();
return streamUIHFactory.setId(li.attr("data-video-id")).getUrl();
} catch (Exception e) {
throw new ParsingException("Could not get web page url for the video", e);
}
@ -257,7 +255,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
@Override
public String getThumbnailUrl() throws ParsingException {
try {
return "https://i.ytimg.com/vi/" + streamUrlIdHandler.setUrl(getUrl()).getId() + "/hqdefault.jpg";
return "https://i.ytimg.com/vi/" + streamUIHFactory.setUrl(getUrl()).getId() + "/hqdefault.jpg";
} catch (Exception e) {
throw new ParsingException("Could not get thumbnail url", e);
}

View File

@ -5,15 +5,12 @@ import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.schabi.newpipe.extractor.Downloader;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.InfoItemsCollector;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.search.InfoItemsSearchCollector;
import org.schabi.newpipe.extractor.search.SearchEngine;
import org.schabi.newpipe.extractor.search.SearchExtractor;
import org.schabi.newpipe.extractor.search.SearchQueryUrlHandler;
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeSearchQueryUrlHandler;
import org.schabi.newpipe.extractor.search.SearchQIHFactory;
import org.schabi.newpipe.extractor.utils.Parser;
import javax.annotation.Nonnull;
@ -27,7 +24,7 @@ public class YoutubeSearchExtractor extends SearchExtractor {
private Document doc;
public YoutubeSearchExtractor(StreamingService service,
SearchQueryUrlHandler urlIdHandler,
SearchQIHFactory urlIdHandler,
String contentCountry) {
super(service, urlIdHandler, contentCountry);
}

View File

@ -84,8 +84,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
private boolean isAgeRestricted;
public YoutubeStreamExtractor(StreamingService service, UrlIdHandler urlIdHandler) throws ExtractionException {
super(service, urlIdHandler);
public YoutubeStreamExtractor(StreamingService service, UIHFactory UIHFactory) throws ExtractionException {
super(service, UIHFactory);
}
/*//////////////////////////////////////////////////////////////////////////

View File

@ -25,13 +25,11 @@ import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.schabi.newpipe.extractor.Downloader;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeTrendingUrlIdHandler;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
@ -42,7 +40,7 @@ public class YoutubeTrendingExtractor extends KioskExtractor {
private Document doc;
public YoutubeTrendingExtractor(StreamingService service, ListUrlIdHandler urlIdHandler, String kioskId)
public YoutubeTrendingExtractor(StreamingService service, ListUIHFactory urlIdHandler, String kioskId)
throws ExtractionException {
super(service, urlIdHandler, kioskId);
}

View File

@ -1,6 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube.urlIdHandlers;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.utils.Parser;
@ -8,7 +8,7 @@ import org.schabi.newpipe.extractor.utils.Parser;
* Created by Christian Schabesberger on 25.07.16.
*
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
* YoutubeChannelUrlIdHandler.java is part of NewPipe.
* YoutubeChannelUIHFactory.java is part of NewPipe.
*
* NewPipe is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -24,12 +24,12 @@ import org.schabi.newpipe.extractor.utils.Parser;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
public class YoutubeChannelUrlIdHandler extends ListUrlIdHandler {
public class YoutubeChannelUIHFactory extends ListUIHFactory {
private static final YoutubeChannelUrlIdHandler instance = new YoutubeChannelUrlIdHandler();
private static final YoutubeChannelUIHFactory instance = new YoutubeChannelUIHFactory();
private static final String ID_PATTERN = "/(user/[A-Za-z0-9_-]*|channel/[A-Za-z0-9_-]*)";
public static YoutubeChannelUrlIdHandler getInstance() {
public static YoutubeChannelUIHFactory getInstance() {
return instance;
}

View File

@ -1,16 +1,16 @@
package org.schabi.newpipe.extractor.services.youtube.urlIdHandlers;
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.utils.Parser;
public class YoutubePlaylistUrlIdHandler extends ListUrlIdHandler {
public class YoutubePlaylistUIHFactory extends ListUIHFactory {
private static final YoutubePlaylistUrlIdHandler instance = new YoutubePlaylistUrlIdHandler();
private static final YoutubePlaylistUIHFactory instance = new YoutubePlaylistUIHFactory();
private static final String ID_PATTERN = "([\\-a-zA-Z0-9_]{10,})";
public static YoutubePlaylistUrlIdHandler getInstance() {
public static YoutubePlaylistUIHFactory getInstance() {
return instance;
}

View File

@ -1,12 +1,12 @@
package org.schabi.newpipe.extractor.services.youtube.urlIdHandlers;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.search.SearchQueryUrlHandler;
import org.schabi.newpipe.extractor.search.SearchQIHFactory;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class YoutubeSearchQueryUrlHandler extends SearchQueryUrlHandler {
public class YoutubeSearchQIHFactory extends SearchQIHFactory {
public static final String CHARSET_UTF_8 = "UTF-8";
@ -15,8 +15,8 @@ public class YoutubeSearchQueryUrlHandler extends SearchQueryUrlHandler {
public static final String PLAYLIST = "playlist";
public static final String ANY = "any";
public static YoutubeSearchQueryUrlHandler getInstance() {
return new YoutubeSearchQueryUrlHandler();
public static YoutubeSearchQIHFactory getInstance() {
return new YoutubeSearchQIHFactory();
}
@Override

View File

@ -5,7 +5,7 @@ import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.schabi.newpipe.extractor.Downloader;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.UIHFactory;
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
@ -21,7 +21,7 @@ import java.net.URLDecoder;
* Created by Christian Schabesberger on 02.02.16.
*
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
* YoutubeStreamUrlIdHandler.java is part of NewPipe.
* YoutubeStreamUIHFactory.java is part of NewPipe.
*
* NewPipe is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -37,15 +37,15 @@ import java.net.URLDecoder;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
public class YoutubeStreamUrlIdHandler extends UrlIdHandler {
public class YoutubeStreamUIHFactory extends UIHFactory {
private static final YoutubeStreamUrlIdHandler instance = new YoutubeStreamUrlIdHandler();
private static final YoutubeStreamUIHFactory instance = new YoutubeStreamUIHFactory();
private static final String ID_PATTERN = "([\\-a-zA-Z0-9_]{11})";
private YoutubeStreamUrlIdHandler() {
private YoutubeStreamUIHFactory() {
}
public static YoutubeStreamUrlIdHandler getInstance() {
public static YoutubeStreamUIHFactory getInstance() {
return instance;
}

View File

@ -4,7 +4,7 @@ package org.schabi.newpipe.extractor.services.youtube.urlIdHandlers;
* Created by Christian Schabesberger on 12.08.17.
*
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
* YoutubeTrendingUrlIdHandler.java is part of NewPipe.
* YoutubeTrendingUIHFactory.java is part of NewPipe.
*
* NewPipe is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -20,12 +20,10 @@ package org.schabi.newpipe.extractor.services.youtube.urlIdHandlers;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
import org.schabi.newpipe.extractor.ListUrlIdHandler;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.ListUIHFactory;
import org.schabi.newpipe.extractor.utils.Parser;
public class YoutubeTrendingUrlIdHandler extends ListUrlIdHandler {
public class YoutubeTrendingUIHFactory extends ListUIHFactory {
public String getUrl() {
return "https://www.youtube.com/feed/trending";

View File

@ -23,7 +23,7 @@ package org.schabi.newpipe.extractor.stream;
import org.schabi.newpipe.extractor.Extractor;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.Subtitles;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.UIHFactory;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.utils.Parser;
@ -39,8 +39,8 @@ public abstract class StreamExtractor extends Extractor {
public static final int NO_AGE_LIMIT = 0;
public StreamExtractor(StreamingService service, UrlIdHandler urlIdHandler) {
super(service, urlIdHandler);
public StreamExtractor(StreamingService service, UIHFactory UIHFactory) {
super(service, UIHFactory);
}
@Nonnull

View File

@ -15,7 +15,7 @@ import static org.junit.Assert.*;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
/**
* Test for {@link SoundcloudChartsUrlIdHandler}
* Test for {@link SoundcloudChartsUIHFactory}
*/
public class SoundcloudChartsExtractorTest {

View File

@ -11,14 +11,14 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* Test for {@link SoundcloudChartsUrlIdHandler}
* Test for {@link SoundcloudChartsUIHFactory}
*/
public class SoundcloudChartsUrlIdHandlerTest {
private static SoundcloudChartsUrlIdHandler urlIdHandler;
public class SoundcloudChartsUIHFactoryTest {
private static SoundcloudChartsUIHFactory urlIdHandler;
@BeforeClass
public static void setUp() throws Exception {
urlIdHandler = new SoundcloudChartsUrlIdHandler();
urlIdHandler = new SoundcloudChartsUIHFactory();
NewPipe.init(Downloader.getInstance());
}

View File

@ -12,14 +12,14 @@ import java.util.List;
import static org.junit.Assert.*;
/**
* Test for {@link SoundcloudStreamUrlIdHandler}
* Test for {@link SoundcloudStreamUIHFactory}
*/
public class SoundcloudStreamUrlIdHandlerTest {
private static SoundcloudStreamUrlIdHandler urlIdHandler;
public class SoundcloudStreamUIHFactoryTest {
private static SoundcloudStreamUIHFactory urlIdHandler;
@BeforeClass
public static void setUp() throws Exception {
urlIdHandler = SoundcloudStreamUrlIdHandler.getInstance();
urlIdHandler = SoundcloudStreamUIHFactory.getInstance();
NewPipe.init(Downloader.getInstance());
}

View File

@ -5,7 +5,7 @@ import org.junit.Test;
import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.UIHFactory;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
import org.schabi.newpipe.extractor.subscription.SubscriptionItem;
@ -21,13 +21,13 @@ import static org.junit.Assert.*;
*/
public class SoundcloudSubscriptionExtractorTest {
private static SoundcloudSubscriptionExtractor subscriptionExtractor;
private static UrlIdHandler urlHandler;
private static UIHFactory urlHandler;
@BeforeClass
public static void setupClass() {
NewPipe.init(Downloader.getInstance());
subscriptionExtractor = new SoundcloudSubscriptionExtractor(ServiceList.SoundCloud);
urlHandler = ServiceList.SoundCloud.getChannelUrlIdHandler();
urlHandler = ServiceList.SoundCloud.getChannelUIHFactory();
}
@Test

View File

@ -4,7 +4,6 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchExtractor;
import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
@ -19,36 +18,36 @@ public class SoundcloudSearchQUHTest {
@Test
public void testRegularValues() throws Exception {
assertEquals("https://api-v2.soundcloud.com/search?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler().setQuery("asdf").getUrl());
assertEquals("https://api-v2.soundcloud.com/search?q=hans&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0",SoundCloud.getSearchQueryHandler().setQuery("hans").getUrl());
assertEquals("https://api-v2.soundcloud.com/search?q=Poifj%26jaijf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler().setQuery("Poifj&jaijf").getUrl());
assertEquals("https://api-v2.soundcloud.com/search?q=G%C3%BCl%C3%BCm&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler().setQuery("Gülüm").getUrl());
assertEquals("https://api-v2.soundcloud.com/search?q=%3Fj%24%29H%C2%A7B&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler().setQuery("?j$)H§B").getUrl());
assertEquals("https://api-v2.soundcloud.com/search?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory().setQuery("asdf").getUrl());
assertEquals("https://api-v2.soundcloud.com/search?q=hans&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0",SoundCloud.getSearchQIHFactory().setQuery("hans").getUrl());
assertEquals("https://api-v2.soundcloud.com/search?q=Poifj%26jaijf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory().setQuery("Poifj&jaijf").getUrl());
assertEquals("https://api-v2.soundcloud.com/search?q=G%C3%BCl%C3%BCm&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory().setQuery("Gülüm").getUrl());
assertEquals("https://api-v2.soundcloud.com/search?q=%3Fj%24%29H%C2%A7B&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory().setQuery("?j$)H§B").getUrl());
}
@Test
public void testGetContentFilter() throws Exception {
assertEquals("tracks", SoundCloud.getSearchQueryHandler()
assertEquals("tracks", SoundCloud.getSearchQIHFactory()
.setQuery("", asList(new String[]{"tracks"}), "").getContentFilter().get(0));
assertEquals("users", SoundCloud.getSearchQueryHandler()
assertEquals("users", SoundCloud.getSearchQIHFactory()
.setQuery("asdf", asList(new String[]{"users"}), "").getContentFilter().get(0));
}
@Test
public void testWithContentfilter() throws Exception {
assertEquals("https://api-v2.soundcloud.com/search/tracks?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler()
assertEquals("https://api-v2.soundcloud.com/search/tracks?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory()
.setQuery("asdf", asList(new String[]{"tracks"}), "").getUrl());
assertEquals("https://api-v2.soundcloud.com/search/users?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler()
assertEquals("https://api-v2.soundcloud.com/search/users?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory()
.setQuery("asdf", asList(new String[]{"users"}), "").getUrl());
assertEquals("https://api-v2.soundcloud.com/search/playlists?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler()
assertEquals("https://api-v2.soundcloud.com/search/playlists?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory()
.setQuery("asdf", asList(new String[]{"playlist"}), "").getUrl());
assertEquals("https://api-v2.soundcloud.com/search?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler()
assertEquals("https://api-v2.soundcloud.com/search?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory()
.setQuery("asdf", asList(new String[]{"fjiijie"}), "").getUrl());
}
@Test
public void testGetAvailableContentFilter() {
final String[] contentFilter = SoundCloud.getSearchQueryHandler().getAvailableContentFilter();
final String[] contentFilter = SoundCloud.getSearchQIHFactory().getAvailableContentFilter();
assertEquals(4, contentFilter.length);
assertEquals("tracks", contentFilter[0]);
assertEquals("users", contentFilter[1]);
@ -58,7 +57,7 @@ public class SoundcloudSearchQUHTest {
@Test
public void testGetAvailableSortFilter() {
final String[] contentFilter = SoundCloud.getSearchQueryHandler().getAvailableSortFilter();
final String[] contentFilter = SoundCloud.getSearchQIHFactory().getAvailableSortFilter();
assertEquals(0, contentFilter.length);
}
}

View File

@ -5,21 +5,21 @@ import org.junit.Test;
import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeChannelUrlIdHandler;
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeChannelUIHFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* Test for {@link YoutubeChannelUrlIdHandler}
* Test for {@link YoutubeChannelUIHFactory}
*/
public class YoutubeChannelUrlIdHandlerTest {
public class YoutubeChannelUIHFactoryTest {
private static YoutubeChannelUrlIdHandler urlIdHandler;
private static YoutubeChannelUIHFactory urlIdHandler;
@BeforeClass
public static void setUp() {
urlIdHandler = YoutubeChannelUrlIdHandler.getInstance();
urlIdHandler = YoutubeChannelUIHFactory.getInstance();
NewPipe.init(Downloader.getInstance());
}

View File

@ -8,7 +8,7 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeStreamUrlIdHandler;
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeStreamUIHFactory;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.stream.SubtitlesFormat;
import org.schabi.newpipe.extractor.stream.VideoStream;
@ -22,7 +22,7 @@ import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/**
* Test for {@link YoutubeStreamUrlIdHandler}
* Test for {@link YoutubeStreamUIHFactory}
*/
public class YoutubeStreamExtractorControversialTest {
private static YoutubeStreamExtractor extractor;

View File

@ -8,7 +8,7 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeStreamUrlIdHandler;
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeStreamUIHFactory;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.stream.SubtitlesFormat;
import org.schabi.newpipe.extractor.stream.VideoStream;
@ -22,7 +22,7 @@ import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/**
* Test for {@link YoutubeStreamUrlIdHandler}
* Test for {@link YoutubeStreamUIHFactory}
*/
public class YoutubeStreamExtractorRestrictedTest {
public static final String HTTPS = "https://";

View File

@ -6,7 +6,7 @@ import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeStreamUrlIdHandler;
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeStreamUIHFactory;
import java.util.ArrayList;
import java.util.List;
@ -14,15 +14,15 @@ import java.util.List;
import static org.junit.Assert.*;
/**
* Test for {@link YoutubeStreamUrlIdHandler}
* Test for {@link YoutubeStreamUIHFactory}
*/
public class YoutubeStreamUrlIdHandlerTest {
public class YoutubeStreamUIHFactoryTest {
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 YoutubeStreamUrlIdHandler urlIdHandler;
private static YoutubeStreamUIHFactory urlIdHandler;
@BeforeClass
public static void setUp() {
urlIdHandler = YoutubeStreamUrlIdHandler.getInstance();
urlIdHandler = YoutubeStreamUIHFactory.getInstance();
NewPipe.init(Downloader.getInstance());
}

View File

@ -5,7 +5,7 @@ import org.junit.Test;
import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.UIHFactory;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSubscriptionExtractor;
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
import org.schabi.newpipe.extractor.subscription.SubscriptionItem;
@ -23,13 +23,13 @@ import static org.junit.Assert.*;
*/
public class YoutubeSubscriptionExtractorTest {
private static YoutubeSubscriptionExtractor subscriptionExtractor;
private static UrlIdHandler urlHandler;
private static UIHFactory urlHandler;
@BeforeClass
public static void setupClass() {
NewPipe.init(Downloader.getInstance());
subscriptionExtractor = new YoutubeSubscriptionExtractor(ServiceList.YouTube);
urlHandler = ServiceList.YouTube.getChannelUrlIdHandler();
urlHandler = ServiceList.YouTube.getChannelUIHFactory();
}
@Test

View File

@ -26,7 +26,7 @@ import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeTrendingExtractor;
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeTrendingUrlIdHandler;
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeTrendingUIHFactory;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.utils.Utils;
@ -37,7 +37,7 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/**
* Test for {@link YoutubeTrendingUrlIdHandler}
* Test for {@link YoutubeTrendingUIHFactory}
*/
public class YoutubeTrendingExtractorTest {

View File

@ -25,7 +25,7 @@ import org.junit.Test;
import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.UIHFactory;
import org.schabi.newpipe.extractor.kiosk.KioskInfo;
import static org.junit.Assert.assertFalse;
@ -43,9 +43,9 @@ public class YoutubeTrendingKioskInfoTest {
throws Exception {
NewPipe.init(Downloader.getInstance());
StreamingService service = YouTube;
UrlIdHandler urlIdHandler = service.getKioskList().getUrlIdHandlerByType("Trending");
UIHFactory UIHFactory = service.getKioskList().getUrlIdHandlerByType("Trending");
kioskInfo = KioskInfo.getInfo(YouTube, urlIdHandler.setId("Trending").getUrl(), null);
kioskInfo = KioskInfo.getInfo(YouTube, UIHFactory.setId("Trending").getUrl(), null);
}
@Test

View File

@ -0,0 +1,82 @@
package org.schabi.newpipe.extractor.services.youtube;
/*
* Created by Christian Schabesberger on 12.08.17.
*
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
* YoutubeTrendingUIHFactoryTest.java is part of NewPipe.
*
* NewPipe is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NewPipe is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
import org.junit.BeforeClass;
import org.junit.Test;
import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.UIHFactory;
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeTrendingUIHFactory;
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/**
* Test for {@link YoutubeTrendingUIHFactory}
*/
public class YoutubeTrendingUIHFactoryTest {
private static UIHFactory UIHFactory;
@BeforeClass
public static void setUp() throws Exception {
UIHFactory = YouTube.getKioskList().getUrlIdHandlerByType("Trending");
NewPipe.init(Downloader.getInstance());
}
@Test
public void getUrl()
throws Exception {
assertEquals(UIHFactory.setId("").getUrl(), "https://www.youtube.com/feed/trending");
}
@Test
public void getId()
throws Exception {
assertEquals(UIHFactory.setUrl("").getId(), "Trending");
}
@Test
public void acceptUrl() {
assertTrue(UIHFactory.acceptUrl("https://www.youtube.com/feed/trending"));
assertTrue(UIHFactory.acceptUrl("https://www.youtube.com/feed/trending?adsf=fjaj#fhe"));
assertTrue(UIHFactory.acceptUrl("http://www.youtube.com/feed/trending"));
assertTrue(UIHFactory.acceptUrl("www.youtube.com/feed/trending"));
assertTrue(UIHFactory.acceptUrl("youtube.com/feed/trending"));
assertTrue(UIHFactory.acceptUrl("youtube.com/feed/trending?akdsakjf=dfije&kfj=dkjak"));
assertTrue(UIHFactory.acceptUrl("https://youtube.com/feed/trending"));
assertTrue(UIHFactory.acceptUrl("m.youtube.com/feed/trending"));
assertFalse(UIHFactory.acceptUrl("https://youtu.be/feed/trending"));
assertFalse(UIHFactory.acceptUrl("kdskjfiiejfia"));
assertFalse(UIHFactory.acceptUrl("https://www.youtube.com/bullshit/feed/trending"));
assertFalse(UIHFactory.acceptUrl("https://www.youtube.com/feed/trending/bullshit"));
assertFalse(UIHFactory.acceptUrl("https://www.youtube.com/feed/bullshit/trending"));
assertFalse(UIHFactory.acceptUrl("peter klaut aepferl youtube.com/feed/trending"));
assertFalse(UIHFactory.acceptUrl("youtube.com/feed/trending askjkf"));
assertFalse(UIHFactory.acceptUrl("askdjfi youtube.com/feed/trending askjkf"));
assertFalse(UIHFactory.acceptUrl(" youtube.com/feed/trending"));
assertFalse(UIHFactory.acceptUrl("https://www.youtube.com/feed/trending.html"));
assertFalse(UIHFactory.acceptUrl(""));
}
}

View File

@ -1,82 +0,0 @@
package org.schabi.newpipe.extractor.services.youtube;
/*
* Created by Christian Schabesberger on 12.08.17.
*
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
* YoutubeTrendingUrlIdHandlerTest.java is part of NewPipe.
*
* NewPipe is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NewPipe is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
import org.junit.BeforeClass;
import org.junit.Test;
import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeTrendingUrlIdHandler;
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/**
* Test for {@link YoutubeTrendingUrlIdHandler}
*/
public class YoutubeTrendingUrlIdHandlerTest {
private static UrlIdHandler urlIdHandler;
@BeforeClass
public static void setUp() throws Exception {
urlIdHandler = YouTube.getKioskList().getUrlIdHandlerByType("Trending");
NewPipe.init(Downloader.getInstance());
}
@Test
public void getUrl()
throws Exception {
assertEquals(urlIdHandler.setId("").getUrl(), "https://www.youtube.com/feed/trending");
}
@Test
public void getId()
throws Exception {
assertEquals(urlIdHandler.setUrl("").getId(), "Trending");
}
@Test
public void acceptUrl() {
assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/feed/trending"));
assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/feed/trending?adsf=fjaj#fhe"));
assertTrue(urlIdHandler.acceptUrl("http://www.youtube.com/feed/trending"));
assertTrue(urlIdHandler.acceptUrl("www.youtube.com/feed/trending"));
assertTrue(urlIdHandler.acceptUrl("youtube.com/feed/trending"));
assertTrue(urlIdHandler.acceptUrl("youtube.com/feed/trending?akdsakjf=dfije&kfj=dkjak"));
assertTrue(urlIdHandler.acceptUrl("https://youtube.com/feed/trending"));
assertTrue(urlIdHandler.acceptUrl("m.youtube.com/feed/trending"));
assertFalse(urlIdHandler.acceptUrl("https://youtu.be/feed/trending"));
assertFalse(urlIdHandler.acceptUrl("kdskjfiiejfia"));
assertFalse(urlIdHandler.acceptUrl("https://www.youtube.com/bullshit/feed/trending"));
assertFalse(urlIdHandler.acceptUrl("https://www.youtube.com/feed/trending/bullshit"));
assertFalse(urlIdHandler.acceptUrl("https://www.youtube.com/feed/bullshit/trending"));
assertFalse(urlIdHandler.acceptUrl("peter klaut aepferl youtube.com/feed/trending"));
assertFalse(urlIdHandler.acceptUrl("youtube.com/feed/trending askjkf"));
assertFalse(urlIdHandler.acceptUrl("askdjfi youtube.com/feed/trending askjkf"));
assertFalse(urlIdHandler.acceptUrl(" youtube.com/feed/trending"));
assertFalse(urlIdHandler.acceptUrl("https://www.youtube.com/feed/trending.html"));
assertFalse(urlIdHandler.acceptUrl(""));
}
}

View File

@ -2,8 +2,6 @@ package org.schabi.newpipe.extractor.services.youtube.search;
import org.junit.Test;
import java.util.ArrayList;
import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
@ -12,36 +10,36 @@ public class YoutubeSearchQUHTest {
@Test
public void testRegularValues() throws Exception {
assertEquals("https://www.youtube.com/results?q=asdf", YouTube.getSearchQueryHandler().setQuery("asdf").getUrl());
assertEquals("https://www.youtube.com/results?q=hans",YouTube.getSearchQueryHandler().setQuery("hans").getUrl());
assertEquals("https://www.youtube.com/results?q=Poifj%26jaijf", YouTube.getSearchQueryHandler().setQuery("Poifj&jaijf").getUrl());
assertEquals("https://www.youtube.com/results?q=G%C3%BCl%C3%BCm", YouTube.getSearchQueryHandler().setQuery("Gülüm").getUrl());
assertEquals("https://www.youtube.com/results?q=%3Fj%24%29H%C2%A7B", YouTube.getSearchQueryHandler().setQuery("?j$)H§B").getUrl());
assertEquals("https://www.youtube.com/results?q=asdf", YouTube.getSearchQIHFactory().setQuery("asdf").getUrl());
assertEquals("https://www.youtube.com/results?q=hans",YouTube.getSearchQIHFactory().setQuery("hans").getUrl());
assertEquals("https://www.youtube.com/results?q=Poifj%26jaijf", YouTube.getSearchQIHFactory().setQuery("Poifj&jaijf").getUrl());
assertEquals("https://www.youtube.com/results?q=G%C3%BCl%C3%BCm", YouTube.getSearchQIHFactory().setQuery("Gülüm").getUrl());
assertEquals("https://www.youtube.com/results?q=%3Fj%24%29H%C2%A7B", YouTube.getSearchQIHFactory().setQuery("?j$)H§B").getUrl());
}
@Test
public void testGetContentFilter() throws Exception {
assertEquals("stream", YouTube.getSearchQueryHandler()
assertEquals("stream", YouTube.getSearchQIHFactory()
.setQuery("", asList(new String[]{"stream"}), "").getContentFilter().get(0));
assertEquals("channel", YouTube.getSearchQueryHandler()
assertEquals("channel", YouTube.getSearchQIHFactory()
.setQuery("asdf", asList(new String[]{"channel"}), "").getContentFilter().get(0));
}
@Test
public void testWithContentfilter() throws Exception {
assertEquals("https://www.youtube.com/results?q=asdf&sp=EgIQAVAU", YouTube.getSearchQueryHandler()
assertEquals("https://www.youtube.com/results?q=asdf&sp=EgIQAVAU", YouTube.getSearchQIHFactory()
.setQuery("asdf", asList(new String[]{"stream"}), "").getUrl());
assertEquals("https://www.youtube.com/results?q=asdf&sp=EgIQAlAU", YouTube.getSearchQueryHandler()
assertEquals("https://www.youtube.com/results?q=asdf&sp=EgIQAlAU", YouTube.getSearchQIHFactory()
.setQuery("asdf", asList(new String[]{"channel"}), "").getUrl());
assertEquals("https://www.youtube.com/results?q=asdf&sp=EgIQA1AU", YouTube.getSearchQueryHandler()
assertEquals("https://www.youtube.com/results?q=asdf&sp=EgIQA1AU", YouTube.getSearchQIHFactory()
.setQuery("asdf", asList(new String[]{"playlist"}), "").getUrl());
assertEquals("https://www.youtube.com/results?q=asdf", YouTube.getSearchQueryHandler()
assertEquals("https://www.youtube.com/results?q=asdf", YouTube.getSearchQIHFactory()
.setQuery("asdf", asList(new String[]{"fjiijie"}), "").getUrl());
}
@Test
public void testGetAvailableContentFilter() {
final String[] contentFilter = YouTube.getSearchQueryHandler().getAvailableContentFilter();
final String[] contentFilter = YouTube.getSearchQIHFactory().getAvailableContentFilter();
assertEquals(4, contentFilter.length);
assertEquals("stream", contentFilter[0]);
assertEquals("channel", contentFilter[1]);
@ -51,7 +49,7 @@ public class YoutubeSearchQUHTest {
@Test
public void testGetAvailableSortFilter() {
final String[] contentFilter = YouTube.getSearchQueryHandler().getAvailableSortFilter();
final String[] contentFilter = YouTube.getSearchQIHFactory().getAvailableSortFilter();
assertEquals(0, contentFilter.length);
}
}