From 28788a05dba7700eebafa9deee939d7bc62c3a85 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Fri, 13 Jul 2018 18:02:40 +0200 Subject: [PATCH] rename uih and remove afiliate link foo --- .../schabi/newpipe/extractor/Extractor.java | 13 ++- .../org/schabi/newpipe/extractor/Info.java | 14 ++-- .../newpipe/extractor/ListExtractor.java | 10 +-- .../schabi/newpipe/extractor/ListInfo.java | 4 +- .../newpipe/extractor/StreamingService.java | 24 +++--- .../extractor/channel/ChannelExtractor.java | 4 +- .../extractor/channel/ChannelInfo.java | 5 +- .../extractor/kiosk/KioskExtractor.java | 5 +- .../newpipe/extractor/kiosk/KioskInfo.java | 5 +- .../newpipe/extractor/kiosk/KioskList.java | 12 ++- .../LinkHandler.java} | 8 +- .../LinkHandlerFactory.java} | 14 ++-- .../ListLinkHandler.java} | 22 ++--- .../ListLinkHandlerFactory.java} | 23 +++-- .../SearchQueryHandler.java} | 18 ++-- .../SearchQueryHandlerFactory.java} | 14 ++-- .../extractor/playlist/PlaylistExtractor.java | 5 +- .../extractor/playlist/PlaylistInfo.java | 5 +- .../extractor/search/SearchExtractor.java | 9 +- .../newpipe/extractor/search/SearchInfo.java | 9 +- .../SoundcloudChannelExtractor.java | 4 +- ... SoundcloudChannelLinkHandlerFactory.java} | 8 +- .../soundcloud/SoundcloudChartsExtractor.java | 4 +- ...> SoundcloudChartsLinkHandlerFactory.java} | 4 +- .../SoundcloudPlaylistExtractor.java | 4 +- ...SoundcloudPlaylistLinkHandlerFactory.java} | 8 +- .../soundcloud/SoundcloudSearchExtractor.java | 6 +- ... SoundcloudSearchQueryHandlerFactory.java} | 12 +-- .../soundcloud/SoundcloudService.java | 32 +++---- .../soundcloud/SoundcloudStreamExtractor.java | 14 +--- ...> SoundcloudStreamLinkHandlerFactory.java} | 10 +-- .../services/youtube/YoutubeService.java | 34 ++++---- .../extractors/YoutubeChannelExtractor.java | 5 +- .../extractors/YoutubePlaylistExtractor.java | 13 +-- .../extractors/YoutubeSearchExtractor.java | 4 +- .../extractors/YoutubeStreamExtractor.java | 41 +-------- .../YoutubeStreamInfoItemExtractor.java | 2 +- .../extractors/YoutubeTrendingExtractor.java | 4 +- .../YoutubeChannelLinkHandlerFactory.java} | 12 +-- .../YoutubeParsingHelper.java | 2 +- .../YoutubePlaylistLinkHandlerFactory.java} | 10 +-- .../YoutubeSearchQueryHandlerFactory.java} | 14 ++-- .../YoutubeStreamLinkHandlerFactory.java} | 14 ++-- .../YoutubeTrendingLinkHandlerFactory.java} | 8 +- .../extractor/stream/StreamExtractor.java | 10 +-- .../newpipe/extractor/stream/StreamInfo.java | 28 ------- .../SoundcloudChartsExtractorTest.java | 2 +- ...undcloudChartsLinkHandlerFactoryTest.java} | 8 +- ...undcloudStreamLinkHandlerFactoryTest.java} | 8 +- .../SoundcloudSubscriptionExtractorTest.java | 4 +- ...YoutubeChannelLinkHandlerFactoryTest.java} | 11 ++- ...utubeStreamExtractorControversialTest.java | 4 +- .../YoutubeStreamExtractorRestrictedTest.java | 4 +- ... YoutubeStreamLinkHandlerFactoryTest.java} | 10 +-- .../YoutubeSubscriptionExtractorTest.java | 4 +- .../youtube/YoutubeTrendingExtractorTest.java | 4 +- .../youtube/YoutubeTrendingKioskInfoTest.java | 6 +- ...YoutubeTrendingLinkHandlerFactoryTest.java | 83 +++++++++++++++++++ .../YoutubeTrendingUIHFactoryTest.java | 83 ------------------- 59 files changed, 334 insertions(+), 427 deletions(-) rename extractor/src/main/java/org/schabi/newpipe/extractor/{uih/UIHandler.java => linkhandler/LinkHandler.java} (68%) rename extractor/src/main/java/org/schabi/newpipe/extractor/{uih/UIHFactory.java => linkhandler/LinkHandlerFactory.java} (85%) rename extractor/src/main/java/org/schabi/newpipe/extractor/{uih/ListUIHandler.java => linkhandler/ListLinkHandler.java} (59%) rename extractor/src/main/java/org/schabi/newpipe/extractor/{uih/ListUIHFactory.java => linkhandler/ListLinkHandlerFactory.java} (67%) rename extractor/src/main/java/org/schabi/newpipe/extractor/{uih/SearchQIHandler.java => linkhandler/SearchQueryHandler.java} (54%) rename extractor/src/main/java/org/schabi/newpipe/extractor/{uih/SearchQIHFactory.java => linkhandler/SearchQueryHandlerFactory.java} (62%) rename extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/{SoundcloudChannelUIHFactory.java => SoundcloudChannelLinkHandlerFactory.java} (78%) rename extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/{SoundcloudChartsUIHFactory.java => SoundcloudChartsLinkHandlerFactory.java} (86%) rename extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/{SoundcloudPlaylistUIHFactory.java => SoundcloudPlaylistLinkHandlerFactory.java} (79%) rename extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/{SoundcloudSearchQIHFactory.java => SoundcloudSearchQueryHandlerFactory.java} (88%) rename extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/{SoundcloudStreamUIHFactory.java => SoundcloudStreamLinkHandlerFactory.java} (76%) rename extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/{urlIdHandlers/YoutubeChannelUIHFactory.java => linkHandler/YoutubeChannelLinkHandlerFactory.java} (77%) rename extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/{urlIdHandlers => linkHandler}/YoutubeParsingHelper.java (96%) rename extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/{urlIdHandlers/YoutubePlaylistUIHFactory.java => linkHandler/YoutubePlaylistLinkHandlerFactory.java} (72%) rename extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/{urlIdHandlers/YoutubeSearchQIHFactory.java => linkHandler/YoutubeSearchQueryHandlerFactory.java} (78%) rename extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/{urlIdHandlers/YoutubeStreamUIHFactory.java => linkHandler/YoutubeStreamLinkHandlerFactory.java} (93%) rename extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/{urlIdHandlers/YoutubeTrendingUIHFactory.java => linkHandler/YoutubeTrendingLinkHandlerFactory.java} (81%) rename extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/{SoundcloudChartsUIHFactoryTest.java => SoundcloudChartsLinkHandlerFactoryTest.java} (88%) rename extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/{SoundcloudStreamUIHFactoryTest.java => SoundcloudStreamLinkHandlerFactoryTest.java} (93%) rename extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/{YoutubeChannelUIHFactoryTest.java => YoutubeChannelLinkHandlerFactoryTest.java} (87%) rename extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/{YoutubeStreamUIHFactoryTest.java => YoutubeStreamLinkHandlerFactoryTest.java} (96%) create mode 100644 extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingLinkHandlerFactoryTest.java delete mode 100644 extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingUIHFactoryTest.java diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java index 8fd9e269b..ac2d7ca3e 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java @@ -2,8 +2,7 @@ package org.schabi.newpipe.extractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.uih.UIHandler; -import org.schabi.newpipe.extractor.uih.UIHandler; +import org.schabi.newpipe.extractor.linkhandler.LinkHandler; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -16,15 +15,15 @@ public abstract class Extractor { */ private final StreamingService service; - private final org.schabi.newpipe.extractor.uih.UIHandler uIHandler; + private final LinkHandler uIHandler; @Nullable private boolean pageFetched = false; private final Downloader downloader; - public Extractor(final StreamingService service, final UIHandler uIHandler) { + public Extractor(final StreamingService service, final LinkHandler uIHandler) { if(service == null) throw new NullPointerException("service is null"); - if(uIHandler == null) throw new NullPointerException("UIHandler is null"); + if(uIHandler == null) throw new NullPointerException("LinkHandler is null"); this.service = service; this.uIHandler = uIHandler; this.downloader = NewPipe.getDownloader(); @@ -32,10 +31,10 @@ public abstract class Extractor { } /** - * @return The {@link UIHandler} of the current extractor object (e.g. a ChannelExtractor should return a channel url handler). + * @return The {@link LinkHandler} of the current extractor object (e.g. a ChannelExtractor should return a channel url handler). */ @Nonnull - public UIHandler getUIHandler() { + public LinkHandler getUIHandler() { return uIHandler; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/Info.java b/extractor/src/main/java/org/schabi/newpipe/extractor/Info.java index 7eb80ad82..853fb1189 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/Info.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/Info.java @@ -1,8 +1,6 @@ package org.schabi.newpipe.extractor; -import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.uih.UIHFactory; -import org.schabi.newpipe.extractor.uih.UIHandler; +import org.schabi.newpipe.extractor.linkhandler.LinkHandler; import java.io.Serializable; import java.util.ArrayList; @@ -20,7 +18,7 @@ public abstract class Info implements Serializable { /** * Different than the {@link #originalUrl} in the sense that it may be set as a cleaned url. * - * @see UIHandler#getUrl() + * @see LinkHandler#getUrl() * @see Extractor#getOriginalUrl() */ private final String url; @@ -50,11 +48,11 @@ public abstract class Info implements Serializable { this.name = name; } - public Info(int serviceId, UIHandler uiHandler, String name) { + public Info(int serviceId, LinkHandler linkHandler, String name) { this(serviceId, - uiHandler.getId(), - uiHandler.getUrl(), - uiHandler.getOriginalUrl(), + linkHandler.getId(), + linkHandler.getUrl(), + linkHandler.getOriginalUrl(), name); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java index adefb8888..51cabe92f 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java @@ -1,11 +1,9 @@ package org.schabi.newpipe.extractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; -import org.schabi.newpipe.extractor.uih.ListUIHFactory; -import org.schabi.newpipe.extractor.uih.ListUIHandler; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import javax.annotation.Nonnull; -import javax.swing.plaf.ListUI; import java.io.IOException; import java.util.Collections; import java.util.List; @@ -15,7 +13,7 @@ import java.util.List; */ public abstract class ListExtractor extends Extractor { - public ListExtractor(StreamingService service, ListUIHandler uiHandler) { + public ListExtractor(StreamingService service, ListLinkHandler uiHandler) { super(service, uiHandler); } @@ -53,8 +51,8 @@ public abstract class ListExtractor extends Extractor { } @Override - public ListUIHandler getUIHandler() { - return (ListUIHandler) super.getUIHandler(); + public ListLinkHandler getUIHandler() { + return (ListLinkHandler) super.getUIHandler(); } /*////////////////////////////////////////////////////////////////////////// diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/ListInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/ListInfo.java index 5f9a59bd5..1cb42e5da 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/ListInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/ListInfo.java @@ -1,6 +1,6 @@ package org.schabi.newpipe.extractor; -import org.schabi.newpipe.extractor.uih.ListUIHandler; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import java.util.List; @@ -22,7 +22,7 @@ public abstract class ListInfo extends Info { this.sortFilter = sortFilter; } - public ListInfo(int serviceId, ListUIHandler listUrlIdHandler, String name) { + public ListInfo(int serviceId, ListLinkHandler listUrlIdHandler, String name) { super(serviceId, listUrlIdHandler, name); this.contentFilters = listUrlIdHandler.getContentFilters(); this.sortFilter = listUrlIdHandler.getSortFilter(); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/StreamingService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/StreamingService.java index b20f117b4..e3dd32243 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/StreamingService.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/StreamingService.java @@ -6,7 +6,7 @@ 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.SearchExtractor; -import org.schabi.newpipe.extractor.uih.*; +import org.schabi.newpipe.extractor.linkhandler.*; import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; @@ -67,23 +67,23 @@ public abstract class StreamingService { //////////////////////////////////////////// // Url Id handler //////////////////////////////////////////// - public abstract UIHFactory getStreamUIHFactory(); - public abstract ListUIHFactory getChannelUIHFactory(); - public abstract ListUIHFactory getPlaylistUIHFactory(); - public abstract SearchQIHFactory getSearchQIHFactory(); + public abstract LinkHandlerFactory getStreamUIHFactory(); + public abstract ListLinkHandlerFactory getChannelUIHFactory(); + public abstract ListLinkHandlerFactory getPlaylistUIHFactory(); + public abstract SearchQueryHandlerFactory getSearchQIHFactory(); //////////////////////////////////////////// // Extractor //////////////////////////////////////////// - public abstract SearchExtractor getSearchExtractor(SearchQIHandler queryHandler, String contentCountry); + public abstract SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, String contentCountry); public abstract SuggestionExtractor getSuggestionExtractor(); public abstract SubscriptionExtractor getSubscriptionExtractor(); public abstract KioskList getKioskList() throws ExtractionException; - public abstract ChannelExtractor getChannelExtractor(ListUIHandler urlIdHandler) throws ExtractionException; - public abstract PlaylistExtractor getPlaylistExtractor(ListUIHandler urlIdHandler) throws ExtractionException; - public abstract StreamExtractor getStreamExtractor(UIHandler UIHFactory) throws ExtractionException; + public abstract ChannelExtractor getChannelExtractor(ListLinkHandler urlIdHandler) throws ExtractionException; + public abstract PlaylistExtractor getPlaylistExtractor(ListLinkHandler urlIdHandler) throws ExtractionException; + public abstract StreamExtractor getStreamExtractor(LinkHandler UIHFactory) throws ExtractionException; public SearchExtractor getSearchExtractor(String query, List contentFilter, String sortFilter, String contentCountry) throws ExtractionException { return getSearchExtractor(getSearchQIHFactory().fromQuery(query, contentFilter, sortFilter), contentCountry); @@ -119,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 { - UIHFactory sH = getStreamUIHFactory(); - UIHFactory cH = getChannelUIHFactory(); - UIHFactory pH = getPlaylistUIHFactory(); + LinkHandlerFactory sH = getStreamUIHFactory(); + LinkHandlerFactory cH = getChannelUIHFactory(); + LinkHandlerFactory pH = getPlaylistUIHFactory(); if (sH.acceptUrl(url)) { return LinkType.STREAM; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java index 79b48e9e9..a5895c19c 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java @@ -4,7 +4,7 @@ import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.stream.StreamInfoItem; -import org.schabi.newpipe.extractor.uih.ListUIHandler; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; /* * Created by Christian Schabesberger on 25.07.16. @@ -28,7 +28,7 @@ import org.schabi.newpipe.extractor.uih.ListUIHandler; public abstract class ChannelExtractor extends ListExtractor { - public ChannelExtractor(StreamingService service, ListUIHandler urlIdHandler) { + public ChannelExtractor(StreamingService service, ListLinkHandler urlIdHandler) { super(service, urlIdHandler); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java index a16926703..297b689e4 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java @@ -2,13 +2,12 @@ package org.schabi.newpipe.extractor.channel; import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage; import org.schabi.newpipe.extractor.ListInfo; -import org.schabi.newpipe.extractor.uih.ListUIHFactory; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.stream.StreamInfoItem; -import org.schabi.newpipe.extractor.uih.ListUIHandler; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.utils.ExtractorHelper; import java.io.IOException; @@ -35,7 +34,7 @@ import java.io.IOException; public class ChannelInfo extends ListInfo { - public ChannelInfo(int serviceId, ListUIHandler urlIdHandler, String name) throws ParsingException { + public ChannelInfo(int serviceId, ListLinkHandler urlIdHandler, String name) throws ParsingException { super(serviceId, urlIdHandler, name); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java index 4c64e3908..c7c14dbf3 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java @@ -21,11 +21,10 @@ package org.schabi.newpipe.extractor.kiosk; */ import org.schabi.newpipe.extractor.ListExtractor; -import org.schabi.newpipe.extractor.uih.ListUIHFactory; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.stream.StreamInfoItem; -import org.schabi.newpipe.extractor.uih.ListUIHandler; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import javax.annotation.Nonnull; @@ -34,7 +33,7 @@ public abstract class KioskExtractor extends ListExtractor { private final String id; public KioskExtractor(StreamingService streamingService, - ListUIHandler urlIdHandler, + ListLinkHandler urlIdHandler, String kioskId) { super(streamingService, urlIdHandler); this.id = kioskId; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java index 66a9db3c1..6c357bd19 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java @@ -24,15 +24,14 @@ import org.schabi.newpipe.extractor.*; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.stream.StreamInfoItem; -import org.schabi.newpipe.extractor.uih.ListUIHFactory; -import org.schabi.newpipe.extractor.uih.ListUIHandler; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.utils.ExtractorHelper; import java.io.IOException; public class KioskInfo extends ListInfo { - private KioskInfo(int serviceId, ListUIHandler urlIdHandler, String name) throws ParsingException { + private KioskInfo(int serviceId, ListLinkHandler urlIdHandler, String name) throws ParsingException { super(serviceId, urlIdHandler, name); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java index fcba9847f..263cf2251 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java @@ -2,9 +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.uih.ListUIHFactory; -import org.schabi.newpipe.extractor.uih.ListUIHandler; -import org.schabi.newpipe.extractor.uih.UIHFactory; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import java.io.IOException; @@ -25,19 +23,19 @@ public class KioskList { private String defaultKiosk = null; private class KioskEntry { - public KioskEntry(KioskExtractorFactory ef, ListUIHFactory h) { + public KioskEntry(KioskExtractorFactory ef, ListLinkHandlerFactory h) { extractorFactory = ef; handlerFactory = h; } final KioskExtractorFactory extractorFactory; - final ListUIHFactory handlerFactory; + final ListLinkHandlerFactory handlerFactory; } public KioskList(int service_id) { this.service_id = service_id; } - public void addKioskEntry(KioskExtractorFactory extractorFactory, ListUIHFactory handlerFactory, String id) + public void addKioskEntry(KioskExtractorFactory extractorFactory, ListLinkHandlerFactory handlerFactory, String id) throws Exception { if(kioskList.get(id) != null) { throw new Exception("Kiosk with type " + id + " already exists."); @@ -94,7 +92,7 @@ public class KioskList { throw new ExtractionException("Could not find a kiosk that fits to the url: " + url); } - public ListUIHFactory getUIHFactoryByType(String type) { + public ListLinkHandlerFactory getUIHFactoryByType(String type) { return kioskList.get(type).handlerFactory; } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/uih/UIHandler.java b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandler.java similarity index 68% rename from extractor/src/main/java/org/schabi/newpipe/extractor/uih/UIHandler.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandler.java index 5b0d3383e..c28bc5c83 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/uih/UIHandler.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandler.java @@ -1,19 +1,19 @@ -package org.schabi.newpipe.extractor.uih; +package org.schabi.newpipe.extractor.linkhandler; import java.io.Serializable; -public class UIHandler implements Serializable { +public class LinkHandler implements Serializable { protected final String originalUrl; protected final String url; protected final String id; - public UIHandler(String originalUrl, String url, String id) { + public LinkHandler(String originalUrl, String url, String id) { this.originalUrl = originalUrl; this.url = url; this.id = id; } - public UIHandler(UIHandler handler) { + public LinkHandler(LinkHandler handler) { this(handler.originalUrl, handler.url, handler.id); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/uih/UIHFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandlerFactory.java similarity index 85% rename from extractor/src/main/java/org/schabi/newpipe/extractor/uih/UIHFactory.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandlerFactory.java index 08aebcae5..60a65f5ef 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/uih/UIHFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandlerFactory.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.extractor.uih; +package org.schabi.newpipe.extractor.linkhandler; import org.schabi.newpipe.extractor.exceptions.FoundAdException; import org.schabi.newpipe.extractor.exceptions.ParsingException; @@ -7,7 +7,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; * Created by Christian Schabesberger on 26.07.16. * * Copyright (C) Christian Schabesberger 2016 - * UIHFactory.java is part of NewPipe. + * LinkHandlerFactory.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 +23,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; * along with NewPipe. If not, see . */ -public abstract class UIHFactory { +public abstract class LinkHandlerFactory { /////////////////////////////////// // To Override @@ -37,20 +37,20 @@ public abstract class UIHFactory { // Logic /////////////////////////////////// - public UIHandler fromUrl(String url) throws ParsingException { + public LinkHandler fromUrl(String url) throws ParsingException { if(url == null) throw new IllegalArgumentException("url can not be null"); if(!acceptUrl(url)) { throw new ParsingException("Malformed unacceptable url: " + url); } final String id = getId(url); - return new UIHandler(url, getUrl(id), id); + return new LinkHandler(url, getUrl(id), id); } - public UIHandler fromId(String id) throws ParsingException { + public LinkHandler fromId(String id) throws ParsingException { if(id == null) throw new IllegalArgumentException("id can not be null"); final String url = getUrl(id); - return new UIHandler(url, url, id); + return new LinkHandler(url, url, id); } /** diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/uih/ListUIHandler.java b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandler.java similarity index 59% rename from extractor/src/main/java/org/schabi/newpipe/extractor/uih/ListUIHandler.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandler.java index b9151fa7b..3e85fe1bd 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/uih/ListUIHandler.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandler.java @@ -1,23 +1,23 @@ -package org.schabi.newpipe.extractor.uih; +package org.schabi.newpipe.extractor.linkhandler; import java.util.Collections; import java.util.List; -public class ListUIHandler extends UIHandler { +public class ListLinkHandler extends LinkHandler { protected final List contentFilters; protected final String sortFilter; - public ListUIHandler(String originalUrl, - String url, - String id, - List contentFilters, - String sortFilter) { + public ListLinkHandler(String originalUrl, + String url, + String id, + List contentFilters, + String sortFilter) { super(originalUrl, url, id); this.contentFilters = Collections.unmodifiableList(contentFilters); this.sortFilter = sortFilter; } - public ListUIHandler(ListUIHandler handler) { + public ListLinkHandler(ListLinkHandler handler) { this(handler.originalUrl, handler.url, handler.id, @@ -25,9 +25,9 @@ public class ListUIHandler extends UIHandler { handler.sortFilter); } - public ListUIHandler(UIHandler handler, - List contentFilters, - String sortFilter) { + public ListLinkHandler(LinkHandler handler, + List contentFilters, + String sortFilter) { this(handler.originalUrl, handler.url, handler.id, diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/uih/ListUIHFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandlerFactory.java similarity index 67% rename from extractor/src/main/java/org/schabi/newpipe/extractor/uih/ListUIHFactory.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandlerFactory.java index 111ee0456..a9c4e51aa 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/uih/ListUIHFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandlerFactory.java @@ -1,12 +1,11 @@ -package org.schabi.newpipe.extractor.uih; +package org.schabi.newpipe.extractor.linkhandler; import org.schabi.newpipe.extractor.exceptions.ParsingException; import java.util.ArrayList; -import java.util.Collections; import java.util.List; -public abstract class ListUIHFactory extends UIHFactory { +public abstract class ListLinkHandlerFactory extends LinkHandlerFactory { /////////////////////////////////// // To Override @@ -22,27 +21,27 @@ public abstract class ListUIHFactory extends UIHFactory { @Override - public ListUIHandler fromUrl(String url) throws ParsingException { + public ListLinkHandler fromUrl(String url) throws ParsingException { if(url == null) throw new IllegalArgumentException("url may not be null"); - return new ListUIHandler(super.fromUrl(url), getContentFilter(url), getSortFilter(url)); + return new ListLinkHandler(super.fromUrl(url), getContentFilter(url), getSortFilter(url)); } @Override - public ListUIHandler fromId(String id) throws ParsingException { - return new ListUIHandler(super.fromId(id), new ArrayList(0), ""); + public ListLinkHandler fromId(String id) throws ParsingException { + return new ListLinkHandler(super.fromId(id), new ArrayList(0), ""); } - public ListUIHandler fromQuery(String id, - List contentFilters, - String sortFilter) throws ParsingException { + public ListLinkHandler fromQuery(String id, + List contentFilters, + String sortFilter) throws ParsingException { final String url = getUrl(id, contentFilters, sortFilter); - return new ListUIHandler(url, url, id, contentFilters, sortFilter); + return new ListLinkHandler(url, url, id, contentFilters, sortFilter); } /** - * For makeing ListUIHFactory compatible with UIHFactory we need to override this, + * For makeing ListLinkHandlerFactory compatible with LinkHandlerFactory we need to override this, * however it should not be overridden by the actual implementation. * @param id * @return the url coresponding to id without any filters applied diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/uih/SearchQIHandler.java b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/SearchQueryHandler.java similarity index 54% rename from extractor/src/main/java/org/schabi/newpipe/extractor/uih/SearchQIHandler.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/SearchQueryHandler.java index 891a38f6c..6c1893c7e 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/uih/SearchQIHandler.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/SearchQueryHandler.java @@ -1,18 +1,18 @@ -package org.schabi.newpipe.extractor.uih; +package org.schabi.newpipe.extractor.linkhandler; import java.util.List; -public class SearchQIHandler extends ListUIHandler { +public class SearchQueryHandler extends ListLinkHandler { - public SearchQIHandler(String originalUrl, - String url, - String searchString, - List contentFilters, - String sortFilter) { + public SearchQueryHandler(String originalUrl, + String url, + String searchString, + List contentFilters, + String sortFilter) { super(originalUrl, url, searchString, contentFilters, sortFilter); } - public SearchQIHandler(ListUIHandler handler) { + public SearchQueryHandler(ListLinkHandler handler) { this(handler.originalUrl, handler.url, handler.id, @@ -22,7 +22,7 @@ public class SearchQIHandler extends ListUIHandler { /** - * Returns the search string. Since ListQIHandler is based on ListUIHandler + * Returns the search string. Since ListQIHandler is based on ListLinkHandler * getSearchString() is equivalent to calling getId(). * @return the search string */ diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/uih/SearchQIHFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/SearchQueryHandlerFactory.java similarity index 62% rename from extractor/src/main/java/org/schabi/newpipe/extractor/uih/SearchQIHFactory.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/SearchQueryHandlerFactory.java index 648dbd141..997e2d09c 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/uih/SearchQIHFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/SearchQueryHandlerFactory.java @@ -1,11 +1,11 @@ -package org.schabi.newpipe.extractor.uih; +package org.schabi.newpipe.extractor.linkhandler; import org.schabi.newpipe.extractor.exceptions.ParsingException; import java.util.ArrayList; import java.util.List; -public abstract class SearchQIHFactory extends ListUIHFactory { +public abstract class SearchQueryHandlerFactory extends ListLinkHandlerFactory { /////////////////////////////////// // To Override @@ -23,13 +23,13 @@ public abstract class SearchQIHFactory extends ListUIHFactory { public String getId(String url) { return getSearchString(url); } @Override - public SearchQIHandler fromQuery(String querry, - List contentFilter, - String sortFilter) throws ParsingException { - return new SearchQIHandler(super.fromQuery(querry, contentFilter, sortFilter)); + public SearchQueryHandler fromQuery(String querry, + List contentFilter, + String sortFilter) throws ParsingException { + return new SearchQueryHandler(super.fromQuery(querry, contentFilter, sortFilter)); } - public SearchQIHandler fromQuery(String querry) throws ParsingException { + public SearchQueryHandler fromQuery(String querry) throws ParsingException { return fromQuery(querry, new ArrayList(0), ""); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java index d5008a504..cc511bc8e 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java @@ -1,15 +1,14 @@ package org.schabi.newpipe.extractor.playlist; import org.schabi.newpipe.extractor.ListExtractor; -import org.schabi.newpipe.extractor.uih.ListUIHFactory; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.stream.StreamInfoItem; -import org.schabi.newpipe.extractor.uih.ListUIHandler; public abstract class PlaylistExtractor extends ListExtractor { - public PlaylistExtractor(StreamingService service, ListUIHandler urlIdHandler) { + public PlaylistExtractor(StreamingService service, ListLinkHandler urlIdHandler) { super(service, urlIdHandler); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java index b4f3ebc1f..1eb35723d 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java @@ -2,20 +2,19 @@ package org.schabi.newpipe.extractor.playlist; import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage; import org.schabi.newpipe.extractor.ListInfo; -import org.schabi.newpipe.extractor.uih.ListUIHFactory; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.stream.StreamInfoItem; -import org.schabi.newpipe.extractor.uih.ListUIHandler; import org.schabi.newpipe.extractor.utils.ExtractorHelper; import java.io.IOException; public class PlaylistInfo extends ListInfo { - private PlaylistInfo(int serviceId, ListUIHandler urlIdHandler, String name) throws ParsingException { + private PlaylistInfo(int serviceId, ListLinkHandler urlIdHandler, String name) throws ParsingException { super(serviceId, urlIdHandler, name); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java index 751152ca5..ebbf76a66 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java @@ -5,8 +5,7 @@ import org.schabi.newpipe.extractor.ListExtractor; 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.uih.SearchQIHFactory; -import org.schabi.newpipe.extractor.uih.SearchQIHandler; +import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler; public abstract class SearchExtractor extends ListExtractor { @@ -19,7 +18,7 @@ public abstract class SearchExtractor extends ListExtractor { private final InfoItemsSearchCollector collector; private final String contentCountry; - public SearchExtractor(StreamingService service, SearchQIHandler urlIdHandler, String contentCountry) { + public SearchExtractor(StreamingService service, SearchQueryHandler urlIdHandler, String contentCountry) { super(service, urlIdHandler); collector = new InfoItemsSearchCollector(service.getServiceId()); this.contentCountry = contentCountry; @@ -36,8 +35,8 @@ public abstract class SearchExtractor extends ListExtractor { } @Override - public SearchQIHandler getUIHandler() { - return (SearchQIHandler) super.getUIHandler(); + public SearchQueryHandler getUIHandler() { + return (SearchQueryHandler) super.getUIHandler(); } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java index c5406ba51..27b622332 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java @@ -5,8 +5,7 @@ import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.ListInfo; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; -import org.schabi.newpipe.extractor.stream.Stream; -import org.schabi.newpipe.extractor.uih.SearchQIHandler; +import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler; import org.schabi.newpipe.extractor.utils.ExtractorHelper; import java.io.IOException; @@ -18,14 +17,14 @@ public class SearchInfo extends ListInfo { private String searchSuggestion; public SearchInfo(int serviceId, - SearchQIHandler qIHandler, + SearchQueryHandler qIHandler, String searchString) { super(serviceId, qIHandler, "Search"); this.searchString = searchString; } - public static SearchInfo getInfo(StreamingService service, SearchQIHandler searchQuery, String contentCountry) throws ExtractionException, IOException { + public static SearchInfo getInfo(StreamingService service, SearchQueryHandler searchQuery, String contentCountry) throws ExtractionException, IOException { SearchExtractor extractor = service.getSearchExtractor(searchQuery, contentCountry); extractor.fetchPage(); return getInfo(extractor); @@ -52,7 +51,7 @@ public class SearchInfo extends ListInfo { public static ListExtractor.InfoItemsPage getMoreItems(StreamingService service, - SearchQIHandler query, + SearchQueryHandler query, String contentCountry, String pageUrl) throws IOException, ExtractionException { diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java index ea2195e38..1b6778698 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java @@ -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.uih.ListUIHandler; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.channel.ChannelExtractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; @@ -24,7 +24,7 @@ public class SoundcloudChannelExtractor extends ChannelExtractor { private StreamInfoItemsCollector streamInfoItemsCollector = null; private String nextPageUrl = null; - public SoundcloudChannelExtractor(StreamingService service, ListUIHandler urlIdHandler) { + public SoundcloudChannelExtractor(StreamingService service, ListLinkHandler urlIdHandler) { super(service, urlIdHandler); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelUIHFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelLinkHandlerFactory.java similarity index 78% rename from extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelUIHFactory.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelLinkHandlerFactory.java index 5a8b10112..ed5d9a98f 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelUIHFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelLinkHandlerFactory.java @@ -1,18 +1,18 @@ package org.schabi.newpipe.extractor.services.soundcloud; -import org.schabi.newpipe.extractor.uih.ListUIHFactory; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Utils; import java.util.List; -public class SoundcloudChannelUIHFactory extends ListUIHFactory { - private static final SoundcloudChannelUIHFactory instance = new SoundcloudChannelUIHFactory(); +public class SoundcloudChannelLinkHandlerFactory extends ListLinkHandlerFactory { + private static final SoundcloudChannelLinkHandlerFactory instance = new SoundcloudChannelLinkHandlerFactory(); private final String URL_PATTERN = "^https?://(www\\.|m\\.)?soundcloud.com/[0-9a-z_-]+" + "(/((tracks|albums|sets|reposts|followers|following)/?)?)?([#?].*)?$"; - public static SoundcloudChannelUIHFactory getInstance() { + public static SoundcloudChannelLinkHandlerFactory getInstance() { return instance; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java index ab9e92c3f..12223b8a5 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java @@ -1,7 +1,7 @@ package org.schabi.newpipe.extractor.services.soundcloud; import org.schabi.newpipe.extractor.Downloader; -import org.schabi.newpipe.extractor.uih.ListUIHandler; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.kiosk.KioskExtractor; @@ -17,7 +17,7 @@ public class SoundcloudChartsExtractor extends KioskExtractor { private StreamInfoItemsCollector collector = null; private String nextPageUrl = null; - public SoundcloudChartsExtractor(StreamingService service, ListUIHandler urlIdHandler, String kioskId) { + public SoundcloudChartsExtractor(StreamingService service, ListLinkHandler urlIdHandler, String kioskId) { super(service, urlIdHandler, kioskId); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsUIHFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactory.java similarity index 86% rename from extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsUIHFactory.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactory.java index 8fdb8f5ec..ef7e700f9 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsUIHFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactory.java @@ -1,11 +1,11 @@ package org.schabi.newpipe.extractor.services.soundcloud; -import org.schabi.newpipe.extractor.uih.ListUIHFactory; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory; import org.schabi.newpipe.extractor.utils.Parser; import java.util.List; -public class SoundcloudChartsUIHFactory extends ListUIHFactory { +public class SoundcloudChartsLinkHandlerFactory extends ListLinkHandlerFactory { 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)?/?([#?].*)?$"; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java index 727486ddb..20c454d6e 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java @@ -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.uih.ListUIHandler; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; @@ -23,7 +23,7 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor { private StreamInfoItemsCollector streamInfoItemsCollector = null; private String nextPageUrl = null; - public SoundcloudPlaylistExtractor(StreamingService service, ListUIHandler urlIdHandler) { + public SoundcloudPlaylistExtractor(StreamingService service, ListLinkHandler urlIdHandler) { super(service, urlIdHandler); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistUIHFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistLinkHandlerFactory.java similarity index 79% rename from extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistUIHFactory.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistLinkHandlerFactory.java index e4dc0cb2f..17e4e7f28 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistUIHFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistLinkHandlerFactory.java @@ -1,18 +1,18 @@ package org.schabi.newpipe.extractor.services.soundcloud; -import org.schabi.newpipe.extractor.uih.ListUIHFactory; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Utils; import java.util.List; -public class SoundcloudPlaylistUIHFactory extends ListUIHFactory { - private static final SoundcloudPlaylistUIHFactory instance = new SoundcloudPlaylistUIHFactory(); +public class SoundcloudPlaylistLinkHandlerFactory extends ListLinkHandlerFactory { + private static final SoundcloudPlaylistLinkHandlerFactory instance = new SoundcloudPlaylistLinkHandlerFactory(); private final String URL_PATTERN = "^https?://(www\\.|m\\.)?soundcloud.com/[0-9a-z_-]+" + "/sets/[0-9a-z_-]+/?([#?].*)?$"; - public static SoundcloudPlaylistUIHFactory getInstance() { + public static SoundcloudPlaylistLinkHandlerFactory getInstance() { return instance; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchExtractor.java index c976ce2d8..b2f4c8ad3 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchExtractor.java @@ -9,7 +9,7 @@ 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.SearchExtractor; -import org.schabi.newpipe.extractor.uih.SearchQIHandler; +import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler; import org.schabi.newpipe.extractor.utils.Parser; import javax.annotation.Nonnull; @@ -18,14 +18,14 @@ import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; -import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchQIHFactory.ITEMS_PER_PAGE; +import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchQueryHandlerFactory.ITEMS_PER_PAGE; public class SoundcloudSearchExtractor extends SearchExtractor { private JsonArray searchCollection; public SoundcloudSearchExtractor(StreamingService service, - SearchQIHandler urlIdHandler, + SearchQueryHandler urlIdHandler, String contentCountry) { super(service, urlIdHandler, contentCountry); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchQIHFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchQueryHandlerFactory.java similarity index 88% rename from extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchQIHFactory.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchQueryHandlerFactory.java index 9f053c181..a48285f87 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchQIHFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchQueryHandlerFactory.java @@ -2,14 +2,14 @@ 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.uih.SearchQIHFactory; +import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandlerFactory; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.List; -public class SoundcloudSearchQIHFactory extends SearchQIHFactory { +public class SoundcloudSearchQueryHandlerFactory extends SearchQueryHandlerFactory { public static final String CHARSET_UTF_8 = "UTF-8"; public static final String TRACKS = "tracks"; @@ -58,9 +58,9 @@ public class SoundcloudSearchQIHFactory extends SearchQIHFactory { @Override public String[] getAvailableContentFilter() { return new String[] { - TRACKS, - USERS, - PLAYLIST, - ANY}; + ANY, + TRACKS, + USERS, + PLAYLIST}; } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java index 901d1ef2c..17aa0284b 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java @@ -1,7 +1,7 @@ package org.schabi.newpipe.extractor.services.soundcloud; import org.schabi.newpipe.extractor.*; -import org.schabi.newpipe.extractor.uih.*; +import org.schabi.newpipe.extractor.linkhandler.*; import org.schabi.newpipe.extractor.channel.ChannelExtractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.kiosk.KioskExtractor; @@ -21,43 +21,43 @@ public class SoundcloudService extends StreamingService { } @Override - public SearchExtractor getSearchExtractor(SearchQIHandler queryHandler, String contentCountry) { + public SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, String contentCountry) { return new SoundcloudSearchExtractor(this, queryHandler, contentCountry); } @Override - public SearchQIHFactory getSearchQIHFactory() { - return new SoundcloudSearchQIHFactory(); + public SearchQueryHandlerFactory getSearchQIHFactory() { + return new SoundcloudSearchQueryHandlerFactory(); } @Override - public UIHFactory getStreamUIHFactory() { - return SoundcloudStreamUIHFactory.getInstance(); + public LinkHandlerFactory getStreamUIHFactory() { + return SoundcloudStreamLinkHandlerFactory.getInstance(); } @Override - public ListUIHFactory getChannelUIHFactory() { - return SoundcloudChannelUIHFactory.getInstance(); + public ListLinkHandlerFactory getChannelUIHFactory() { + return SoundcloudChannelLinkHandlerFactory.getInstance(); } @Override - public ListUIHFactory getPlaylistUIHFactory() { - return SoundcloudPlaylistUIHFactory.getInstance(); + public ListLinkHandlerFactory getPlaylistUIHFactory() { + return SoundcloudPlaylistLinkHandlerFactory.getInstance(); } @Override - public StreamExtractor getStreamExtractor(UIHandler UIHandler) { - return new SoundcloudStreamExtractor(this, UIHandler); + public StreamExtractor getStreamExtractor(LinkHandler LinkHandler) { + return new SoundcloudStreamExtractor(this, LinkHandler); } @Override - public ChannelExtractor getChannelExtractor(ListUIHandler urlIdHandler) { + public ChannelExtractor getChannelExtractor(ListLinkHandler urlIdHandler) { return new SoundcloudChannelExtractor(this, urlIdHandler); } @Override - public PlaylistExtractor getPlaylistExtractor(ListUIHandler urlIdHandler) { + public PlaylistExtractor getPlaylistExtractor(ListLinkHandler urlIdHandler) { return new SoundcloudPlaylistExtractor(this, urlIdHandler); } @@ -75,14 +75,14 @@ public class SoundcloudService extends StreamingService { String id) throws ExtractionException { return new SoundcloudChartsExtractor(SoundcloudService.this, - new SoundcloudChartsUIHFactory().fromUrl(url), id); + new SoundcloudChartsLinkHandlerFactory().fromUrl(url), id); } }; KioskList list = new KioskList(getServiceId()); // add kiosks here e.g.: - final SoundcloudChartsUIHFactory h = new SoundcloudChartsUIHFactory(); + final SoundcloudChartsLinkHandlerFactory h = new SoundcloudChartsLinkHandlerFactory(); try { list.addKioskEntry(chartsFactory, h, "Top 50"); list.addKioskEntry(chartsFactory, h, "New & hot"); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java index 853d17bc3..dbd9971c9 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java @@ -7,8 +7,8 @@ import org.schabi.newpipe.extractor.*; import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.linkhandler.LinkHandler; import org.schabi.newpipe.extractor.stream.*; -import org.schabi.newpipe.extractor.uih.UIHandler; import javax.annotation.Nonnull; import java.io.IOException; @@ -21,7 +21,7 @@ import java.util.List; public class SoundcloudStreamExtractor extends StreamExtractor { private JsonObject track; - public SoundcloudStreamExtractor(StreamingService service, UIHandler uIHandler) { + public SoundcloudStreamExtractor(StreamingService service, LinkHandler uIHandler) { super(service, uIHandler); } @@ -202,16 +202,6 @@ public class SoundcloudStreamExtractor extends StreamExtractor { return collector; } - @Override - public String[] getDonationLinks() { - return new String[0]; - } - - @Override - public String[] getAffiliateLinks() { - return new String[0]; - } - @Override public String getErrorMessage() { return null; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamUIHFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamLinkHandlerFactory.java similarity index 76% rename from extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamUIHFactory.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamLinkHandlerFactory.java index a4e5e6043..3476eab18 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamUIHFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamLinkHandlerFactory.java @@ -1,19 +1,19 @@ package org.schabi.newpipe.extractor.services.soundcloud; -import org.schabi.newpipe.extractor.uih.UIHFactory; +import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Utils; -public class SoundcloudStreamUIHFactory extends UIHFactory { - private static final SoundcloudStreamUIHFactory instance = new SoundcloudStreamUIHFactory(); +public class SoundcloudStreamLinkHandlerFactory extends LinkHandlerFactory { + private static final SoundcloudStreamLinkHandlerFactory instance = new SoundcloudStreamLinkHandlerFactory(); private final String URL_PATTERN = "^https?://(www\\.|m\\.)?soundcloud.com/[0-9a-z_-]+" + "/(?!(tracks|albums|sets|reposts|followers|following)/?$)[0-9a-z_-]+/?([#?].*)?$"; - private SoundcloudStreamUIHFactory() { + private SoundcloudStreamLinkHandlerFactory() { } - public static SoundcloudStreamUIHFactory getInstance() { + public static SoundcloudStreamLinkHandlerFactory getInstance() { return instance; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java index 4490f1386..228827bf0 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java @@ -1,7 +1,7 @@ package org.schabi.newpipe.extractor.services.youtube; import org.schabi.newpipe.extractor.*; -import org.schabi.newpipe.extractor.uih.*; +import org.schabi.newpipe.extractor.linkhandler.*; import org.schabi.newpipe.extractor.channel.ChannelExtractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.kiosk.KioskExtractor; @@ -9,7 +9,7 @@ import org.schabi.newpipe.extractor.kiosk.KioskList; import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.services.youtube.extractors.*; -import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.*; +import org.schabi.newpipe.extractor.services.youtube.linkHandler.*; import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; @@ -44,42 +44,42 @@ public class YoutubeService extends StreamingService { } @Override - public SearchExtractor getSearchExtractor(SearchQIHandler query, String contentCountry) { + public SearchExtractor getSearchExtractor(SearchQueryHandler query, String contentCountry) { return new YoutubeSearchExtractor(this, query, contentCountry); } @Override - public UIHFactory getStreamUIHFactory() { - return YoutubeStreamUIHFactory.getInstance(); + public LinkHandlerFactory getStreamUIHFactory() { + return YoutubeStreamLinkHandlerFactory.getInstance(); } @Override - public ListUIHFactory getChannelUIHFactory() { - return YoutubeChannelUIHFactory.getInstance(); + public ListLinkHandlerFactory getChannelUIHFactory() { + return YoutubeChannelLinkHandlerFactory.getInstance(); } @Override - public ListUIHFactory getPlaylistUIHFactory() { - return YoutubePlaylistUIHFactory.getInstance(); + public ListLinkHandlerFactory getPlaylistUIHFactory() { + return YoutubePlaylistLinkHandlerFactory.getInstance(); } @Override - public SearchQIHFactory getSearchQIHFactory() { - return YoutubeSearchQIHFactory.getInstance(); + public SearchQueryHandlerFactory getSearchQIHFactory() { + return YoutubeSearchQueryHandlerFactory.getInstance(); } @Override - public StreamExtractor getStreamExtractor(UIHandler uiHandler) throws ExtractionException { - return new YoutubeStreamExtractor(this, uiHandler); + public StreamExtractor getStreamExtractor(LinkHandler linkHandler) throws ExtractionException { + return new YoutubeStreamExtractor(this, linkHandler); } @Override - public ChannelExtractor getChannelExtractor(ListUIHandler urlIdHandler) throws ExtractionException { + public ChannelExtractor getChannelExtractor(ListLinkHandler urlIdHandler) throws ExtractionException { return new YoutubeChannelExtractor(this, urlIdHandler); } @Override - public PlaylistExtractor getPlaylistExtractor(ListUIHandler urlIdHandler) throws ExtractionException { + public PlaylistExtractor getPlaylistExtractor(ListLinkHandler urlIdHandler) throws ExtractionException { return new YoutubePlaylistExtractor(this, urlIdHandler); } @@ -99,9 +99,9 @@ public class YoutubeService extends StreamingService { public KioskExtractor createNewKiosk(StreamingService streamingService, String url, String id) throws ExtractionException { return new YoutubeTrendingExtractor(YoutubeService.this, - new YoutubeTrendingUIHFactory().fromUrl(url), id); + new YoutubeTrendingLinkHandlerFactory().fromUrl(url), id); } - }, new YoutubeTrendingUIHFactory(), "Trending"); + }, new YoutubeTrendingLinkHandlerFactory(), "Trending"); list.setDefaultKiosk("Trending"); } catch (Exception e) { throw new ExtractionException(e); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java index 72176d69a..e8680d11f 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java @@ -13,8 +13,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; -import org.schabi.newpipe.extractor.uih.ListUIHFactory; -import org.schabi.newpipe.extractor.uih.ListUIHandler; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.utils.DonationLinkHelper; import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Utils; @@ -50,7 +49,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor { private Document doc; - public YoutubeChannelExtractor(StreamingService service, ListUIHandler urlIdHandler) { + public YoutubeChannelExtractor(StreamingService service, ListLinkHandler urlIdHandler) { super(service, urlIdHandler); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java index cc116ebbb..4852ceee5 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java @@ -9,12 +9,13 @@ import org.jsoup.nodes.Element; import org.schabi.newpipe.extractor.*; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; -import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeParsingHelper; +import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import org.schabi.newpipe.extractor.stream.StreamType; -import org.schabi.newpipe.extractor.uih.ListUIHandler; import org.schabi.newpipe.extractor.utils.Utils; import javax.annotation.Nonnull; @@ -25,7 +26,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor { private Document doc; - public YoutubePlaylistExtractor(StreamingService service, ListUIHandler urlIdHandler) throws ExtractionException { + public YoutubePlaylistExtractor(StreamingService service, ListLinkHandler urlIdHandler) throws ExtractionException { super(service, urlIdHandler); } @@ -174,7 +175,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor { private void collectStreamsFrom(StreamInfoItemsCollector collector, Element element) { collector.reset(); - final org.schabi.newpipe.extractor.uih.UIHFactory streamUIHFactory = getService().getStreamUIHFactory(); + final LinkHandlerFactory streamLinkHandlerFactory = getService().getStreamUIHFactory(); for (final Element li : element.children()) { if(isDeletedItem(li)) { continue; @@ -191,7 +192,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor { @Override public String getUrl() throws ParsingException { try { - return streamUIHFactory.fromId(li.attr("data-video-id")).getUrl(); + return streamLinkHandlerFactory.fromId(li.attr("data-video-id")).getUrl(); } catch (Exception e) { throw new ParsingException("Could not get web page url for the video", e); } @@ -256,7 +257,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor { @Override public String getThumbnailUrl() throws ParsingException { try { - return "https://i.ytimg.com/vi/" + streamUIHFactory.fromUrl(getUrl()).getId() + "/hqdefault.jpg"; + return "https://i.ytimg.com/vi/" + streamLinkHandlerFactory.fromUrl(getUrl()).getId() + "/hqdefault.jpg"; } catch (Exception e) { throw new ParsingException("Could not get thumbnail url", e); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java index bdf55ac45..b74c948fc 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java @@ -10,7 +10,7 @@ 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.SearchExtractor; -import org.schabi.newpipe.extractor.uih.SearchQIHandler; +import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler; import org.schabi.newpipe.extractor.utils.Parser; import javax.annotation.Nonnull; @@ -44,7 +44,7 @@ public class YoutubeSearchExtractor extends SearchExtractor { private Document doc; public YoutubeSearchExtractor(StreamingService service, - SearchQIHandler urlIdHandler, + SearchQueryHandler urlIdHandler, String contentCountry) { super(service, urlIdHandler, contentCountry); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java index 133906a24..bd44ecf3d 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java @@ -15,9 +15,9 @@ import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; +import org.schabi.newpipe.extractor.linkhandler.LinkHandler; import org.schabi.newpipe.extractor.services.youtube.ItagItem; import org.schabi.newpipe.extractor.stream.*; -import org.schabi.newpipe.extractor.uih.UIHandler; import org.schabi.newpipe.extractor.utils.DonationLinkHelper; import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Utils; @@ -85,8 +85,8 @@ public class YoutubeStreamExtractor extends StreamExtractor { private boolean isAgeRestricted; - public YoutubeStreamExtractor(StreamingService service, UIHandler uiHandler) throws ExtractionException { - super(service, uiHandler); + public YoutubeStreamExtractor(StreamingService service, LinkHandler linkHandler) { + super(service, linkHandler); } /*////////////////////////////////////////////////////////////////////////// @@ -518,41 +518,6 @@ public class YoutubeStreamExtractor extends StreamExtractor { return errorReason != null ? errorReason.toString() : null; } - @Override - public String[] getDonationLinks() throws ParsingException { - try { - ArrayList donationLinks = new ArrayList<>(); - for (String s : Parser.getLinksFromString(getDescription())) { - if (DonationLinkHelper.getDonatoinServiceByLink(s) != DonationLinkHelper.DonationService.NO_DONATION) { - donationLinks.add(s); - } - } - String[] donlret = new String[donationLinks.size()]; - donlret = donationLinks.toArray(donlret); - return donlret; - } catch (Exception e) { - throw new ParsingException("Could not get donation links", e); - } - } - - @Override - public String[] getAffiliateLinks() throws ParsingException { - try { - ArrayList donationLinks = new ArrayList<>(); - for (String s : Parser.getLinksFromString(getDescription())) { - if (DonationLinkHelper.getAffiliateServiceByLink(s) != DonationLinkHelper.AffiliateService.NO_AFILIATE) { - donationLinks.add(s); - } - } - String[] donlret = new String[donationLinks.size()]; - donlret = donationLinks.toArray(donlret); - return donlret; - } catch (Exception e) { - throw new ParsingException("Could not get afiliate links", e); - } - } - - /*////////////////////////////////////////////////////////////////////////// // Fetch page //////////////////////////////////////////////////////////////////////////*/ diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java index 3b1bb7191..a948bfcff 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java @@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube.extractors; import org.jsoup.nodes.Element; import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeParsingHelper; +import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper; import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor; import org.schabi.newpipe.extractor.stream.StreamType; import org.schabi.newpipe.extractor.utils.Utils; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeTrendingExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeTrendingExtractor.java index 7feb0090b..b9cc118b1 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeTrendingExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeTrendingExtractor.java @@ -25,7 +25,7 @@ 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.uih.ListUIHandler; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; @@ -41,7 +41,7 @@ public class YoutubeTrendingExtractor extends KioskExtractor { private Document doc; public YoutubeTrendingExtractor(StreamingService service, - ListUIHandler urlIdHandler, + ListLinkHandler urlIdHandler, String kioskId) { super(service, urlIdHandler, kioskId); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubeChannelUIHFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeChannelLinkHandlerFactory.java similarity index 77% rename from extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubeChannelUIHFactory.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeChannelLinkHandlerFactory.java index 187933e98..950bab2b9 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubeChannelUIHFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeChannelLinkHandlerFactory.java @@ -1,6 +1,6 @@ -package org.schabi.newpipe.extractor.services.youtube.urlIdHandlers; +package org.schabi.newpipe.extractor.services.youtube.linkHandler; -import org.schabi.newpipe.extractor.uih.ListUIHFactory; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.utils.Parser; @@ -10,7 +10,7 @@ import java.util.List; * Created by Christian Schabesberger on 25.07.16. * * Copyright (C) Christian Schabesberger 2018 - * YoutubeChannelUIHFactory.java is part of NewPipe. + * YoutubeChannelLinkHandlerFactory.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 @@ -26,12 +26,12 @@ import java.util.List; * along with NewPipe. If not, see . */ -public class YoutubeChannelUIHFactory extends ListUIHFactory { +public class YoutubeChannelLinkHandlerFactory extends ListLinkHandlerFactory { - private static final YoutubeChannelUIHFactory instance = new YoutubeChannelUIHFactory(); + private static final YoutubeChannelLinkHandlerFactory instance = new YoutubeChannelLinkHandlerFactory(); private static final String ID_PATTERN = "/(user/[A-Za-z0-9_-]*|channel/[A-Za-z0-9_-]*)"; - public static YoutubeChannelUIHFactory getInstance() { + public static YoutubeChannelLinkHandlerFactory getInstance() { return instance; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubeParsingHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeParsingHelper.java similarity index 96% rename from extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubeParsingHelper.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeParsingHelper.java index 90f464ed9..fca0584ca 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubeParsingHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeParsingHelper.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.extractor.services.youtube.urlIdHandlers; +package org.schabi.newpipe.extractor.services.youtube.linkHandler; import org.schabi.newpipe.extractor.exceptions.ParsingException; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubePlaylistUIHFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubePlaylistLinkHandlerFactory.java similarity index 72% rename from extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubePlaylistUIHFactory.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubePlaylistLinkHandlerFactory.java index c55057af3..9954634fc 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubePlaylistUIHFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubePlaylistLinkHandlerFactory.java @@ -1,18 +1,18 @@ -package org.schabi.newpipe.extractor.services.youtube.urlIdHandlers; +package org.schabi.newpipe.extractor.services.youtube.linkHandler; -import org.schabi.newpipe.extractor.uih.ListUIHFactory; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.utils.Parser; import java.util.List; -public class YoutubePlaylistUIHFactory extends ListUIHFactory { +public class YoutubePlaylistLinkHandlerFactory extends ListLinkHandlerFactory { - private static final YoutubePlaylistUIHFactory instance = new YoutubePlaylistUIHFactory(); + private static final YoutubePlaylistLinkHandlerFactory instance = new YoutubePlaylistLinkHandlerFactory(); private static final String ID_PATTERN = "([\\-a-zA-Z0-9_]{10,})"; - public static YoutubePlaylistUIHFactory getInstance() { + public static YoutubePlaylistLinkHandlerFactory getInstance() { return instance; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubeSearchQIHFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeSearchQueryHandlerFactory.java similarity index 78% rename from extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubeSearchQIHFactory.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeSearchQueryHandlerFactory.java index db688f32d..803e74736 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubeSearchQIHFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeSearchQueryHandlerFactory.java @@ -1,13 +1,13 @@ -package org.schabi.newpipe.extractor.services.youtube.urlIdHandlers; +package org.schabi.newpipe.extractor.services.youtube.linkHandler; import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.uih.SearchQIHFactory; +import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandlerFactory; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.List; -public class YoutubeSearchQIHFactory extends SearchQIHFactory { +public class YoutubeSearchQueryHandlerFactory extends SearchQueryHandlerFactory { public static final String CHARSET_UTF_8 = "UTF-8"; @@ -16,8 +16,8 @@ public class YoutubeSearchQIHFactory extends SearchQIHFactory { public static final String PLAYLIST = "playlist"; public static final String ANY = "any"; - public static YoutubeSearchQIHFactory getInstance() { - return new YoutubeSearchQIHFactory(); + public static YoutubeSearchQueryHandlerFactory getInstance() { + return new YoutubeSearchQueryHandlerFactory(); } @Override @@ -45,9 +45,9 @@ public class YoutubeSearchQIHFactory extends SearchQIHFactory { @Override public String[] getAvailableContentFilter() { return new String[] { + ANY, STREAM, CHANNEL, - PLAYLIST, - ANY}; + PLAYLIST}; } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubeStreamUIHFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeStreamLinkHandlerFactory.java similarity index 93% rename from extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubeStreamUIHFactory.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeStreamLinkHandlerFactory.java index 95f9da499..b159e3ad8 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubeStreamUIHFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeStreamLinkHandlerFactory.java @@ -1,11 +1,11 @@ -package org.schabi.newpipe.extractor.services.youtube.urlIdHandlers; +package org.schabi.newpipe.extractor.services.youtube.linkHandler; import org.jsoup.Jsoup; 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.uih.UIHFactory; +import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory; 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 2018 - * YoutubeStreamUIHFactory.java is part of NewPipe. + * YoutubeStreamLinkHandlerFactory.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 . */ -public class YoutubeStreamUIHFactory extends UIHFactory { +public class YoutubeStreamLinkHandlerFactory extends LinkHandlerFactory { - private static final YoutubeStreamUIHFactory instance = new YoutubeStreamUIHFactory(); + private static final YoutubeStreamLinkHandlerFactory instance = new YoutubeStreamLinkHandlerFactory(); private static final String ID_PATTERN = "([\\-a-zA-Z0-9_]{11})"; - private YoutubeStreamUIHFactory() { + private YoutubeStreamLinkHandlerFactory() { } - public static YoutubeStreamUIHFactory getInstance() { + public static YoutubeStreamLinkHandlerFactory getInstance() { return instance; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubeTrendingUIHFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeTrendingLinkHandlerFactory.java similarity index 81% rename from extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubeTrendingUIHFactory.java rename to extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeTrendingLinkHandlerFactory.java index 823516197..e61693b08 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/urlIdHandlers/YoutubeTrendingUIHFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeTrendingLinkHandlerFactory.java @@ -1,10 +1,10 @@ -package org.schabi.newpipe.extractor.services.youtube.urlIdHandlers; +package org.schabi.newpipe.extractor.services.youtube.linkHandler; /* * Created by Christian Schabesberger on 12.08.17. * * Copyright (C) Christian Schabesberger 2018 - * YoutubeTrendingUIHFactory.java is part of NewPipe. + * YoutubeTrendingLinkHandlerFactory.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,12 @@ package org.schabi.newpipe.extractor.services.youtube.urlIdHandlers; * along with NewPipe. If not, see . */ -import org.schabi.newpipe.extractor.uih.ListUIHFactory; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory; import org.schabi.newpipe.extractor.utils.Parser; import java.util.List; -public class YoutubeTrendingUIHFactory extends ListUIHFactory { +public class YoutubeTrendingLinkHandlerFactory extends ListLinkHandlerFactory { public String getUrl(String id, List contentFilters, String sortFilter) { return "https://www.youtube.com/feed/trending"; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java index a4409c7a2..765a9fae4 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java @@ -23,10 +23,9 @@ 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.uih.UIHFactory; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.uih.UIHandler; +import org.schabi.newpipe.extractor.linkhandler.LinkHandler; import org.schabi.newpipe.extractor.utils.Parser; import javax.annotation.Nonnull; @@ -40,8 +39,8 @@ public abstract class StreamExtractor extends Extractor { public static final int NO_AGE_LIMIT = 0; - public StreamExtractor(StreamingService service, UIHandler uiHandler) { - super(service, uiHandler); + public StreamExtractor(StreamingService service, LinkHandler linkHandler) { + super(service, linkHandler); } @Nonnull @@ -136,9 +135,6 @@ public abstract class StreamExtractor extends Extractor { public abstract StreamInfoItem getNextVideo() throws IOException, ExtractionException; public abstract StreamInfoItemsCollector getRelatedVideos() throws IOException, ExtractionException; - public abstract String[] getDonationLinks() throws ExtractionException; - public abstract String[] getAffiliateLinks() throws ExtractionException; - /** * Analyses the webpage's document and extracts any error message there might be. * diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java index 9443e1ff4..f2633533f 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java @@ -242,16 +242,6 @@ public class StreamInfo extends Info { } catch (Exception e) { streamInfo.addError(e); } - try { - streamInfo.setAffiliateLinks(extractor.getAffiliateLinks()); - } catch (Exception e) { - streamInfo.addError(e); - } - try { - streamInfo.setDonationLinks(extractor.getDonationLinks()); - } catch (Exception e) { - streamInfo.addError(e); - } streamInfo.setRelatedStreams(ExtractorHelper.getRelatedVideosOrLogError(streamInfo, extractor)); return streamInfo; @@ -284,9 +274,6 @@ public class StreamInfo extends Info { private long startPosition = 0; private List subtitles; - private String[] donationLinks; - private String[] affiliateLinks; - /** * Get the stream type * @@ -480,19 +467,4 @@ public class StreamInfo extends Info { this.subtitles = subtitles; } - public String[] getDonationLinks() { - return donationLinks; - } - - public void setDonationLinks(String[] donationLinks) { - this.donationLinks = donationLinks; - } - - public String[] getAffiliateLinks() { - return affiliateLinks; - } - - public void setAffiliateLinks(String[] affiliateLinks) { - this.affiliateLinks = affiliateLinks; - } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java index 189e2f3d5..b7c640f50 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java @@ -15,7 +15,7 @@ import static org.junit.Assert.*; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; /** - * Test for {@link SoundcloudChartsUIHFactory} + * Test for {@link SoundcloudChartsLinkHandlerFactory} */ public class SoundcloudChartsExtractorTest { diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsUIHFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactoryTest.java similarity index 88% rename from extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsUIHFactoryTest.java rename to extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactoryTest.java index e5d8ca2bd..10066d597 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsUIHFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactoryTest.java @@ -11,14 +11,14 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /** - * Test for {@link SoundcloudChartsUIHFactory} + * Test for {@link SoundcloudChartsLinkHandlerFactory} */ -public class SoundcloudChartsUIHFactoryTest { - private static SoundcloudChartsUIHFactory urlIdHandler; +public class SoundcloudChartsLinkHandlerFactoryTest { + private static SoundcloudChartsLinkHandlerFactory urlIdHandler; @BeforeClass public static void setUp() throws Exception { - urlIdHandler = new SoundcloudChartsUIHFactory(); + urlIdHandler = new SoundcloudChartsLinkHandlerFactory(); NewPipe.init(Downloader.getInstance()); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamUIHFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamLinkHandlerFactoryTest.java similarity index 93% rename from extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamUIHFactoryTest.java rename to extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamLinkHandlerFactoryTest.java index 4084ac3bb..c2acd423b 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamUIHFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamLinkHandlerFactoryTest.java @@ -12,14 +12,14 @@ import java.util.List; import static org.junit.Assert.*; /** - * Test for {@link SoundcloudStreamUIHFactory} + * Test for {@link SoundcloudStreamLinkHandlerFactory} */ -public class SoundcloudStreamUIHFactoryTest { - private static SoundcloudStreamUIHFactory urlIdHandler; +public class SoundcloudStreamLinkHandlerFactoryTest { + private static SoundcloudStreamLinkHandlerFactory urlIdHandler; @BeforeClass public static void setUp() throws Exception { - urlIdHandler = SoundcloudStreamUIHFactory.getInstance(); + urlIdHandler = SoundcloudStreamLinkHandlerFactory.getInstance(); NewPipe.init(Downloader.getInstance()); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSubscriptionExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSubscriptionExtractorTest.java index ebb5c3512..6af125346 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSubscriptionExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSubscriptionExtractorTest.java @@ -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.uih.UIHFactory; +import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; import org.schabi.newpipe.extractor.subscription.SubscriptionItem; @@ -21,7 +21,7 @@ import static org.junit.Assert.*; */ public class SoundcloudSubscriptionExtractorTest { private static SoundcloudSubscriptionExtractor subscriptionExtractor; - private static UIHFactory urlHandler; + private static LinkHandlerFactory urlHandler; @BeforeClass public static void setupClass() { diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelUIHFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLinkHandlerFactoryTest.java similarity index 87% rename from extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelUIHFactoryTest.java rename to extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLinkHandlerFactoryTest.java index 1be835aa8..ccb8b4256 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelUIHFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLinkHandlerFactoryTest.java @@ -4,23 +4,22 @@ import org.junit.BeforeClass; import org.junit.Test; 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.YoutubeChannelUIHFactory; +import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /** - * Test for {@link YoutubeChannelUIHFactory} + * Test for {@link YoutubeChannelLinkHandlerFactory} */ -public class YoutubeChannelUIHFactoryTest { +public class YoutubeChannelLinkHandlerFactoryTest { - private static YoutubeChannelUIHFactory urlIdHandler; + private static YoutubeChannelLinkHandlerFactory urlIdHandler; @BeforeClass public static void setUp() { - urlIdHandler = YoutubeChannelUIHFactory.getInstance(); + urlIdHandler = YoutubeChannelLinkHandlerFactory.getInstance(); NewPipe.init(Downloader.getInstance()); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorControversialTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorControversialTest.java index a9a536d8f..1f5948064 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorControversialTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorControversialTest.java @@ -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.YoutubeStreamUIHFactory; +import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLinkHandlerFactory; 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 YoutubeStreamUIHFactory} + * Test for {@link YoutubeStreamLinkHandlerFactory} */ public class YoutubeStreamExtractorControversialTest { private static YoutubeStreamExtractor extractor; diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorRestrictedTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorRestrictedTest.java index fd40a5828..b8bee1a32 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorRestrictedTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorRestrictedTest.java @@ -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.YoutubeStreamUIHFactory; +import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLinkHandlerFactory; 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 YoutubeStreamUIHFactory} + * Test for {@link YoutubeStreamLinkHandlerFactory} */ public class YoutubeStreamExtractorRestrictedTest { public static final String HTTPS = "https://"; diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamUIHFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamLinkHandlerFactoryTest.java similarity index 96% rename from extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamUIHFactoryTest.java rename to extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamLinkHandlerFactoryTest.java index e2e6f401f..c71d19390 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamUIHFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamLinkHandlerFactoryTest.java @@ -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.YoutubeStreamUIHFactory; +import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLinkHandlerFactory; import java.util.ArrayList; import java.util.List; @@ -14,15 +14,15 @@ import java.util.List; import static org.junit.Assert.*; /** - * Test for {@link YoutubeStreamUIHFactory} + * Test for {@link YoutubeStreamLinkHandlerFactory} */ -public class YoutubeStreamUIHFactoryTest { +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 YoutubeStreamUIHFactory urlIdHandler; + private static YoutubeStreamLinkHandlerFactory urlIdHandler; @BeforeClass public static void setUp() { - urlIdHandler = YoutubeStreamUIHFactory.getInstance(); + urlIdHandler = YoutubeStreamLinkHandlerFactory.getInstance(); NewPipe.init(Downloader.getInstance()); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSubscriptionExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSubscriptionExtractorTest.java index cd921ae5b..a4ab4eeb9 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSubscriptionExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSubscriptionExtractorTest.java @@ -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.uih.UIHFactory; +import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSubscriptionExtractor; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; import org.schabi.newpipe.extractor.subscription.SubscriptionItem; @@ -23,7 +23,7 @@ import static org.junit.Assert.*; */ public class YoutubeSubscriptionExtractorTest { private static YoutubeSubscriptionExtractor subscriptionExtractor; - private static UIHFactory urlHandler; + private static LinkHandlerFactory urlHandler; @BeforeClass public static void setupClass() { diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java index 8ea4d91a0..bf1ae8bb7 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java @@ -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.YoutubeTrendingUIHFactory; +import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingLinkHandlerFactory; 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 YoutubeTrendingUIHFactory} + * Test for {@link YoutubeTrendingLinkHandlerFactory} */ public class YoutubeTrendingExtractorTest { diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java index 6f3fc38b2..a2b3ec47a 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java @@ -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.uih.UIHFactory; +import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory; 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; - UIHFactory UIHFactory = service.getKioskList().getUIHFactoryByType("Trending"); + LinkHandlerFactory LinkHandlerFactory = service.getKioskList().getUIHFactoryByType("Trending"); - kioskInfo = KioskInfo.getInfo(YouTube, UIHFactory.fromId("Trending").getUrl(), null); + kioskInfo = KioskInfo.getInfo(YouTube, LinkHandlerFactory.fromId("Trending").getUrl(), null); } @Test diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingLinkHandlerFactoryTest.java new file mode 100644 index 000000000..a6a18bd9f --- /dev/null +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingLinkHandlerFactoryTest.java @@ -0,0 +1,83 @@ +package org.schabi.newpipe.extractor.services.youtube; + +/* + * Created by Christian Schabesberger on 12.08.17. + * + * Copyright (C) Christian Schabesberger 2017 + * YoutubeTrendingLinkHandlerFactoryTest.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 . + */ + +import org.junit.BeforeClass; +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.linkhandler.LinkHandlerFactory; +import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingLinkHandlerFactory; + +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 YoutubeTrendingLinkHandlerFactory} + */ +public class YoutubeTrendingLinkHandlerFactoryTest { + private static LinkHandlerFactory LinkHandlerFactory; + + @BeforeClass + public static void setUp() throws Exception { + LinkHandlerFactory = YouTube.getKioskList().getUIHFactoryByType("Trending"); + NewPipe.init(Downloader.getInstance()); + } + + @Test + public void getUrl() + throws Exception { + assertEquals(LinkHandlerFactory.fromId("").getUrl(), "https://www.youtube.com/feed/trending"); + } + + @Test + public void getId() + throws Exception { + assertEquals(LinkHandlerFactory.fromUrl("https://www.youtube.com/feed/trending").getId(), "Trending"); + } + + @Test + public void acceptUrl() throws ParsingException { + assertTrue(LinkHandlerFactory.acceptUrl("https://www.youtube.com/feed/trending")); + assertTrue(LinkHandlerFactory.acceptUrl("https://www.youtube.com/feed/trending?adsf=fjaj#fhe")); + assertTrue(LinkHandlerFactory.acceptUrl("http://www.youtube.com/feed/trending")); + assertTrue(LinkHandlerFactory.acceptUrl("www.youtube.com/feed/trending")); + assertTrue(LinkHandlerFactory.acceptUrl("youtube.com/feed/trending")); + assertTrue(LinkHandlerFactory.acceptUrl("youtube.com/feed/trending?akdsakjf=dfije&kfj=dkjak")); + assertTrue(LinkHandlerFactory.acceptUrl("https://youtube.com/feed/trending")); + assertTrue(LinkHandlerFactory.acceptUrl("m.youtube.com/feed/trending")); + + assertFalse(LinkHandlerFactory.acceptUrl("https://youtu.be/feed/trending")); + assertFalse(LinkHandlerFactory.acceptUrl("kdskjfiiejfia")); + assertFalse(LinkHandlerFactory.acceptUrl("https://www.youtube.com/bullshit/feed/trending")); + assertFalse(LinkHandlerFactory.acceptUrl("https://www.youtube.com/feed/trending/bullshit")); + assertFalse(LinkHandlerFactory.acceptUrl("https://www.youtube.com/feed/bullshit/trending")); + assertFalse(LinkHandlerFactory.acceptUrl("peter klaut aepferl youtube.com/feed/trending")); + assertFalse(LinkHandlerFactory.acceptUrl("youtube.com/feed/trending askjkf")); + assertFalse(LinkHandlerFactory.acceptUrl("askdjfi youtube.com/feed/trending askjkf")); + assertFalse(LinkHandlerFactory.acceptUrl(" youtube.com/feed/trending")); + assertFalse(LinkHandlerFactory.acceptUrl("https://www.youtube.com/feed/trending.html")); + assertFalse(LinkHandlerFactory.acceptUrl("")); + } +} diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingUIHFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingUIHFactoryTest.java deleted file mode 100644 index 9d1fd3b69..000000000 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingUIHFactoryTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.schabi.newpipe.extractor.services.youtube; - -/* - * Created by Christian Schabesberger on 12.08.17. - * - * Copyright (C) Christian Schabesberger 2017 - * 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 . - */ - -import org.junit.BeforeClass; -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.uih.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().getUIHFactoryByType("Trending"); - NewPipe.init(Downloader.getInstance()); - } - - @Test - public void getUrl() - throws Exception { - assertEquals(UIHFactory.fromId("").getUrl(), "https://www.youtube.com/feed/trending"); - } - - @Test - public void getId() - throws Exception { - assertEquals(UIHFactory.fromUrl("https://www.youtube.com/feed/trending").getId(), "Trending"); - } - - @Test - public void acceptUrl() throws ParsingException { - 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("")); - } -}