Skip to content

Commit 0f8057a

Browse files
authored
Merge pull request #322 from wb9688/upgrade-jsoup
Upgrade dependencies
2 parents 60e6df7 + 8f71bde commit 0f8057a

14 files changed

Lines changed: 94 additions & 60 deletions

File tree

extractor/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ dependencies {
22
implementation project(':timeago-parser')
33

44
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
5-
implementation 'org.jsoup:jsoup:1.9.2'
6-
implementation 'org.mozilla:rhino:1.7.7.1'
7-
implementation 'com.github.spotbugs:spotbugs-annotations:3.1.0'
8-
implementation 'org.nibor.autolink:autolink:0.8.0'
5+
implementation 'org.jsoup:jsoup:1.13.1'
6+
implementation 'org.mozilla:rhino:1.7.12'
7+
implementation 'com.github.spotbugs:spotbugs-annotations:4.0.2'
8+
implementation 'org.nibor.autolink:autolink:0.10.0'
99

10-
testImplementation 'junit:junit:4.12'
10+
testImplementation 'junit:junit:4.13'
1111
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import com.grack.nanojson.JsonObject;
44
import com.grack.nanojson.JsonParser;
55
import com.grack.nanojson.JsonParserException;
6-
import org.jsoup.helper.StringUtil;
6+
77
import org.schabi.newpipe.extractor.NewPipe;
88
import org.schabi.newpipe.extractor.downloader.Downloader;
99
import org.schabi.newpipe.extractor.downloader.Response;
1010
import org.schabi.newpipe.extractor.exceptions.ParsingException;
1111
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
1212
import org.schabi.newpipe.extractor.utils.JsonUtils;
13+
import org.schabi.newpipe.extractor.utils.Utils;
1314

1415
import java.io.IOException;
1516

@@ -43,7 +44,7 @@ public void fetchInstanceMetaData() throws Exception {
4344
throw new Exception("unable to configure instance " + url, e);
4445
}
4546

46-
if (response == null || StringUtil.isBlank(response.responseBody())) {
47+
if (response == null || Utils.isBlank(response.responseBody())) {
4748
throw new Exception("unable to configure instance " + url);
4849
}
4950

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

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

33
import com.grack.nanojson.JsonObject;
4-
import org.jsoup.helper.StringUtil;
4+
55
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
66
import org.schabi.newpipe.extractor.exceptions.ParsingException;
77
import org.schabi.newpipe.extractor.utils.Parser;
8+
import org.schabi.newpipe.extractor.utils.Utils;
89

910
import java.text.ParseException;
1011
import java.text.SimpleDateFormat;
@@ -24,7 +25,7 @@ private PeertubeParsingHelper() {
2425

2526
public static void validate(JsonObject json) throws ContentNotAvailableException {
2627
String error = json.getString("error");
27-
if (!StringUtil.isBlank(error)) {
28+
if (!Utils.isBlank(error)) {
2829
throw new ContentNotAvailableException(error);
2930
}
3031
}
@@ -51,7 +52,7 @@ public static String getNextPageUrl(String prevPageUrl, long total) {
5152
} catch (Parser.RegexException e) {
5253
return "";
5354
}
54-
if (StringUtil.isBlank(prevStart)) return "";
55+
if (Utils.isBlank(prevStart)) return "";
5556
long nextStart = 0;
5657
try {
5758
nextStart = Long.parseLong(prevStart) + ITEMS_PER_PAGE;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.grack.nanojson.JsonObject;
55
import com.grack.nanojson.JsonParser;
66
import com.grack.nanojson.JsonParserException;
7-
import org.jsoup.helper.StringUtil;
7+
88
import org.schabi.newpipe.extractor.StreamingService;
99
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
1010
import org.schabi.newpipe.extractor.downloader.Downloader;
@@ -16,6 +16,7 @@
1616
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
1717
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
1818
import org.schabi.newpipe.extractor.utils.JsonUtils;
19+
import org.schabi.newpipe.extractor.utils.Utils;
1920

2021
import java.io.IOException;
2122

@@ -119,7 +120,7 @@ public String getNextPageUrl() throws IOException, ExtractionException {
119120
public InfoItemsPage<StreamInfoItem> getPage(String pageUrl) throws IOException, ExtractionException {
120121
Response response = getDownloader().get(pageUrl);
121122
JsonObject json = null;
122-
if (response != null && !StringUtil.isBlank(response.responseBody())) {
123+
if (response != null && !Utils.isBlank(response.responseBody())) {
123124
try {
124125
json = JsonParser.object().from(response.responseBody());
125126
} catch (Exception e) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.grack.nanojson.JsonObject;
55
import com.grack.nanojson.JsonParser;
66
import com.grack.nanojson.JsonParserException;
7-
import org.jsoup.helper.StringUtil;
7+
88
import org.schabi.newpipe.extractor.StreamingService;
99
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
1010
import org.schabi.newpipe.extractor.downloader.Downloader;
@@ -18,6 +18,7 @@
1818
import org.schabi.newpipe.extractor.utils.JsonUtils;
1919
import org.schabi.newpipe.extractor.utils.Parser;
2020
import org.schabi.newpipe.extractor.utils.Parser.RegexException;
21+
import org.schabi.newpipe.extractor.utils.Utils;
2122

2223
import java.io.IOException;
2324

@@ -127,7 +128,7 @@ public String getNextPageUrl() throws IOException, ExtractionException {
127128
public InfoItemsPage<StreamInfoItem> getPage(String pageUrl) throws IOException, ExtractionException {
128129
Response response = getDownloader().get(pageUrl);
129130
JsonObject json = null;
130-
if (null != response && !StringUtil.isBlank(response.responseBody())) {
131+
if (response != null && !Utils.isBlank(response.responseBody())) {
131132
try {
132133
json = JsonParser.object().from(response.responseBody());
133134
} catch (Exception e) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.grack.nanojson.JsonArray;
44
import com.grack.nanojson.JsonObject;
55
import com.grack.nanojson.JsonParser;
6-
import org.jsoup.helper.StringUtil;
6+
77
import org.schabi.newpipe.extractor.StreamingService;
88
import org.schabi.newpipe.extractor.comments.CommentsExtractor;
99
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
@@ -17,6 +17,7 @@
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;
2021

2122
import java.io.IOException;
2223

@@ -65,7 +66,7 @@ public String getNextPageUrl() throws IOException, ExtractionException {
6566
public InfoItemsPage<CommentsInfoItem> getPage(String pageUrl) throws IOException, ExtractionException {
6667
Response response = getDownloader().get(pageUrl);
6768
JsonObject json = null;
68-
if (null != response && !StringUtil.isBlank(response.responseBody())) {
69+
if (response != null && !Utils.isBlank(response.responseBody())) {
6970
try {
7071
json = JsonParser.object().from(response.responseBody());
7172
} catch (Exception e) {
@@ -88,5 +89,4 @@ public InfoItemsPage<CommentsInfoItem> getPage(String pageUrl) throws IOExceptio
8889
public void onFetchPage(Downloader downloader) throws IOException, ExtractionException {
8990
this.initPage = getPage(getUrl() + "?" + START_KEY + "=0&" + COUNT_KEY + "=" + ITEMS_PER_PAGE);
9091
}
91-
9292
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.grack.nanojson.JsonArray;
44
import com.grack.nanojson.JsonObject;
55
import com.grack.nanojson.JsonParser;
6-
import org.jsoup.helper.StringUtil;
6+
77
import org.schabi.newpipe.extractor.InfoItem;
88
import org.schabi.newpipe.extractor.InfoItemExtractor;
99
import org.schabi.newpipe.extractor.InfoItemsCollector;
@@ -19,6 +19,7 @@
1919
import org.schabi.newpipe.extractor.utils.JsonUtils;
2020
import org.schabi.newpipe.extractor.utils.Parser;
2121
import org.schabi.newpipe.extractor.utils.Parser.RegexException;
22+
import org.schabi.newpipe.extractor.utils.Utils;
2223

2324
import javax.annotation.Nonnull;
2425
import java.io.IOException;
@@ -84,7 +85,7 @@ public String getNextPageUrl() throws IOException, ExtractionException {
8485
public InfoItemsPage<InfoItem> getPage(String pageUrl) throws IOException, ExtractionException {
8586
Response response = getDownloader().get(pageUrl);
8687
JsonObject json = null;
87-
if (null != response && !StringUtil.isBlank(response.responseBody())) {
88+
if (null != response && !Utils.isBlank(response.responseBody())) {
8889
try {
8990
json = JsonParser.object().from(response.responseBody());
9091
} catch (Exception e) {
@@ -104,5 +105,4 @@ public InfoItemsPage<InfoItem> getPage(String pageUrl) throws IOException, Extra
104105
public void onFetchPage(Downloader downloader) throws IOException, ExtractionException {
105106
initPage = getPage(getUrl() + "&" + START_KEY + "=0&" + COUNT_KEY + "=" + ITEMS_PER_PAGE);
106107
}
107-
108108
}

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.grack.nanojson.JsonObject;
55
import com.grack.nanojson.JsonParser;
66
import com.grack.nanojson.JsonParserException;
7-
import org.jsoup.helper.StringUtil;
7+
88
import org.schabi.newpipe.extractor.MediaFormat;
99
import org.schabi.newpipe.extractor.NewPipe;
1010
import org.schabi.newpipe.extractor.StreamingService;
@@ -17,10 +17,18 @@
1717
import org.schabi.newpipe.extractor.localization.DateWrapper;
1818
import org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper;
1919
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeSearchQueryHandlerFactory;
20-
import org.schabi.newpipe.extractor.stream.*;
20+
import org.schabi.newpipe.extractor.stream.AudioStream;
21+
import org.schabi.newpipe.extractor.stream.Description;
22+
import org.schabi.newpipe.extractor.stream.Stream;
23+
import org.schabi.newpipe.extractor.stream.StreamExtractor;
24+
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
25+
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
26+
import org.schabi.newpipe.extractor.stream.StreamType;
27+
import org.schabi.newpipe.extractor.stream.SubtitlesStream;
28+
import org.schabi.newpipe.extractor.stream.VideoStream;
2129
import org.schabi.newpipe.extractor.utils.JsonUtils;
30+
import org.schabi.newpipe.extractor.utils.Utils;
2231

23-
import javax.annotation.Nonnull;
2432
import java.io.IOException;
2533
import java.io.UnsupportedEncodingException;
2634
import java.net.URLEncoder;
@@ -29,6 +37,8 @@
2937
import java.util.List;
3038
import java.util.Locale;
3139

40+
import javax.annotation.Nonnull;
41+
3242
public class PeertubeStreamExtractor extends StreamExtractor {
3343

3444

@@ -255,7 +265,7 @@ public StreamInfoItemsCollector getRelatedStreams() throws IOException, Extracti
255265
} else {
256266
apiUrl = getUploaderUrl() + "/videos?start=0&count=8";
257267
}
258-
if (!StringUtil.isBlank(apiUrl)) getStreamsFromApi(collector, apiUrl);
268+
if (!Utils.isBlank(apiUrl)) getStreamsFromApi(collector, apiUrl);
259269
return collector;
260270
}
261271

@@ -292,7 +302,7 @@ private String getRelatedStreamsUrl(List<String> tags) throws UnsupportedEncodin
292302
private void getStreamsFromApi(StreamInfoItemsCollector collector, String apiUrl) throws ReCaptchaException, IOException, ParsingException {
293303
Response response = getDownloader().get(apiUrl);
294304
JsonObject relatedVideosJson = null;
295-
if (null != response && !StringUtil.isBlank(response.responseBody())) {
305+
if (null != response && !Utils.isBlank(response.responseBody())) {
296306
try {
297307
relatedVideosJson = JsonParser.object().from(response.responseBody());
298308
} catch (JsonParserException e) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.grack.nanojson.JsonArray;
44
import com.grack.nanojson.JsonObject;
55
import com.grack.nanojson.JsonParser;
6-
import org.jsoup.helper.StringUtil;
6+
77
import org.schabi.newpipe.extractor.StreamingService;
88
import org.schabi.newpipe.extractor.downloader.Downloader;
99
import org.schabi.newpipe.extractor.downloader.Response;
@@ -15,6 +15,7 @@
1515
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
1616
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
1717
import org.schabi.newpipe.extractor.utils.JsonUtils;
18+
import org.schabi.newpipe.extractor.utils.Utils;
1819

1920
import java.io.IOException;
2021

@@ -69,7 +70,7 @@ public String getNextPageUrl() throws IOException, ExtractionException {
6970
public InfoItemsPage<StreamInfoItem> getPage(String pageUrl) throws IOException, ExtractionException {
7071
Response response = getDownloader().get(pageUrl);
7172
JsonObject json = null;
72-
if (null != response && !StringUtil.isBlank(response.responseBody())) {
73+
if (response != null && !Utils.isBlank(response.responseBody())) {
7374
try {
7475
json = JsonParser.object().from(response.responseBody());
7576
} catch (Exception e) {

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java

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

3-
43
import com.grack.nanojson.JsonArray;
54
import com.grack.nanojson.JsonObject;
65
import com.grack.nanojson.JsonParser;
@@ -111,9 +110,7 @@ public static boolean isInvidioURL(URL url) {
111110

112111
public static long parseDurationString(String input)
113112
throws ParsingException, NumberFormatException {
114-
115113
// If time separator : is not detected, try . instead
116-
117114
final String[] splitInput = input.contains(":")
118115
? input.split(":")
119116
: input.split("\\.");
@@ -145,10 +142,10 @@ public static long parseDurationString(String input)
145142
default:
146143
throw new ParsingException("Error duration string with unknown format: " + input);
147144
}
148-
return ((((Long.parseLong(days) * 24)
149-
+ Long.parseLong(hours) * 60)
150-
+ Long.parseLong(minutes)) * 60)
151-
+ Long.parseLong(seconds);
145+
return (((Long.parseLong(Utils.removeNonDigitCharacters(days)) * 24)
146+
+ Long.parseLong(Utils.removeNonDigitCharacters(hours)) * 60)
147+
+ Long.parseLong(Utils.removeNonDigitCharacters(minutes)) * 60)
148+
+ Long.parseLong(Utils.removeNonDigitCharacters(seconds));
152149
}
153150

154151
public static String getFeedUrlFrom(final String channelIdOrUser) {

0 commit comments

Comments
 (0)