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:
parent
a281519e77
commit
b382416372
|
@ -70,20 +70,23 @@ public class PeertubeStreamExtractor extends StreamExtractor {
|
|||
|
||||
@Override
|
||||
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();
|
||||
try {
|
||||
Response response = dl.get(getUrl() + "/description");
|
||||
JsonObject jsonObject = JsonParser.object().from(response.responseBody());
|
||||
description = JsonUtils.getString(jsonObject, "description");
|
||||
desc = JsonUtils.getString(jsonObject, "description");
|
||||
} catch (ReCaptchaException | IOException | JsonParserException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (description.equals("")) {
|
||||
//if the request above failed
|
||||
description = JsonUtils.getString(json, "description");
|
||||
}
|
||||
return description;
|
||||
return desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -353,7 +353,7 @@ public abstract class StreamExtractor extends Extractor {
|
|||
|
||||
/**
|
||||
* 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,
|
||||
* you can simply return an empty string.
|
||||
* @return the host of the stream or an empty String.
|
||||
|
|
Loading…
Reference in New Issue