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 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

View File

@ -13,8 +13,8 @@ import java.util.List;
*/
public abstract class ListExtractor<R extends InfoItem> 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<R extends InfoItem> extends Extractor {
}
@Override
public ListLinkHandler getUIHandler() {
return (ListLinkHandler) super.getUIHandler();
public ListLinkHandler getLinkHandler() {
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 {
ChannelInfo info = new ChannelInfo(extractor.getServiceId(),
extractor.getUIHandler(),
extractor.getLinkHandler(),
extractor.getName());

View File

@ -68,7 +68,7 @@ public class KioskInfo extends ListInfo<StreamInfoItem> {
public static KioskInfo getInfo(KioskExtractor extractor) throws ExtractionException {
final KioskInfo info = new KioskInfo(extractor.getServiceId(),
extractor.getUIHandler(),
extractor.getLinkHandler(),
extractor.getName());
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(
extractor.getServiceId(),
extractor.getUIHandler(),
extractor.getLinkHandler(),
extractor.getName());
try {

View File

@ -25,7 +25,7 @@ public abstract class SearchExtractor extends ListExtractor<InfoItem> {
}
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<InfoItem> {
}
@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() {

View File

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

View File

@ -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();

View File

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

View File

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

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.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);