youtube-dl

Another place where youtube-dl lives on
git clone git://git.oshgnacknak.de/youtube-dl.git
Log | Files | Refs | README | LICENSE

commit c40dbb19ab475e8a0e1b29548130adf9ce13ea43
parent ffaf6e66e3830d0e4750aec2cfdaff1a6bd9c2ad
Author: Sergey M․ <dstftw@gmail.com>
Date:   Sat, 19 Dec 2015 19:19:26 +0600

[toggle] Extract thumbnails

Diffstat:
Myoutube_dl/extractor/togglesg.py | 34++++++++++++++++++++++++++--------
1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/youtube_dl/extractor/togglesg.py b/youtube_dl/extractor/togglesg.py @@ -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, }