replace uiHandler name with linkhandler

This commit is contained in:
Christian Schabesberger 2018-09-15 20:12:52 +02:00
parent 1e7bcfbd66
commit dc0d0bda24
12 changed files with 45 additions and 28 deletions

View File

@ -15,17 +15,17 @@ public abstract class Extractor {
*/ */
private final StreamingService service; private final StreamingService service;
private final LinkHandler uIHandler; private final LinkHandler linkHandler;
@Nullable @Nullable
private boolean pageFetched = false; private boolean pageFetched = false;
private final Downloader downloader; private final Downloader downloader;
public Extractor(final StreamingService service, final LinkHandler uIHandler) { public Extractor(final StreamingService service, final LinkHandler linkHandler) {
if(service == null) throw new NullPointerException("service is null"); 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.service = service;
this.uIHandler = uIHandler; this.linkHandler = linkHandler;
this.downloader = NewPipe.getDownloader(); this.downloader = NewPipe.getDownloader();
if(downloader == null) throw new NullPointerException("downloader is null"); 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). * @return The {@link LinkHandler} of the current extractor object (e.g. a ChannelExtractor should return a channel url handler).
*/ */
@Nonnull @Nonnull
public LinkHandler getUIHandler() { public LinkHandler getLinkHandler() {
return uIHandler; return linkHandler;
} }
/** /**
@ -67,7 +67,7 @@ public abstract class Extractor {
@Nonnull @Nonnull
public String getId() throws ParsingException { public String getId() throws ParsingException {
return uIHandler.getId(); return linkHandler.getId();
} }
/** /**
@ -80,12 +80,12 @@ public abstract class Extractor {
@Nonnull @Nonnull
public String getOriginalUrl() throws ParsingException { public String getOriginalUrl() throws ParsingException {
return uIHandler.getOriginalUrl(); return linkHandler.getOriginalUrl();
} }
@Nonnull @Nonnull
public String getUrl() throws ParsingException { public String getUrl() throws ParsingException {
return uIHandler.getUrl(); return linkHandler.getUrl();
} }
@Nonnull @Nonnull

View File

@ -13,8 +13,8 @@ import java.util.List;
*/ */
public abstract class ListExtractor<R extends InfoItem> extends Extractor { public abstract class ListExtractor<R extends InfoItem> extends Extractor {
public ListExtractor(StreamingService service, ListLinkHandler uiHandler) { public ListExtractor(StreamingService service, ListLinkHandler linkHandler) {
super(service, uiHandler); super(service, linkHandler);
} }
/** /**
@ -51,8 +51,8 @@ public abstract class ListExtractor<R extends InfoItem> extends Extractor {
} }
@Override @Override
public ListLinkHandler getUIHandler() { public ListLinkHandler getLinkHandler() {
return (ListLinkHandler) super.getUIHandler(); return (ListLinkHandler) super.getLinkHandler();
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////

View File

@ -55,7 +55,7 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
public static ChannelInfo getInfo(ChannelExtractor extractor) throws IOException, ExtractionException { public static ChannelInfo getInfo(ChannelExtractor extractor) throws IOException, ExtractionException {
ChannelInfo info = new ChannelInfo(extractor.getServiceId(), ChannelInfo info = new ChannelInfo(extractor.getServiceId(),
extractor.getUIHandler(), extractor.getLinkHandler(),
extractor.getName()); extractor.getName());

View File

@ -68,7 +68,7 @@ public class KioskInfo extends ListInfo<StreamInfoItem> {
public static KioskInfo getInfo(KioskExtractor extractor) throws ExtractionException { public static KioskInfo getInfo(KioskExtractor extractor) throws ExtractionException {
final KioskInfo info = new KioskInfo(extractor.getServiceId(), final KioskInfo info = new KioskInfo(extractor.getServiceId(),
extractor.getUIHandler(), extractor.getLinkHandler(),
extractor.getName()); extractor.getName());
final ListExtractor.InfoItemsPage<StreamInfoItem> itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor); final ListExtractor.InfoItemsPage<StreamInfoItem> itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor);

View File

@ -41,7 +41,7 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
final PlaylistInfo info = new PlaylistInfo( final PlaylistInfo info = new PlaylistInfo(
extractor.getServiceId(), extractor.getServiceId(),
extractor.getUIHandler(), extractor.getLinkHandler(),
extractor.getName()); extractor.getName());
try { try {

View File

@ -25,7 +25,7 @@ public abstract class SearchExtractor extends ListExtractor<InfoItem> {
} }
public String getSearchString() { public String getSearchString() {
return getUIHandler().getSearchString(); return getLinkHandler().getSearchString();
} }
public abstract String getSearchSuggestion() throws ParsingException; public abstract String getSearchSuggestion() throws ParsingException;
@ -35,13 +35,13 @@ public abstract class SearchExtractor extends ListExtractor<InfoItem> {
} }
@Override @Override
public SearchQueryHandler getUIHandler() { public SearchQueryHandler getLinkHandler() {
return (SearchQueryHandler) super.getUIHandler(); return (SearchQueryHandler) super.getLinkHandler();
} }
@Override @Override
public String getName() { public String getName() {
return getUIHandler().getSearchString(); return getLinkHandler().getSearchString();
} }
protected String getContentCountry() { protected String getContentCountry() {

View File

@ -33,7 +33,7 @@ public class SearchInfo extends ListInfo<InfoItem> {
public static SearchInfo getInfo(SearchExtractor extractor) throws ExtractionException, IOException { public static SearchInfo getInfo(SearchExtractor extractor) throws ExtractionException, IOException {
final SearchInfo info = new SearchInfo( final SearchInfo info = new SearchInfo(
extractor.getServiceId(), extractor.getServiceId(),
extractor.getUIHandler(), extractor.getLinkHandler(),
extractor.getSearchString()); extractor.getSearchString());
try { try {

View File

@ -31,7 +31,7 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
@Override @Override
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
userId = getUIHandler().getId(); userId = getLinkHandler().getId();
String apiUrl = "https://api-v2.soundcloud.com/users/" + userId + String apiUrl = "https://api-v2.soundcloud.com/users/" + userId +
"?client_id=" + SoundcloudParsingHelper.clientId(); "?client_id=" + SoundcloudParsingHelper.clientId();

View File

@ -30,7 +30,7 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
@Override @Override
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
playlistId = getUIHandler().getId(); playlistId = getLinkHandler().getId();
String apiUrl = "https://api.soundcloud.com/playlists/" + playlistId + String apiUrl = "https://api.soundcloud.com/playlists/" + playlistId +
"?client_id=" + SoundcloudParsingHelper.clientId() + "?client_id=" + SoundcloudParsingHelper.clientId() +
"&representation=compact"; "&representation=compact";

View File

@ -21,8 +21,8 @@ import java.util.List;
public class SoundcloudStreamExtractor extends StreamExtractor { public class SoundcloudStreamExtractor extends StreamExtractor {
private JsonObject track; private JsonObject track;
public SoundcloudStreamExtractor(StreamingService service, LinkHandler uIHandler) { public SoundcloudStreamExtractor(StreamingService service, LinkHandler linkHandler) {
super(service, uIHandler); super(service, linkHandler);
} }
@Override @Override

View File

@ -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;
}
}

View File

@ -3,7 +3,6 @@ package org.schabi.newpipe.extractor.services.youtube.search;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.schabi.newpipe.Downloader; import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor;
@ -25,8 +24,7 @@ public class YoutubeSearchCountTest {
} }
@Test @Test
public void testViewCount() throws Exception { public void testViewCount() {
boolean foundKnownChannel = false;
ChannelInfoItem ci = (ChannelInfoItem) itemsPage.getItems().get(0); ChannelInfoItem ci = (ChannelInfoItem) itemsPage.getItems().get(0);
assertTrue("Count does not fit: " + Long.toString(ci.getSubscriberCount()), assertTrue("Count does not fit: " + Long.toString(ci.getSubscriberCount()),
65043316 < ci.getSubscriberCount() && ci.getSubscriberCount() < 68043316); 65043316 < ci.getSubscriberCount() && ci.getSubscriberCount() < 68043316);