From dc0d0bda244d8decf448a62c2d42ea965646bed8 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 15 Sep 2018 20:12:52 +0200 Subject: [PATCH] replace uiHandler name with linkhandler --- .../schabi/newpipe/extractor/Extractor.java | 18 +++++++++--------- .../newpipe/extractor/ListExtractor.java | 8 ++++---- .../extractor/channel/ChannelInfo.java | 2 +- .../newpipe/extractor/kiosk/KioskInfo.java | 2 +- .../extractor/playlist/PlaylistInfo.java | 2 +- .../extractor/search/SearchExtractor.java | 8 ++++---- .../newpipe/extractor/search/SearchInfo.java | 2 +- .../SoundcloudChannelExtractor.java | 2 +- .../SoundcloudPlaylistExtractor.java | 2 +- .../soundcloud/SoundcloudStreamExtractor.java | 4 ++-- .../newpipe/extractor/utils/Localization.java | 19 +++++++++++++++++++ .../search/YoutubeSearchCountTest.java | 4 +--- 12 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 extractor/src/main/java/org/schabi/newpipe/extractor/utils/Localization.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 ac2d7ca3e..02999dc9f 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java @@ -15,17 +15,17 @@ public abstract class Extractor { */ private final StreamingService service; - private final LinkHandler uIHandler; + private final LinkHandler linkHandler; @Nullable private boolean pageFetched = false; private final Downloader downloader; - public Extractor(final StreamingService service, final LinkHandler uIHandler) { + public Extractor(final StreamingService service, final LinkHandler linkHandler) { if(service == null) throw new NullPointerException("service is null"); - if(uIHandler == null) throw new NullPointerException("LinkHandler is null"); + if(linkHandler == null) throw new NullPointerException("LinkHandler is null"); this.service = service; - this.uIHandler = uIHandler; + this.linkHandler = linkHandler; this.downloader = NewPipe.getDownloader(); if(downloader == null) throw new NullPointerException("downloader is null"); } @@ -34,8 +34,8 @@ public abstract class Extractor { * @return The {@link LinkHandler} of the current extractor object (e.g. a ChannelExtractor should return a channel url handler). */ @Nonnull - public LinkHandler getUIHandler() { - return uIHandler; + public LinkHandler getLinkHandler() { + return linkHandler; } /** @@ -67,7 +67,7 @@ public abstract class Extractor { @Nonnull public String getId() throws ParsingException { - return uIHandler.getId(); + return linkHandler.getId(); } /** @@ -80,12 +80,12 @@ public abstract class Extractor { @Nonnull public String getOriginalUrl() throws ParsingException { - return uIHandler.getOriginalUrl(); + return linkHandler.getOriginalUrl(); } @Nonnull public String getUrl() throws ParsingException { - return uIHandler.getUrl(); + return linkHandler.getUrl(); } @Nonnull 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 51cabe92f..b254adbd8 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java @@ -13,8 +13,8 @@ import java.util.List; */ public abstract class ListExtractor extends Extractor { - public ListExtractor(StreamingService service, ListLinkHandler uiHandler) { - super(service, uiHandler); + public ListExtractor(StreamingService service, ListLinkHandler linkHandler) { + super(service, linkHandler); } /** @@ -51,8 +51,8 @@ public abstract class ListExtractor extends Extractor { } @Override - public ListLinkHandler getUIHandler() { - return (ListLinkHandler) super.getUIHandler(); + public ListLinkHandler getLinkHandler() { + return (ListLinkHandler) super.getLinkHandler(); } /*////////////////////////////////////////////////////////////////////////// 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 297b689e4..11c80c86e 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 @@ -55,7 +55,7 @@ public class ChannelInfo extends ListInfo { public static ChannelInfo getInfo(ChannelExtractor extractor) throws IOException, ExtractionException { ChannelInfo info = new ChannelInfo(extractor.getServiceId(), - extractor.getUIHandler(), + extractor.getLinkHandler(), extractor.getName()); 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 6c357bd19..95f0ed0e8 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 @@ -68,7 +68,7 @@ public class KioskInfo extends ListInfo { public static KioskInfo getInfo(KioskExtractor extractor) throws ExtractionException { final KioskInfo info = new KioskInfo(extractor.getServiceId(), - extractor.getUIHandler(), + extractor.getLinkHandler(), extractor.getName()); final ListExtractor.InfoItemsPage itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor); 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 1eb35723d..f55662a26 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 @@ -41,7 +41,7 @@ public class PlaylistInfo extends ListInfo { final PlaylistInfo info = new PlaylistInfo( extractor.getServiceId(), - extractor.getUIHandler(), + extractor.getLinkHandler(), extractor.getName()); try { 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 ebbf76a66..f94c1325b 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 @@ -25,7 +25,7 @@ public abstract class SearchExtractor extends ListExtractor { } public String getSearchString() { - return getUIHandler().getSearchString(); + return getLinkHandler().getSearchString(); } public abstract String getSearchSuggestion() throws ParsingException; @@ -35,13 +35,13 @@ public abstract class SearchExtractor extends ListExtractor { } @Override - public SearchQueryHandler getUIHandler() { - return (SearchQueryHandler) super.getUIHandler(); + public SearchQueryHandler getLinkHandler() { + return (SearchQueryHandler) super.getLinkHandler(); } @Override public String getName() { - return getUIHandler().getSearchString(); + return getLinkHandler().getSearchString(); } protected String getContentCountry() { 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 27b622332..1ec1d7946 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 @@ -33,7 +33,7 @@ public class SearchInfo extends ListInfo { public static SearchInfo getInfo(SearchExtractor extractor) throws ExtractionException, IOException { final SearchInfo info = new SearchInfo( extractor.getServiceId(), - extractor.getUIHandler(), + extractor.getLinkHandler(), extractor.getSearchString()); try { 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 1b6778698..f2d6a0268 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 @@ -31,7 +31,7 @@ public class SoundcloudChannelExtractor extends ChannelExtractor { @Override public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { - userId = getUIHandler().getId(); + userId = getLinkHandler().getId(); String apiUrl = "https://api-v2.soundcloud.com/users/" + userId + "?client_id=" + SoundcloudParsingHelper.clientId(); 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 20c454d6e..9a3846e6b 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 @@ -30,7 +30,7 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor { @Override public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { - playlistId = getUIHandler().getId(); + playlistId = getLinkHandler().getId(); String apiUrl = "https://api.soundcloud.com/playlists/" + playlistId + "?client_id=" + SoundcloudParsingHelper.clientId() + "&representation=compact"; 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 dbd9971c9..eaddc1149 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 @@ -21,8 +21,8 @@ import java.util.List; public class SoundcloudStreamExtractor extends StreamExtractor { private JsonObject track; - public SoundcloudStreamExtractor(StreamingService service, LinkHandler uIHandler) { - super(service, uIHandler); + public SoundcloudStreamExtractor(StreamingService service, LinkHandler linkHandler) { + super(service, linkHandler); } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/utils/Localization.java b/extractor/src/main/java/org/schabi/newpipe/extractor/utils/Localization.java new file mode 100644 index 000000000..d4f5ddbc0 --- /dev/null +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/utils/Localization.java @@ -0,0 +1,19 @@ +package org.schabi.newpipe.extractor.utils; + +public class Localization { + private final String country; + private final String language; + + public Localization(String country, String language) { + this.country = country; + this.language = language; + } + + public String getCountry() { + return country; + } + + public String getLanguage() { + return language; + } +} diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchCountTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchCountTest.java index 745b6a0a1..aa79893fe 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchCountTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchCountTest.java @@ -3,7 +3,6 @@ package org.schabi.newpipe.extractor.services.youtube.search; import org.junit.BeforeClass; import org.junit.Test; import org.schabi.newpipe.Downloader; -import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor; @@ -25,8 +24,7 @@ public class YoutubeSearchCountTest { } @Test - public void testViewCount() throws Exception { - boolean foundKnownChannel = false; + public void testViewCount() { ChannelInfoItem ci = (ChannelInfoItem) itemsPage.getItems().get(0); assertTrue("Count does not fit: " + Long.toString(ci.getSubscriberCount()), 65043316 < ci.getSubscriberCount() && ci.getSubscriberCount() < 68043316);