1 from __future__ import unicode_literals
5 from .common import InfoExtractor
12 class FoxNewsIE(InfoExtractor):
13 _VALID_URL = r'https?://video\.fox(?:news|business)\.com/v/(?:video-embed\.html\?video_id=)?(?P<id>\d+)'
16 'url': 'http://video.foxnews.com/v/3937480/frozen-in-time/#sp=show-clips',
17 'md5': '32aaded6ba3ef0d1c04e238d01031e5e',
21 'title': 'Frozen in Time',
22 'description': 'Doctors baffled by 16-year-old girl that is the size of a toddler',
24 'timestamp': 1304411491,
25 'upload_date': '20110503',
26 'thumbnail': 're:^https?://.*\.jpg$',
30 'url': 'http://video.foxnews.com/v/3922535568001/rep-luis-gutierrez-on-if-obamas-immigration-plan-is-legal/#sp=show-clips',
31 'md5': '5846c64a1ea05ec78175421b8323e2df',
33 'id': '3922535568001',
35 'title': "Rep. Luis Gutierrez on if Obama's immigration plan is legal",
36 'description': "Congressman discusses the president's executive action",
38 'timestamp': 1417662047,
39 'upload_date': '20141204',
40 'thumbnail': 're:^https?://.*\.jpg$',
44 'url': 'http://video.foxnews.com/v/video-embed.html?video_id=3937480&d=video.foxnews.com',
45 'only_matching': True,
48 'url': 'http://video.foxbusiness.com/v/4442309889001',
49 'only_matching': True,
53 def _real_extract(self, url):
54 video_id = self._match_id(url)
56 m = re.match(r'^https?://video\.fox(news|business)', url)
58 video = self._download_json(
59 'http://video.fox' + m.group(1) + '.com/v/feed/video/%s.js?template=fox' % video_id, video_id)
61 item = video['channel']['item']
63 description = item['description']
64 timestamp = parse_iso8601(item['dc-date'])
66 media_group = item['media-group']
69 for media in media_group['media-content']:
70 attributes = media['@attributes']
71 video_url = attributes['url']
72 if video_url.endswith('.f4m'):
73 formats.extend(self._extract_f4m_formats(video_url + '?hdcore=3.4.0&plugin=aasp-3.4.0.132.124', video_id))
74 elif video_url.endswith('.m3u8'):
75 formats.extend(self._extract_m3u8_formats(video_url, video_id, 'flv'))
76 elif not video_url.endswith('.smil'):
77 duration = int_or_none(attributes.get('duration'))
80 'format_id': media['media-category']['@attributes']['label'],
82 'vbr': int_or_none(attributes.get('bitrate')),
83 'filesize': int_or_none(attributes.get('fileSize'))
85 self._sort_formats(formats)
87 media_thumbnail = media_group['media-thumbnail']['@attributes']
89 'url': media_thumbnail['url'],
90 'width': int_or_none(media_thumbnail.get('width')),
91 'height': int_or_none(media_thumbnail.get('height')),
92 }] if media_thumbnail else []
97 'description': description,
99 'timestamp': timestamp,
101 'thumbnails': thumbnails,