From 850043babb95eda2d38625ee468e795f062542f2 Mon Sep 17 00:00:00 2001 From: pypy Date: Wed, 8 May 2019 18:44:03 +0900 Subject: [PATCH 1/2] fix warning (channel id) --- youtube_dl/extractor/youtube.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index 4002dcfdd..ff2652cd7 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -2100,8 +2100,12 @@ class YoutubeIE(YoutubeBaseInfoExtractor): else: self._downloader.report_warning('unable to extract uploader nickname') - channel_id = self._html_search_meta( - 'channelId', video_webpage, 'channel id') + channel_id = None + if video_details: + channel_id = str_or_none(video_details.get('channelId')) + if channel_id is None: + channel_id = self._html_search_meta( + 'channelId', video_webpage, 'channel id') channel_url = 'http://www.youtube.com/channel/%s' % channel_id if channel_id else None # thumbnail image From ddc928571a34660e3fd91084b605463b67a04036 Mon Sep 17 00:00:00 2001 From: Sergey M Date: Thu, 9 May 2019 00:58:00 +0700 Subject: [PATCH 2/2] Update youtube.py --- youtube_dl/extractor/youtube.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index ff2652cd7..da202b9bc 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -2100,12 +2100,13 @@ class YoutubeIE(YoutubeBaseInfoExtractor): else: self._downloader.report_warning('unable to extract uploader nickname') - channel_id = None - if video_details: - channel_id = str_or_none(video_details.get('channelId')) - if channel_id is None: - channel_id = self._html_search_meta( - 'channelId', video_webpage, 'channel id') + channel_id = ( + str_or_none(video_details.get('channelId')) or + self._html_search_meta( + 'channelId', video_webpage, 'channel id', default=None) or + self._search_regex( + r'data-channel-external-id=(["\'])(?P(?:(?!\1).)+)\1', + video_webpage, 'channel id', default=None, group='id')) channel_url = 'http://www.youtube.com/channel/%s' % channel_id if channel_id else None # thumbnail image