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
This commit is contained in:
bopol 2020-01-20 14:36:12 +01:00
parent a281519e77
commit b382416372
2 changed files with 15 additions and 12 deletions

View File

@ -70,20 +70,23 @@ public class PeertubeStreamExtractor extends StreamExtractor {
@Override @Override
public String getDescription() throws ParsingException { public String getDescription() throws ParsingException {
String description = ""; String desc;
try {
desc = JsonUtils.getString(json, "description");
} catch (ParsingException e) {
return "No description";
}
if (desc.length() >= 255 && desc.substring(desc.length() - 3).equals("...")) {
Downloader dl = NewPipe.getDownloader(); Downloader dl = NewPipe.getDownloader();
try { try {
Response response = dl.get(getUrl() + "/description"); Response response = dl.get(getUrl() + "/description");
JsonObject jsonObject = JsonParser.object().from(response.responseBody()); JsonObject jsonObject = JsonParser.object().from(response.responseBody());
description = JsonUtils.getString(jsonObject, "description"); desc = JsonUtils.getString(jsonObject, "description");
} catch (ReCaptchaException | IOException | JsonParserException e) { } catch (ReCaptchaException | IOException | JsonParserException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (description.equals("")) {
//if the request above failed
description = JsonUtils.getString(json, "description");
} }
return description; return desc;
} }
@Override @Override

View File

@ -353,7 +353,7 @@ public abstract class StreamExtractor extends Extractor {
/** /**
* The host of the stream (Eg. peertube.cpy.re). * The host of the stream (Eg. peertube.cpy.re).
* If the privacy is not available, or if the service doesn't use * If the host is not available, or if the service doesn't use
* a federated system, but a centralised system, * a federated system, but a centralised system,
* you can simply return an empty string. * you can simply return an empty string.
* @return the host of the stream or an empty String. * @return the host of the stream or an empty String.