Fix getting uploader for videoRenderer

This commit is contained in:
wb9688 2020-02-22 20:33:05 +01:00 committed by TobiGr
parent b88188d419
commit 957db062ef
1 changed files with 23 additions and 6 deletions

View File

@ -104,20 +104,37 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor {
@Override @Override
public String getUploaderName() throws ParsingException { public String getUploaderName() throws ParsingException {
String name = null;
try { try {
return videoInfo.getObject("longBylineText").getArray("runs") name = videoInfo.getObject("longBylineText").getArray("runs")
.getObject(0).getString("text"); .getObject(0).getString("text");
} catch (Exception e) { } catch (Exception ignored) {}
throw new ParsingException("Could not get uploader name", e); if (name == null) {
try {
name = videoInfo.getObject("ownerText").getArray("runs")
.getObject(0).getString("text");
} catch (Exception ignored) {}
} }
if (name != null && !name.isEmpty()) return name;
throw new ParsingException("Could not get uploader name");
} }
@Override @Override
public String getUploaderUrl() throws ParsingException { public String getUploaderUrl() throws ParsingException {
try { try {
String id = videoInfo.getObject("longBylineText").getArray("runs") String id = null;
try {
id = videoInfo.getObject("longBylineText").getArray("runs")
.getObject(0).getObject("navigationEndpoint") .getObject(0).getObject("navigationEndpoint")
.getObject("browseEndpoint").getString("browseId"); .getObject("browseEndpoint").getString("browseId");
} catch (Exception ignored) {}
if (id == null) {
try {
id = videoInfo.getObject("ownerText").getArray("runs")
.getObject(0).getObject("navigationEndpoint")
.getObject("browseEndpoint").getString("browseId");
} catch (Exception ignored) {}
}
if (id == null || id.isEmpty()) { if (id == null || id.isEmpty()) {
throw new IllegalArgumentException("is empty"); throw new IllegalArgumentException("is empty");
} }