Return null if channel has no banner

This commit is contained in:
wb9688 2020-02-24 13:01:13 +01:00 committed by TobiGr
parent 1eca63089b
commit a38ab9b791
1 changed files with 5 additions and 2 deletions

View File

@ -127,8 +127,11 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
@Override @Override
public String getBannerUrl() throws ParsingException { public String getBannerUrl() throws ParsingException {
try { try {
String url = initialData.getObject("header").getObject("c4TabbedHeaderRenderer").getObject("banner").getArray("thumbnails").getObject(0).getString("url"); String url = null;
if (url.contains("s.ytimg.com") || url.contains("default_banner")) { try {
url = initialData.getObject("header").getObject("c4TabbedHeaderRenderer").getObject("banner").getArray("thumbnails").getObject(0).getString("url");
} catch (Exception ignored) {}
if (url == null || url.contains("s.ytimg.com") || url.contains("default_banner")) {
return null; return null;
} }
// the first characters of the banner URLs are different for each channel and some are not even valid URLs // the first characters of the banner URLs are different for each channel and some are not even valid URLs