Skip to content

Commit

Permalink
make less tests fail
Browse files Browse the repository at this point in the history
  • Loading branch information
theScrabi committed Jul 1, 2018
1 parent e8ceb3e commit ced37ab
Show file tree
Hide file tree
Showing 59 changed files with 581 additions and 398 deletions.
22 changes: 12 additions & 10 deletions extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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 javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -14,27 +16,27 @@ public abstract class Extractor {
*/
private final StreamingService service;

private final UIHFactory UIHFactory;
private final org.schabi.newpipe.extractor.uih.UIHandler uIHandler;

@Nullable
private boolean pageFetched = false;
private final Downloader downloader;

public Extractor(final StreamingService service, final UIHFactory UIHFactory) {
public Extractor(final StreamingService service, final UIHandler uIHandler) {
if(service == null) throw new NullPointerException("service is null");
if(UIHFactory == null) throw new NullPointerException("UIHFactory is null");
if(uIHandler == null) throw new NullPointerException("UIHandler is null");
this.service = service;
this.UIHFactory = UIHFactory;
this.uIHandler = uIHandler;
this.downloader = NewPipe.getDownloader();
if(downloader == null) throw new NullPointerException("downloader is null");
}

/**
* @return The {@link UIHFactory} of the current extractor object (e.g. a ChannelExtractor should return a channel url handler).
* @return The {@link UIHandler} of the current extractor object (e.g. a ChannelExtractor should return a channel url handler).
*/
@Nonnull
public UIHFactory getUIHFactory() {
return UIHFactory;
public UIHandler getUIHandler() {
return uIHandler;
}

/**
Expand Down Expand Up @@ -66,7 +68,7 @@ protected boolean isPageFetched() {

@Nonnull
public String getId() throws ParsingException {
return UIHFactory.getId();
return uIHandler.getId();
}

/**
Expand All @@ -79,12 +81,12 @@ public String getId() throws ParsingException {

@Nonnull
public String getOriginalUrl() throws ParsingException {
return UIHFactory.getOriginalUrl();
return uIHandler.getOriginalUrl();
}

@Nonnull
public String getUrl() throws ParsingException {
return UIHFactory.getUrl();
return uIHandler.getUrl();
}

@Nonnull
Expand Down
12 changes: 7 additions & 5 deletions extractor/src/main/java/org/schabi/newpipe/extractor/Info.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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 java.io.Serializable;
import java.util.ArrayList;
Expand All @@ -18,7 +20,7 @@ public abstract class Info implements Serializable {
/**
* Different than the {@link #originalUrl} in the sense that it <i>may</i> be set as a cleaned url.
*
* @see UIHFactory#getUrl()
* @see UIHandler#getUrl()
* @see Extractor#getOriginalUrl()
*/
private final String url;
Expand Down Expand Up @@ -48,11 +50,11 @@ public Info(int serviceId, String id, String url, String originalUrl, String nam
this.name = name;
}

public Info(int serviceId, UIHFactory UIHFactory, String name) throws ParsingException {
public Info(int serviceId, UIHandler uiHandler, String name) {
this(serviceId,
UIHFactory.getId(),
UIHFactory.getUrl(),
UIHFactory.getOriginalUrl(),
uiHandler.getId(),
uiHandler.getUrl(),
uiHandler.getOriginalUrl(),
name);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
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 javax.annotation.Nonnull;
import javax.swing.plaf.ListUI;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
Expand All @@ -12,8 +15,8 @@
*/
public abstract class ListExtractor<R extends InfoItem> extends Extractor {

public ListExtractor(StreamingService service, ListUIHFactory urlIdHandler) {
super(service, urlIdHandler);
public ListExtractor(StreamingService service, ListUIHandler uiHandler) {
super(service, uiHandler);
}

/**
Expand Down Expand Up @@ -50,8 +53,8 @@ public boolean hasNextPage() throws IOException, ExtractionException {
}

@Override
public ListUIHFactory getUIHFactory() {
return (ListUIHFactory) super.getUIHFactory();
public ListUIHandler getUIHandler() {
return (ListUIHandler) super.getUIHandler();
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package org.schabi.newpipe.extractor;

import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.uih.ListUIHandler;

import java.util.ArrayList;
import java.util.List;

public abstract class ListInfo<T extends InfoItem> extends Info {
private List<T> relatedItems;
private String nextPageUrl = null;
private List<String> contentFilter = new ArrayList<>();
private List<String> contentFilters = new ArrayList<>();
private String sortFilter = "";

public ListInfo(int serviceId,
Expand All @@ -19,13 +20,13 @@ public ListInfo(int serviceId,
List<String> contentFilter,
String sortFilter) {
super(serviceId, id, url, originalUrl, name);
this.contentFilter = contentFilter;
this.contentFilters = contentFilter;
this.sortFilter = sortFilter;
}

public ListInfo(int serviceId, ListUIHFactory listUrlIdHandler, String name) throws ParsingException {
public ListInfo(int serviceId, ListUIHandler listUrlIdHandler, String name) throws ParsingException {
super(serviceId, listUrlIdHandler, name);
this.contentFilter = listUrlIdHandler.getContentFilter();
this.contentFilters = listUrlIdHandler.getContentFilters();
this.sortFilter = listUrlIdHandler.getSortFilter();
}

Expand All @@ -49,8 +50,8 @@ public void setNextPageUrl(String pageUrl) {
this.nextPageUrl = pageUrl;
}

public List<String> getContentFilter() {
return contentFilter;
public List<String> getContentFilters() {
return contentFilters;
}

public String getSortFilter() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,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.search.SearchQIHFactory;
import org.schabi.newpipe.extractor.uih.*;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;

Expand Down Expand Up @@ -76,41 +76,41 @@ public String toString() {
////////////////////////////////////////////
// Extractor
////////////////////////////////////////////
public abstract SearchExtractor getSearchExtractor(SearchQIHFactory queryHandler, String contentCountry);
public abstract SearchExtractor getSearchExtractor(SearchQIHandler queryHandler, String contentCountry);
public abstract SuggestionExtractor getSuggestionExtractor();
public abstract SubscriptionExtractor getSubscriptionExtractor();
public abstract KioskList getKioskList() throws ExtractionException;

public abstract ChannelExtractor getChannelExtractor(ListUIHFactory urlIdHandler) throws ExtractionException;
public abstract PlaylistExtractor getPlaylistExtractor(ListUIHFactory urlIdHandler) throws ExtractionException;
public abstract StreamExtractor getStreamExtractor(UIHFactory UIHFactory) throws ExtractionException;
public abstract ChannelExtractor getChannelExtractor(ListUIHandler urlIdHandler) throws ExtractionException;
public abstract PlaylistExtractor getPlaylistExtractor(ListUIHandler urlIdHandler) throws ExtractionException;
public abstract StreamExtractor getStreamExtractor(UIHandler UIHFactory) throws ExtractionException;

public SearchExtractor getSearchExtractor(String query, List<String> contentFilter, String sortFilter, String contentCountry) throws ExtractionException {
return getSearchExtractor(getSearchQIHFactory().setQuery(query, contentFilter, sortFilter), contentCountry);
return getSearchExtractor(getSearchQIHFactory().fromQuery(query, contentFilter, sortFilter), contentCountry);
}

public ChannelExtractor getChannelExtractor(String id, List<String> contentFilter, String sortFilter) throws ExtractionException {
return getChannelExtractor(getChannelUIHFactory().setQuery(id, contentFilter, sortFilter));
return getChannelExtractor(getChannelUIHFactory().fromQuery(id, contentFilter, sortFilter));
}

public PlaylistExtractor getPlaylistExtractor(String id, List<String> contentFilter, String sortFilter) throws ExtractionException {
return getPlaylistExtractor(getPlaylistUIHFactory().setQuery(id, contentFilter, sortFilter));
return getPlaylistExtractor(getPlaylistUIHFactory().fromQuery(id, contentFilter, sortFilter));
}

public SearchExtractor getSearchExtractor(String query, String contentCountry) throws ExtractionException {
return getSearchExtractor(getSearchQIHFactory().setQuery(query), contentCountry);
return getSearchExtractor(getSearchQIHFactory().fromQuery(query), contentCountry);
}

public ChannelExtractor getChannelExtractor(String url) throws ExtractionException {
return getChannelExtractor(getChannelUIHFactory().setUrl(url));
return getChannelExtractor(getChannelUIHFactory().fromUrl(url));
}

public PlaylistExtractor getPlaylistExtractor(String url) throws ExtractionException {
return getPlaylistExtractor(getPlaylistUIHFactory().setUrl(url));
return getPlaylistExtractor(getPlaylistUIHFactory().fromUrl(url));
}

public StreamExtractor getStreamExtractor(String url) throws ExtractionException {
return getStreamExtractor(getStreamUIHFactory().setUrl(url));
return getStreamExtractor(getStreamUIHFactory().fromUrl(url));
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.schabi.newpipe.extractor.channel;

import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.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;

/*
* Created by Christian Schabesberger on 25.07.16.
Expand All @@ -28,7 +28,7 @@

public abstract class ChannelExtractor extends ListExtractor<StreamInfoItem> {

public ChannelExtractor(StreamingService service, ListUIHFactory urlIdHandler) {
public ChannelExtractor(StreamingService service, ListUIHandler urlIdHandler) {
super(service, urlIdHandler);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
import org.schabi.newpipe.extractor.ListInfo;
import org.schabi.newpipe.extractor.ListUIHFactory;
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.utils.ExtractorHelper;

import java.io.IOException;
Expand All @@ -34,7 +35,7 @@

public class ChannelInfo extends ListInfo<StreamInfoItem> {

public ChannelInfo(int serviceId, ListUIHFactory urlIdHandler, String name) throws ParsingException {
public ChannelInfo(int serviceId, ListUIHandler urlIdHandler, String name) throws ParsingException {
super(serviceId, urlIdHandler, name);
}

Expand All @@ -55,7 +56,7 @@ public static InfoItemsPage<StreamInfoItem> getMoreItems(StreamingService servic
public static ChannelInfo getInfo(ChannelExtractor extractor) throws IOException, ExtractionException {

ChannelInfo info = new ChannelInfo(extractor.getServiceId(),
extractor.getUIHFactory(),
extractor.getUIHandler(),
extractor.getName());


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
*/

import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.ListUIHFactory;
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 javax.annotation.Nonnull;

Expand All @@ -33,7 +34,7 @@ public abstract class KioskExtractor extends ListExtractor<StreamInfoItem> {
private final String id;

public KioskExtractor(StreamingService streamingService,
ListUIHFactory urlIdHandler,
ListUIHandler urlIdHandler,
String kioskId) {
super(streamingService, urlIdHandler);
this.id = kioskId;
Expand Down
Loading

0 comments on commit ced37ab

Please sign in to comment.