Fix channel descriptions consisting of multiple parts

This commit is contained in:
wb9688 2020-02-27 10:06:35 +01:00
parent 880b951088
commit 8ebd971648
2 changed files with 7 additions and 3 deletions

View file

@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube.extractors;
import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject;
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
@ -97,7 +98,11 @@ public class YoutubeChannelInfoItemExtractor implements ChannelInfoItemExtractor
@Override
public String getDescription() throws ParsingException {
try {
return channelInfoItem.getObject("descriptionSnippet").getArray("runs").getObject(0).getString("text");
StringBuilder description = new StringBuilder();
JsonArray descriptionArray = channelInfoItem.getObject("descriptionSnippet").getArray("runs");
for (Object descriptionPart : descriptionArray)
description.append(((JsonObject) descriptionPart).getString("text"));
return description.toString();
} catch (Exception e) {
throw new ParsingException("Could not get description", e);
}

View file

@ -116,9 +116,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
try {
StringBuilder titleBuilder = new StringBuilder();
JsonArray titleArray = getVideoPrimaryInfoRenderer().getObject("title").getArray("runs");
for (Object titlePart : titleArray) {
for (Object titlePart : titleArray)
titleBuilder.append(((JsonObject) titlePart).getString("text"));
}
title = titleBuilder.toString();
} catch (Exception ignored) {}
if (title == null) {