]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vevo.py
3 import xml
.etree
.ElementTree
6 from .common
import InfoExtractor
13 class VevoIE(InfoExtractor
):
15 Accepts urls from vevo.com or in the format 'vevo:{id}'
16 (currently used by MTVIE)
18 _VALID_URL
= r
'((http://www.vevo.com/watch/.*?/.*?/)|(vevo:))(?P<id>.*?)(\?|$)'
20 u
'url': u
'http://www.vevo.com/watch/hurts/somebody-to-die-for/GB1101300280',
21 u
'file': u
'GB1101300280.mp4',
23 u
"upload_date": u
"20130624",
24 u
"uploader": u
"Hurts",
25 u
"title": u
"Somebody to Die For",
30 def _real_extract(self
, url
):
31 mobj
= re
.match(self
._VALID
_URL
, url
)
32 video_id
= mobj
.group('id')
34 json_url
= 'http://videoplayer.vevo.com/VideoService/AuthenticateVideo?isrc=%s' % video_id
35 info_json
= self
._download
_webpage
(json_url
, video_id
, u
'Downloading json info')
37 self
.report_extraction(video_id
)
38 video_info
= json
.loads(info_json
)['video']
39 last_version
= {'version': -1}
40 for version
in video_info
['videoVersions']:
41 # These are the HTTP downloads, other types are for different manifests
42 if version
['sourceType'] == 2:
43 if version
['version'] > last_version
['version']:
44 last_version
= version
45 if last_version
['version'] == -1:
46 raise ExtractorError(u
'Unable to extract last version of the video')
48 renditions
= xml
.etree
.ElementTree
.fromstring(last_version
['data'])
50 # Already sorted from worst to best quality
51 for rend
in renditions
.findall('rendition'):
56 'ext': determine_ext(f_url
),
57 'height': int(attr
['frameheight']),
58 'width': int(attr
['frameWidth']),
61 date_epoch
= int(self
._search
_regex
(
62 r
'/Date\((\d+)\)/', video_info
['launchDate'], u
'launch date'))/1000
63 upload_date
= datetime
.datetime
.fromtimestamp(date_epoch
)
66 'title': video_info
['title'],
68 'thumbnail': video_info
['imageUrl'],
69 'upload_date': upload_date
.strftime('%Y%m%d'),
70 'uploader': video_info
['mainArtists'][0]['artistName'],
71 'duration': video_info
['duration'],
74 # TODO: Remove when #980 has been merged
75 info
.update(formats
[-1])