2 from __future__ import unicode_literals
6 from .common import InfoExtractor
14 class NineCNineMediaIE(InfoExtractor):
15 _VALID_URL = r'9c9media:(?P<destination_code>[^:]+):(?P<id>\d+)'
17 def _real_extract(self, url):
18 destination_code, video_id = re.match(self._VALID_URL, url).groups()
19 api_base_url = 'http://capi.9c9media.com/destinations/%s/platforms/desktop/contents/%s/' % (destination_code, video_id)
20 content = self._download_json(api_base_url, video_id, query={
21 '$include': '[contentpackages]',
23 title = content['Name']
24 if len(content['ContentPackages']) > 1:
25 raise ExtractorError('multiple content packages')
26 content_package = content['ContentPackages'][0]
27 stacks_base_url = api_base_url + 'contentpackages/%s/stacks/' % content_package['Id']
28 stacks = self._download_json(stacks_base_url, video_id)['Items']
30 raise ExtractorError('multiple stacks')
32 stack_base_url = '%s%s/manifest.' % (stacks_base_url, stack['Id'])
34 formats.extend(self._extract_m3u8_formats(
35 stack_base_url + 'm3u8', video_id, 'mp4',
36 'm3u8_native', m3u8_id='hls', fatal=False))
37 formats.extend(self._extract_f4m_formats(
38 stack_base_url + 'f4m', video_id,
39 f4m_id='hds', fatal=False))
40 mp4_url = self._download_webpage(stack_base_url + 'pd', video_id, fatal=False)
46 self._sort_formats(formats)
51 'description': content.get('Desc') or content.get('ShortDesc'),
52 'timestamp': parse_iso8601(content.get('BroadcastDateTime')),
53 'duration': parse_duration(content.get('BroadcastTime')),