mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-12-24 17:25:52 +01:00
[toggle] Extract thumbnails
This commit is contained in:
parent
ffaf6e66e3
commit
c40dbb19ab
@ -2,6 +2,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import json
|
||||
import re
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..utils import (
|
||||
@ -119,12 +120,8 @@ class ToggleSgIE(InfoExtractor):
|
||||
info = self._download_json(req, video_id, 'Downloading video info json')
|
||||
|
||||
title = info['MediaName']
|
||||
duration = int_or_none(info.get('Duration'))
|
||||
thumbnail = info.get('PicURL')
|
||||
description = info.get('Description')
|
||||
created_at = parse_iso8601(info.get('CreationDate') or None)
|
||||
formats = []
|
||||
|
||||
formats = []
|
||||
for video_file in info.get('Files', []):
|
||||
ext = determine_ext(video_file['URL'])
|
||||
vid_format = video_file['Format'].replace(' ', '')
|
||||
@ -146,19 +143,40 @@ class ToggleSgIE(InfoExtractor):
|
||||
'preference': self._FORMAT_PREFERENCES.get(ext + '-' + vid_format) or -1,
|
||||
'format_note': 'DRM-protected video' if ext == 'wvm' else None
|
||||
})
|
||||
|
||||
if not formats:
|
||||
# Most likely because geo-blocked
|
||||
raise ExtractorError('No downloadable videos found', expected=True)
|
||||
|
||||
self._sort_formats(formats)
|
||||
|
||||
duration = int_or_none(info.get('Duration'))
|
||||
description = info.get('Description')
|
||||
created_at = parse_iso8601(info.get('CreationDate') or None)
|
||||
|
||||
thumbnails = []
|
||||
for picture in info.get('Pictures', []):
|
||||
if not isinstance(picture, dict):
|
||||
continue
|
||||
pic_url = picture.get('URL')
|
||||
if not pic_url:
|
||||
continue
|
||||
thumbnail = {
|
||||
'url': pic_url,
|
||||
}
|
||||
pic_size = picture.get('PicSize', '')
|
||||
m = re.search(r'(?P<width>\d+)[xX](?P<height>\d+)', pic_size)
|
||||
if m:
|
||||
thumbnail.update({
|
||||
'width': int(m.group('width')),
|
||||
'height': int(m.group('height')),
|
||||
})
|
||||
thumbnails.append(thumbnail)
|
||||
|
||||
return {
|
||||
'id': video_id,
|
||||
'title': title,
|
||||
'description': description,
|
||||
'duration': duration,
|
||||
'timestamp': created_at,
|
||||
'thumbnail': thumbnail,
|
||||
'thumbnails': thumbnails,
|
||||
'formats': formats,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user