3 from .common
import InfoExtractor
10 class CNNIE(InfoExtractor
):
11 _VALID_URL
= r
'''(?x)https?://((edition|www)\.)?cnn\.com/video/(data/.+?|\?)/
12 (?P<path>.+?/(?P<title>[^/]+?)(?:\.cnn|(?=&)))'''
15 u
'url': u
'http://edition.cnn.com/video/?/video/sports/2013/06/09/nadal-1-on-1.cnn',
16 u
'file': u
'sports_2013_06_09_nadal-1-on-1.cnn.mp4',
17 u
'md5': u
'3e6121ea48df7e2259fe73a0628605c4',
19 u
'title': u
'Nadal wins 8th French Open title',
20 u
'description': u
'World Sport\'s Amanda Davies chats with 2013 French Open champion Rafael Nadal.',
22 u
'upload_date': u
'20130609',
26 u
"url": u
"http://edition.cnn.com/video/?/video/us/2013/08/21/sot-student-gives-epic-speech.georgia-institute-of-technology&utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+rss%2Fcnn_topstories+%28RSS%3A+Top+Stories%29",
27 u
"file": u
"us_2013_08_21_sot-student-gives-epic-speech.georgia-institute-of-technology.mp4",
28 u
"md5": u
"b5cc60c60a3477d185af8f19a2a26f4e",
30 u
"title": "Student's epic speech stuns new freshmen",
31 u
"description": "A Georgia Tech student welcomes the incoming freshmen with an epic speech backed by music from \"2001: A Space Odyssey.\""
35 def _real_extract(self
, url
):
36 mobj
= re
.match(self
._VALID
_URL
, url
)
37 path
= mobj
.group('path')
38 page_title
= mobj
.group('title')
39 info_url
= u
'http://cnn.com/video/data/3.0/%s/index.xml' % path
40 info
= self
._download
_xml
(info_url
, page_title
)
43 rex
= re
.compile(r
'''(?x)
44 (?P<width>[0-9]+)x(?P<height>[0-9]+)
45 (?:_(?P<bitrate>[0-9]+)k)?
47 for f
in info
.findall('files/file'):
48 video_url
= 'http://ht.cdn.turner.com/cnn/big%s' % (f
.text
.strip())
50 'format_id': f
.attrib
['bitrate'],
54 mf
= rex
.match(f
.attrib
['bitrate'])
56 fdct
['width'] = int(mf
.group('width'))
57 fdct
['height'] = int(mf
.group('height'))
58 fdct
['tbr'] = int_or_none(mf
.group('bitrate'))
60 mf
= rex
.search(f
.text
)
62 fdct
['width'] = int(mf
.group('width'))
63 fdct
['height'] = int(mf
.group('height'))
64 fdct
['tbr'] = int_or_none(mf
.group('bitrate'))
66 mi
= re
.match(r
'ios_(audio|[0-9]+)$', f
.attrib
['bitrate'])
68 if mi
.group(1) == 'audio':
69 fdct
['vcodec'] = 'none'
72 fdct
['tbr'] = int(mi
.group(1))
76 self
._sort
_formats
(formats
)
78 thumbnails
= sorted([((int(t
.attrib
['height']),int(t
.attrib
['width'])), t
.text
) for t
in info
.findall('images/image')])
79 thumbs_dict
= [{'resolution': res, 'url': t_url}
for (res
, t_url
) in thumbnails
]
81 metas_el
= info
.find('metas')
83 metas_el
.attrib
.get('version') if metas_el
is not None else None)
85 duration_el
= info
.find('length')
86 duration
= parse_duration(duration_el
.text
)
89 'id': info
.attrib
['id'],
90 'title': info
.find('headline').text
,
92 'thumbnail': thumbnails
[-1][1],
93 'thumbnails': thumbs_dict
,
94 'description': info
.find('description').text
,
96 'upload_date': upload_date
,