Fix channel descriptions consisting of multiple parts
This commit is contained in:
parent
880b951088
commit
8ebd971648
2 changed files with 7 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
||||||
package org.schabi.newpipe.extractor.services.youtube.extractors;
|
package org.schabi.newpipe.extractor.services.youtube.extractors;
|
||||||
|
|
||||||
|
import com.grack.nanojson.JsonArray;
|
||||||
import com.grack.nanojson.JsonObject;
|
import com.grack.nanojson.JsonObject;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
|
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
|
||||||
|
@ -97,7 +98,11 @@ public class YoutubeChannelInfoItemExtractor implements ChannelInfoItemExtractor
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() throws ParsingException {
|
public String getDescription() throws ParsingException {
|
||||||
try {
|
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) {
|
} catch (Exception e) {
|
||||||
throw new ParsingException("Could not get description", e);
|
throw new ParsingException("Could not get description", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,9 +116,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
try {
|
try {
|
||||||
StringBuilder titleBuilder = new StringBuilder();
|
StringBuilder titleBuilder = new StringBuilder();
|
||||||
JsonArray titleArray = getVideoPrimaryInfoRenderer().getObject("title").getArray("runs");
|
JsonArray titleArray = getVideoPrimaryInfoRenderer().getObject("title").getArray("runs");
|
||||||
for (Object titlePart : titleArray) {
|
for (Object titlePart : titleArray)
|
||||||
titleBuilder.append(((JsonObject) titlePart).getString("text"));
|
titleBuilder.append(((JsonObject) titlePart).getString("text"));
|
||||||
}
|
|
||||||
title = titleBuilder.toString();
|
title = titleBuilder.toString();
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
if (title == null) {
|
if (title == null) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue