Thumbnail

This commit is contained in:
ViruZs 2020-07-30 18:10:47 +05:30 committed by GitHub
parent 0cc8dc08ca
commit 2a3f7e2117
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2231,12 +2231,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
video_uploader_id = mobj.group('uploader_id') video_uploader_id = mobj.group('uploader_id')
video_uploader_url = mobj.group('uploader_url') video_uploader_url = mobj.group('uploader_url')
else: else:
owner_profile_url = url_or_none(microformat.get('ownerProfileUrl')) self._downloader.report_warning('unable to extract uploader nickname')
if owner_profile_url:
video_uploader_id = self._search_regex(
r'(?:user|channel)/([^/]+)', owner_profile_url, 'uploader id',
default=None)
video_uploader_url = owner_profile_url
channel_id = ( channel_id = (
str_or_none(video_details.get('channelId')) str_or_none(video_details.get('channelId'))
@ -2247,33 +2242,16 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
video_webpage, 'channel id', default=None, group='id')) video_webpage, 'channel id', default=None, group='id'))
channel_url = 'http://www.youtube.com/channel/%s' % channel_id if channel_id else None channel_url = 'http://www.youtube.com/channel/%s' % channel_id if channel_id else None
thumbnails = [] # thumbnail image
thumbnails_list = try_get( # We try first to get a high quality image:
video_details, lambda x: x['thumbnail']['thumbnails'], list) or [] m_thumb = re.search(r'<span itemprop="thumbnail".*?href="(.*?)">',video_webpage, re.DOTALL)
for t in thumbnails_list: if m_thumb is not None:
if not isinstance(t, dict): video_thumbnail = m_thumb.group(1)
continue elif 'thumbnail_url' not in video_info:
thumbnail_url = url_or_none(t.get('url')) self._downloader.report_warning('unable to extract video thumbnail')
if not thumbnail_url:
continue
thumbnails.append({
'url': thumbnail_url,
'width': int_or_none(t.get('width')),
'height': int_or_none(t.get('height')),
})
if not thumbnails:
video_thumbnail = None video_thumbnail = None
# We try first to get a high quality image: else: # don't panic if we can't find it
m_thumb = re.search(r'<span itemprop="thumbnail".*?href="(.*?)">', video_thumbnail = compat_urllib_parse_unquote_plus(video_info['thumbnail_url'][0])
video_webpage, re.DOTALL)
if m_thumb is not None:
video_thumbnail = m_thumb.group(1)
thumbnail_url = try_get(video_info, lambda x: x['thumbnail_url'][0], compat_str)
if thumbnail_url:
video_thumbnail = compat_urllib_parse_unquote_plus(thumbnail_url)
if video_thumbnail:
thumbnails.append({'url': video_thumbnail})
# upload date # upload date
upload_date = self._html_search_meta( upload_date = self._html_search_meta(
@ -2512,7 +2490,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'creator': video_creator or artist, 'creator': video_creator or artist,
'title': video_title, 'title': video_title,
'alt_title': video_alt_title or track, 'alt_title': video_alt_title or track,
'thumbnails': thumbnails, 'thumbnail': video_thumbnail,
'description': video_description, 'description': video_description,
'categories': video_categories, 'categories': video_categories,
'tags': video_tags, 'tags': video_tags,