Skip to content

Commit b382416

Browse files
committed
changed the way to extract peertube description
if the description length is above 254, and ends with ..., it means the description we got from the first request is shortened. why above 254: because in fact, shortened descriptions length are between 255 : https://framatube.org/videos/watch/24efbe1b-73c0-4d72-a3ff-77c8b32d3fcd https://framatube.org/videos/watch/1ca99f40-fb5b-4fa4-abe5-4d54325df7fc and 269: https://framatube.org/videos/watch/4d661d5f-a884-4510-bca8-15cb19aa3fe5 also fixed a typo in StreamExtractor.java
1 parent a281519 commit b382416

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,23 @@ public String getThumbnailUrl() throws ParsingException {
7070

7171
@Override
7272
public String getDescription() throws ParsingException {
73-
String description = "";
74-
Downloader dl = NewPipe.getDownloader();
73+
String desc;
7574
try {
76-
Response response = dl.get(getUrl() + "/description");
77-
JsonObject jsonObject = JsonParser.object().from(response.responseBody());
78-
description = JsonUtils.getString(jsonObject, "description");
79-
} catch (ReCaptchaException | IOException | JsonParserException e) {
80-
e.printStackTrace();
75+
desc = JsonUtils.getString(json, "description");
76+
} catch (ParsingException e) {
77+
return "No description";
8178
}
82-
if (description.equals("")) {
83-
//if the request above failed
84-
description = JsonUtils.getString(json, "description");
79+
if (desc.length() >= 255 && desc.substring(desc.length() - 3).equals("...")) {
80+
Downloader dl = NewPipe.getDownloader();
81+
try {
82+
Response response = dl.get(getUrl() + "/description");
83+
JsonObject jsonObject = JsonParser.object().from(response.responseBody());
84+
desc = JsonUtils.getString(jsonObject, "description");
85+
} catch (ReCaptchaException | IOException | JsonParserException e) {
86+
e.printStackTrace();
87+
}
8588
}
86-
return description;
89+
return desc;
8790
}
8891

8992
@Override

extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ protected long getTimestampSeconds(String regexPattern) throws ParsingException
353353

354354
/**
355355
* The host of the stream (Eg. peertube.cpy.re).
356-
* If the privacy is not available, or if the service doesn't use
356+
* If the host is not available, or if the service doesn't use
357357
* a federated system, but a centralised system,
358358
* you can simply return an empty string.
359359
* @return the host of the stream or an empty String.

0 commit comments

Comments
 (0)