1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from ..compat import compat_etree_fromstring
13 class VevoIE(InfoExtractor):
15 Accepts urls from vevo.com or in the format 'vevo:{id}'
16 (currently used by MTVIE and MySpaceIE)
19 (?:https?://www\.vevo\.com/watch/(?:[^/]+/(?:[^/]+/)?)?|
20 https?://cache\.vevo\.com/m/html/embed\.html\?video=|
21 https?://videoplayer\.vevo\.com/embed/embedded\?videoId=|
26 'url': 'http://www.vevo.com/watch/hurts/somebody-to-die-for/GB1101300280',
27 'md5': '2dbc7e9fd4f1c60436c9aa73a5406193',
31 'title': 'Hurts - Somebody to Die For',
32 'description': 'md5:13e925b89af6b01c7e417332bd23c4bf',
33 'uploader_id': 'HurtsVEVO',
34 'uploader': 'HurtsVEVO',
35 'upload_date': '20130624',
38 'add_ie': ['Youtube'],
40 'note': 'v3 SMIL format',
41 'url': 'http://www.vevo.com/watch/cassadee-pope/i-wish-i-could-break-your-heart/USUV71302923',
42 'md5': '13d5204f520af905eeffa675040b8e76',
46 'title': 'Cassadee Pope - I Wish I Could Break Your Heart',
47 'description': 'md5:5e9721c92ef117a6f69d00e9b42ceba7',
48 'uploader_id': 'CassadeeVEVO',
49 'uploader': 'CassadeeVEVO',
50 'upload_date': '20140219',
54 'add_ie': ['Youtube'],
56 'note': 'Age-limited video',
57 'url': 'https://www.vevo.com/watch/justin-timberlake/tunnel-vision-explicit/USRV81300282',
62 'title': 'Justin Timberlake - Tunnel Vision (Explicit)',
63 'description': 'md5:64249768eec3bc4276236606ea996373',
64 'uploader_id': 'justintimberlakeVEVO',
65 'uploader': 'justintimberlakeVEVO',
66 'upload_date': '20130703',
69 'skip_download': 'true',
71 'add_ie': ['Youtube'],
73 'note': 'No video_info',
74 'url': 'http://www.vevo.com/watch/k-camp-1/Till-I-Die/USUV71503000',
75 'md5': '8b83cc492d72fc9cf74a02acee7dc1b0',
79 'title': 'Till I Die - K Camp ft. T.I.',
83 _SMIL_BASE_URL = 'http://smil.lvl3.vevo.com'
106 def _parse_smil_formats(self, smil, smil_url, video_id, namespace=None, f4m_params=None, transform_rtmp_url=None):
108 els = smil.findall('.//{http://www.w3.org/2001/SMIL20/Language}video')
110 src = el.attrib['src']
111 m = re.match(r'''(?xi)
114 [/a-z0-9]+ # The directory and main part of the URL
116 _(?P<width>[0-9]+)x(?P<height>[0-9]+)
117 _(?P<vcodec>[a-z0-9]+)
119 _(?P<acodec>[a-z0-9]+)
121 \.[a-z0-9]+ # File extension
126 format_url = self._SMIL_BASE_URL + m.group('path')
129 'format_id': 'smil_' + m.group('tbr'),
130 'vcodec': m.group('vcodec'),
131 'acodec': m.group('acodec'),
132 'tbr': int(m.group('tbr')),
133 'vbr': int(m.group('vbr')),
134 'abr': int(m.group('abr')),
135 'ext': m.group('ext'),
136 'width': int(m.group('width')),
137 'height': int(m.group('height')),
141 def _real_extract(self, url):
142 video_id = self._match_id(url)
146 json_url = 'http://videoplayer.vevo.com/VideoService/AuthenticateVideo?isrc=%s' % video_id
147 response = self._download_json(json_url, video_id)
148 video_info = response['video'] or {}
151 ytid = response.get('errorInfo', {}).get('ytid')
153 return self.url_result(ytid, 'Youtube', ytid)
155 if response.get('statusCode') != 909:
156 if 'statusMessage' in response:
157 raise ExtractorError('%s said: %s' % (
158 self.IE_NAME, response['statusMessage']), expected=True)
159 raise ExtractorError('Unable to extract videos')
161 if url.startswith('vevo:'):
162 raise ExtractorError(
163 'Please specify full Vevo URL for downloading', expected=True)
164 webpage = self._download_webpage(url, video_id)
166 title = video_info.get('title') or self._og_search_title(webpage)
170 for video_version in video_info['videoVersions']:
171 version = self._VERSIONS.get(video_version['version'])
172 if version == 'youtube':
173 return self.url_result(
174 video_version['id'], 'Youtube', video_version['id'])
176 source_type = self._SOURCE_TYPES.get(video_version['sourceType'])
177 renditions = compat_etree_fromstring(video_version['data'])
178 if source_type == 'http':
179 for rend in renditions.findall('rendition'):
183 'format_id': '%s-%s' % (version, attr['name']),
184 'height': int_or_none(attr.get('frameheight')),
185 'width': int_or_none(attr.get('frameWidth')),
186 'tbr': int_or_none(attr.get('totalBitrate')),
187 'vbr': int_or_none(attr.get('videoBitrate')),
188 'abr': int_or_none(attr.get('audioBitrate')),
189 'vcodec': attr.get('videoCodec'),
190 'acodec': attr.get('audioCodec'),
192 elif source_type == 'hls':
193 formats.extend(self._extract_m3u8_formats(
194 renditions.find('rendition').attrib['url'], video_id,
195 'mp4', 'm3u8_native', m3u8_id='hls-%s' % version, fatal=False))
196 elif source_type == 'smil' and not smil_parsed:
197 formats.extend(self._extract_smil_formats(
198 renditions.find('rendition').attrib['url'], video_id, False))
200 self._sort_formats(formats)
202 is_explicit = video_info.get('isExplicit')
203 if is_explicit is True:
205 elif is_explicit is False:
210 timestamp = int_or_none(self._search_regex(
212 video_info['launchDate'], 'launch date', fatal=False),
213 scale=1000) if video_info else None
215 duration = video_info.get('duration') or int_or_none(
216 self._html_search_meta('video:duration', webpage))
222 'thumbnail': video_info.get('imageUrl'),
223 'timestamp': timestamp,
224 'uploader': video_info['mainArtists'][0]['artistName'] if video_info else None,
225 'duration': duration,
226 'age_limit': age_limit,