Fix "Could not get id" for channels w/o "Subscribe" button

This commit is contained in:
Stypox 2019-08-27 13:15:06 +02:00 committed by Tobias Groza
parent 94e7f0d3ab
commit db3596c818
1 changed files with 5 additions and 0 deletions

View File

@ -82,6 +82,11 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
@Nonnull
@Override
public String getId() throws ParsingException {
try {
return doc.select("meta[itemprop=\"channelId\"]").first().attr("content");
} catch (Exception ignored) {}
// fallback method; does not work with channels that have no "Subscribe" button (e.g. EminemVEVO)
try {
Element element = doc.getElementsByClass("yt-uix-subscription-button").first();
if (element == null) element = doc.getElementsByClass("yt-uix-subscription-preferences-button").first();