Skip to content

Commit bc75c66

Browse files
committed
added getBaseUrl method to linkhandler
1 parent 279f175 commit bc75c66

9 files changed

Lines changed: 26 additions & 18 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package org.schabi.newpipe.extractor;
22

3+
import java.io.IOException;
4+
5+
import javax.annotation.Nonnull;
6+
import javax.annotation.Nullable;
7+
38
import org.schabi.newpipe.extractor.downloader.Downloader;
49
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
510
import org.schabi.newpipe.extractor.exceptions.ParsingException;
@@ -8,11 +13,6 @@
813
import org.schabi.newpipe.extractor.localization.Localization;
914
import org.schabi.newpipe.extractor.localization.TimeAgoParser;
1015

11-
import javax.annotation.Nonnull;
12-
import javax.annotation.Nullable;
13-
import java.io.IOException;
14-
import java.io.Serializable;
15-
1616
public abstract class Extractor{
1717
/**
1818
* {@link StreamingService} currently related to this extractor.<br>
@@ -93,6 +93,11 @@ public String getOriginalUrl() throws ParsingException {
9393
public String getUrl() throws ParsingException {
9494
return linkHandler.getUrl();
9595
}
96+
97+
@Nonnull
98+
public String getBaseUrl() throws ParsingException {
99+
return linkHandler.getBaseUrl();
100+
}
96101

97102
@Nonnull
98103
public StreamingService getService() {

extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandler.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import java.io.Serializable;
44

5+
import org.schabi.newpipe.extractor.exceptions.ParsingException;
6+
import org.schabi.newpipe.extractor.utils.Utils;
7+
58
public class LinkHandler implements Serializable {
69
protected final String originalUrl;
710
protected final String url;
@@ -28,4 +31,8 @@ public String getUrl() {
2831
public String getId() {
2932
return id;
3033
}
34+
35+
public String getBaseUrl() throws ParsingException {
36+
return Utils.getBaseUrl(url);
37+
}
3138
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public String getBaseUrl() {
122122
return instance.getUrl();
123123
}
124124

125-
public void setInstance(PeertubeInstance instance) throws IOException {
125+
public void setInstance(PeertubeInstance instance) {
126126
this.instance = instance;
127127
this.getServiceInfo().setName(instance.getName());
128128
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.schabi.newpipe.extractor.utils.JsonUtils;
1717
import org.schabi.newpipe.extractor.utils.Parser;
1818
import org.schabi.newpipe.extractor.utils.Parser.RegexException;
19-
import org.schabi.newpipe.extractor.utils.Utils;
2019

2120
import com.grack.nanojson.JsonArray;
2221
import com.grack.nanojson.JsonObject;
@@ -38,7 +37,7 @@ public class PeertubeChannelExtractor extends ChannelExtractor {
3837

3938
public PeertubeChannelExtractor(StreamingService service, ListLinkHandler linkHandler) throws ParsingException {
4039
super(service, linkHandler);
41-
this.baseUrl = Utils.getBaseUrl(getUrl());
40+
this.baseUrl = getBaseUrl();
4241
}
4342

4443
@Override

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private void collectStreamsFrom(CommentsInfoItemsCollector collector, JsonObject
5656
for(Object c: contents) {
5757
if(c instanceof JsonObject) {
5858
final JsonObject item = (JsonObject) c;
59-
PeertubeCommentsInfoItemExtractor extractor = new PeertubeCommentsInfoItemExtractor(item, pageUrl);
59+
PeertubeCommentsInfoItemExtractor extractor = new PeertubeCommentsInfoItemExtractor(item, this);
6060
collector.commit(extractor);
6161
}
6262
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsInfoItemExtractor.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.schabi.newpipe.extractor.localization.DateWrapper;
99
import org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper;
1010
import org.schabi.newpipe.extractor.utils.JsonUtils;
11-
import org.schabi.newpipe.extractor.utils.Utils;
1211

1312
import com.grack.nanojson.JsonObject;
1413

@@ -19,10 +18,10 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac
1918
private final String url;
2019
private final String baseUrl;
2120

22-
public PeertubeCommentsInfoItemExtractor(JsonObject item, String url) throws ParsingException {
21+
public PeertubeCommentsInfoItemExtractor(JsonObject item, PeertubeCommentsExtractor extractor) throws ParsingException {
2322
this.item = item;
24-
this.url = url;
25-
this.baseUrl = Utils.getBaseUrl(url);
23+
this.url = extractor.getUrl();
24+
this.baseUrl = extractor.getBaseUrl();
2625
}
2726

2827
@Override

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeSearchExtractor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.schabi.newpipe.extractor.utils.JsonUtils;
1818
import org.schabi.newpipe.extractor.utils.Parser;
1919
import org.schabi.newpipe.extractor.utils.Parser.RegexException;
20-
import org.schabi.newpipe.extractor.utils.Utils;
2120

2221
import com.grack.nanojson.JsonArray;
2322
import com.grack.nanojson.JsonObject;
@@ -59,7 +58,7 @@ private InfoItemsCollector<InfoItem, InfoItemExtractor> collectStreamsFrom(JsonO
5958
throw new ParsingException("unable to extract search info", e);
6059
}
6160

62-
String baseUrl = Utils.getBaseUrl(getUrl());
61+
String baseUrl = getBaseUrl();
6362
for(Object c: contents) {
6463
if(c instanceof JsonObject) {
6564
final JsonObject item = (JsonObject) c;

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
4545

4646
public PeertubeStreamExtractor(StreamingService service, LinkHandler linkHandler) throws ParsingException {
4747
super(service, linkHandler);
48-
this.baseUrl = Utils.getBaseUrl(getUrl());
48+
this.baseUrl = getBaseUrl();
4949
}
5050

5151
@Override

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeTrendingExtractor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.schabi.newpipe.extractor.utils.JsonUtils;
1616
import org.schabi.newpipe.extractor.utils.Parser;
1717
import org.schabi.newpipe.extractor.utils.Parser.RegexException;
18-
import org.schabi.newpipe.extractor.utils.Utils;
1918

2019
import com.grack.nanojson.JsonArray;
2120
import com.grack.nanojson.JsonObject;
@@ -54,7 +53,7 @@ private void collectStreamsFrom(StreamInfoItemsCollector collector, JsonObject j
5453
throw new ParsingException("unable to extract kiosk info", e);
5554
}
5655

57-
String baseUrl = Utils.getBaseUrl(getUrl());
56+
String baseUrl = getBaseUrl();
5857
for(Object c: contents) {
5958
if(c instanceof JsonObject) {
6059
final JsonObject item = (JsonObject) c;

0 commit comments

Comments
 (0)