from __future__ import unicode_literals
import json
+import re
from .common import InfoExtractor
from ..utils import (
def _real_extract(self, url):
video_id = self._match_id(url)
- webpage = self._download_webpage(url, video_id, note='Downloading video page')
+ webpage = self._download_webpage(
+ url, video_id, note='Downloading video page')
api_user = self._search_regex(
- r'apiUser:\s*"([^"]+)"', webpage, 'apiUser', default=self._API_USER)
+ r'apiUser\s*:\s*(["\'])(?P<user>.+?)\1', webpage, 'apiUser',
+ default=self._API_USER, group='user')
api_pass = self._search_regex(
- r'apiPass:\s*"([^"]+)"', webpage, 'apiPass', default=self._API_PASS)
+ r'apiPass\s*:\s*(["\'])(?P<pass>.+?)\1', webpage, 'apiPass',
+ default=self._API_PASS, group='pass')
params = {
'initObj': {
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(' ', '')
video_file['URL'], video_id, ext='mp4', m3u8_id=vid_format,
note='Downloading %s m3u8 information' % vid_format,
errnote='Failed to download %s m3u8 information' % vid_format,
- fatal=False
- )
+ fatal=False)
if m3u8_formats:
formats.extend(m3u8_formats)
- if ext in ['mp4', 'wvm']:
+ elif ext in ('mp4', 'wvm'):
# wvm are drm-protected files
formats.append({
'ext': ext,
'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,
}