empty support returns "", same for empty description

This commit is contained in:
bopol 2020-01-23 14:37:14 +01:00
parent 74439f692a
commit 20da4750f8
2 changed files with 7 additions and 3 deletions

View File

@ -76,7 +76,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
try {
desc = JsonUtils.getString(json, "description");
} catch (ParsingException e) {
return "No description";
return "";
}
if (desc.length() == 250 && desc.substring(247).equals("...")) {
//if description is shortened, get full description
@ -256,7 +256,11 @@ public class PeertubeStreamExtractor extends StreamExtractor {
@Nonnull
@Override
public String getSupportInfo() throws ParsingException {
return JsonUtils.getString(json, "support");
try {
return JsonUtils.getString(json, "support");
} catch (ParsingException e) {
return "";
}
}
private String getRelatedStreamsUrl(List<String> tags) throws UnsupportedEncodingException {

View File

@ -61,7 +61,7 @@ public class PeertubeStreamExtractorDefaultTest {
public void testGetEmptyDescription() throws Exception {
PeertubeStreamExtractor extractorEmpty = (PeertubeStreamExtractor) PeerTube.getStreamExtractor("https://framatube.org/api/v1/videos/d5907aad-2252-4207-89ec-a4b687b9337d");
extractorEmpty.fetchPage();
assertEquals("No description", extractorEmpty.getDescription());
assertEquals("", extractorEmpty.getDescription());
}
@Test