2 from __future__ import unicode_literals
6 from .common import InfoExtractor
16 class OnionStudiosIE(InfoExtractor):
17 _VALID_URL = r'https?://(?:www\.)?onionstudios\.com/(?:video(?:s/[^/]+-|/)|embed\?.*\bid=)(?P<id>\d+)(?!-)'
20 'url': 'http://www.onionstudios.com/videos/hannibal-charges-forward-stops-for-a-cocktail-2937',
21 'md5': '5a118d466d62b5cd03647cf2c593977f',
25 'title': 'Hannibal charges forward, stops for a cocktail',
26 'description': 'md5:545299bda6abf87e5ec666548c6a9448',
27 'thumbnail': r're:^https?://.*\.jpg$',
28 'uploader': 'a.v. club',
29 'upload_date': '20150619',
30 'timestamp': 1434728546,
33 'url': 'http://www.onionstudios.com/embed?id=2855&autoplay=true',
34 'only_matching': True,
36 'url': 'http://www.onionstudios.com/video/6139.json',
37 'only_matching': True,
41 def _extract_url(webpage):
43 r'(?s)<(?:iframe|bulbs-video)[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?onionstudios\.com/(?:embed.+?|video/\d+\.json))\1', webpage)
45 return mobj.group('url')
47 def _real_extract(self, url):
48 video_id = self._match_id(url)
50 webpage = self._download_webpage(
51 'http://onionstudios.com/embed/dc94dc2899fe644c0e7241fa04c1b732.js',
53 mcp_id = compat_str(self._parse_json(self._search_regex(
54 r'window\.mcpMapping\s*=\s*({.+?});', webpage,
55 'MCP Mapping'), video_id, js_to_json)[video_id]['mcp_id'])
56 video_data = self._download_json(
57 'https://api.vmh.univision.com/metadata/v1/content/' + mcp_id,
58 mcp_id)['videoMetadata']
59 iptc = video_data['photoVideoMetadataIPTC']
60 title = iptc['title']['en']
61 fmg = video_data.get('photoVideoMetadata_fmg') or {}
62 tvss_domain = fmg.get('tvssDomain') or 'https://auth.univision.com'
63 data = self._download_json(
64 tvss_domain + '/api/v3/video-auth/url-signature-tokens',
65 mcp_id, query={'mcpids': mcp_id})['data'][0]
68 rendition_url = data.get('renditionUrl')
70 formats = self._extract_m3u8_formats(
71 rendition_url, mcp_id, 'mp4',
72 'm3u8_native', m3u8_id='hls', fatal=False)
74 fallback_rendition_url = data.get('fallbackRenditionUrl')
75 if fallback_rendition_url:
77 'format_id': 'fallback',
78 'tbr': int_or_none(self._search_regex(
79 r'_(\d+)\.mp4', fallback_rendition_url,
80 'bitrate', default=None)),
81 'url': fallback_rendition_url,
84 self._sort_formats(formats)
89 'thumbnail': try_get(iptc, lambda x: x['cloudinaryLink']['link'], compat_str),
90 'uploader': fmg.get('network'),
91 'duration': int_or_none(iptc.get('fileDuration')),
93 'description': try_get(iptc, lambda x: x['description']['en'], compat_str),
94 'timestamp': parse_iso8601(iptc.get('dateReleased')),