added getBaseUrl method to linkhandler
This commit is contained in:
parent
279f175693
commit
bc75c6603b
|
@ -1,5 +1,10 @@
|
|||
package org.schabi.newpipe.extractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.schabi.newpipe.extractor.downloader.Downloader;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
|
@ -8,11 +13,6 @@ import org.schabi.newpipe.extractor.localization.ContentCountry;
|
|||
import org.schabi.newpipe.extractor.localization.Localization;
|
||||
import org.schabi.newpipe.extractor.localization.TimeAgoParser;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
public abstract class Extractor{
|
||||
/**
|
||||
* {@link StreamingService} currently related to this extractor.<br>
|
||||
|
@ -93,6 +93,11 @@ public abstract class Extractor{
|
|||
public String getUrl() throws ParsingException {
|
||||
return linkHandler.getUrl();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public String getBaseUrl() throws ParsingException {
|
||||
return linkHandler.getBaseUrl();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public StreamingService getService() {
|
||||
|
|
|
@ -2,6 +2,9 @@ package org.schabi.newpipe.extractor.linkhandler;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
public class LinkHandler implements Serializable {
|
||||
protected final String originalUrl;
|
||||
protected final String url;
|
||||
|
@ -28,4 +31,8 @@ public class LinkHandler implements Serializable {
|
|||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getBaseUrl() throws ParsingException {
|
||||
return Utils.getBaseUrl(url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ public class PeertubeService extends StreamingService {
|
|||
return instance.getUrl();
|
||||
}
|
||||
|
||||
public void setInstance(PeertubeInstance instance) throws IOException {
|
||||
public void setInstance(PeertubeInstance instance) {
|
||||
this.instance = instance;
|
||||
this.getServiceInfo().setName(instance.getName());
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
|||
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
||||
import org.schabi.newpipe.extractor.utils.Parser;
|
||||
import org.schabi.newpipe.extractor.utils.Parser.RegexException;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import com.grack.nanojson.JsonArray;
|
||||
import com.grack.nanojson.JsonObject;
|
||||
|
@ -38,7 +37,7 @@ public class PeertubeChannelExtractor extends ChannelExtractor {
|
|||
|
||||
public PeertubeChannelExtractor(StreamingService service, ListLinkHandler linkHandler) throws ParsingException {
|
||||
super(service, linkHandler);
|
||||
this.baseUrl = Utils.getBaseUrl(getUrl());
|
||||
this.baseUrl = getBaseUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -56,7 +56,7 @@ public class PeertubeCommentsExtractor extends CommentsExtractor {
|
|||
for(Object c: contents) {
|
||||
if(c instanceof JsonObject) {
|
||||
final JsonObject item = (JsonObject) c;
|
||||
PeertubeCommentsInfoItemExtractor extractor = new PeertubeCommentsInfoItemExtractor(item, pageUrl);
|
||||
PeertubeCommentsInfoItemExtractor extractor = new PeertubeCommentsInfoItemExtractor(item, this);
|
||||
collector.commit(extractor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
||||
import org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper;
|
||||
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import com.grack.nanojson.JsonObject;
|
||||
|
||||
|
@ -19,10 +18,10 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac
|
|||
private final String url;
|
||||
private final String baseUrl;
|
||||
|
||||
public PeertubeCommentsInfoItemExtractor(JsonObject item, String url) throws ParsingException {
|
||||
public PeertubeCommentsInfoItemExtractor(JsonObject item, PeertubeCommentsExtractor extractor) throws ParsingException {
|
||||
this.item = item;
|
||||
this.url = url;
|
||||
this.baseUrl = Utils.getBaseUrl(url);
|
||||
this.url = extractor.getUrl();
|
||||
this.baseUrl = extractor.getBaseUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.schabi.newpipe.extractor.search.SearchExtractor;
|
|||
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
||||
import org.schabi.newpipe.extractor.utils.Parser;
|
||||
import org.schabi.newpipe.extractor.utils.Parser.RegexException;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import com.grack.nanojson.JsonArray;
|
||||
import com.grack.nanojson.JsonObject;
|
||||
|
@ -59,7 +58,7 @@ public class PeertubeSearchExtractor extends SearchExtractor {
|
|||
throw new ParsingException("unable to extract search info", e);
|
||||
}
|
||||
|
||||
String baseUrl = Utils.getBaseUrl(getUrl());
|
||||
String baseUrl = getBaseUrl();
|
||||
for(Object c: contents) {
|
||||
if(c instanceof JsonObject) {
|
||||
final JsonObject item = (JsonObject) c;
|
||||
|
|
|
@ -45,7 +45,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
|
|||
|
||||
public PeertubeStreamExtractor(StreamingService service, LinkHandler linkHandler) throws ParsingException {
|
||||
super(service, linkHandler);
|
||||
this.baseUrl = Utils.getBaseUrl(getUrl());
|
||||
this.baseUrl = getBaseUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,6 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
|||
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
||||
import org.schabi.newpipe.extractor.utils.Parser;
|
||||
import org.schabi.newpipe.extractor.utils.Parser.RegexException;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import com.grack.nanojson.JsonArray;
|
||||
import com.grack.nanojson.JsonObject;
|
||||
|
@ -54,7 +53,7 @@ public class PeertubeTrendingExtractor extends KioskExtractor {
|
|||
throw new ParsingException("unable to extract kiosk info", e);
|
||||
}
|
||||
|
||||
String baseUrl = Utils.getBaseUrl(getUrl());
|
||||
String baseUrl = getBaseUrl();
|
||||
for(Object c: contents) {
|
||||
if(c instanceof JsonObject) {
|
||||
final JsonObject item = (JsonObject) c;
|
||||
|
|
Loading…
Reference in New Issue