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
parent 9893a922d0
commit 045a02e735
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
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();