]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/foxnews.py
1 from __future__
import unicode_literals
3 from .common
import InfoExtractor
10 class FoxNewsIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://video\.foxnews\.com/v/(?:video-embed\.html\?video_id=)?(?P<id>\d+)'
14 'url': 'http://video.foxnews.com/v/3937480/frozen-in-time/#sp=show-clips',
15 'md5': '32aaded6ba3ef0d1c04e238d01031e5e',
19 'title': 'Frozen in Time',
20 'description': 'Doctors baffled by 16-year-old girl that is the size of a toddler',
22 'timestamp': 1304411491,
23 'upload_date': '20110503',
24 'thumbnail': 're:^https?://.*\.jpg$',
28 'url': 'http://video.foxnews.com/v/3922535568001/rep-luis-gutierrez-on-if-obamas-immigration-plan-is-legal/#sp=show-clips',
29 'md5': '5846c64a1ea05ec78175421b8323e2df',
31 'id': '3922535568001',
33 'title': "Rep. Luis Gutierrez on if Obama's immigration plan is legal",
34 'description': "Congressman discusses the president's executive action",
36 'timestamp': 1417662047,
37 'upload_date': '20141204',
38 'thumbnail': 're:^https?://.*\.jpg$',
42 'url': 'http://video.foxnews.com/v/video-embed.html?video_id=3937480&d=video.foxnews.com',
43 'only_matching': True,
47 def _real_extract(self
, url
):
48 video_id
= self
._match
_id
(url
)
50 video
= self
._download
_json
(
51 'http://video.foxnews.com/v/feed/video/%s.js?template=fox' % video_id
, video_id
)
53 item
= video
['channel']['item']
55 description
= item
['description']
56 timestamp
= parse_iso8601(item
['dc-date'])
58 media_group
= item
['media-group']
61 for media
in media_group
['media-content']:
62 attributes
= media
['@attributes']
63 video_url
= attributes
['url']
64 if video_url
.endswith('.f4m'):
65 formats
.extend(self
._extract
_f
4m
_formats
(video_url
+ '?hdcore=3.4.0&plugin=aasp-3.4.0.132.124', video_id
))
66 elif video_url
.endswith('.m3u8'):
67 formats
.extend(self
._extract
_m
3u8_formats
(video_url
, video_id
, 'flv'))
68 elif not video_url
.endswith('.smil'):
69 duration
= int_or_none(attributes
.get('duration'))
72 'format_id': media
['media-category']['@attributes']['label'],
74 'vbr': int_or_none(attributes
.get('bitrate')),
75 'filesize': int_or_none(attributes
.get('fileSize'))
77 self
._sort
_formats
(formats
)
79 media_thumbnail
= media_group
['media-thumbnail']['@attributes']
81 'url': media_thumbnail
['url'],
82 'width': int_or_none(media_thumbnail
.get('width')),
83 'height': int_or_none(media_thumbnail
.get('height')),
84 }] if media_thumbnail
else []
89 'description': description
,
91 'timestamp': timestamp
,
93 'thumbnails': thumbnails
,