aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2015-12-19 19:19:26 +0600
committerSergey M․ <dstftw@gmail.com>2015-12-19 19:19:26 +0600
commitc40dbb19ab475e8a0e1b29548130adf9ce13ea43 (patch)
tree9f8fc50005982f05682bc50aa5385539c2070b19
parentffaf6e66e3830d0e4750aec2cfdaff1a6bd9c2ad (diff)
downloadyoutube-dl-c40dbb19ab475e8a0e1b29548130adf9ce13ea43.tar.xz
[toggle] Extract thumbnails
-rw-r--r--youtube_dl/extractor/togglesg.py34
1 files changed, 26 insertions, 8 deletions
diff --git a/youtube_dl/extractor/togglesg.py b/youtube_dl/extractor/togglesg.py
index 244c79e8d..a2b89d6bb 100644
--- 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,
}