]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/reverbnation.py
Initiate release.
[youtubedl] / youtube_dl / extractor / reverbnation.py
1 from __future__ import unicode_literals
2
3 import re
4 import time
5
6 from .common import InfoExtractor
7 from ..utils import strip_jsonp
8
9
10 class ReverbNationIE(InfoExtractor):
11 _VALID_URL = r'^https?://(?:www\.)?reverbnation\.com/.*?/song/(?P<id>\d+).*?$'
12 _TESTS = [{
13 'url': 'http://www.reverbnation.com/alkilados/song/16965047-mona-lisa',
14 'file': '16965047.mp3',
15 'md5': '3da12ebca28c67c111a7f8b262d3f7a7',
16 'info_dict': {
17 "title": "MONA LISA",
18 "uploader": "ALKILADOS",
19 "uploader_id": 216429,
20 "thumbnail": "//gp1.wac.edgecastcdn.net/802892/production_public/Photo/13761700/image/1366002176_AVATAR_MONA_LISA.jpg"
21 },
22 }]
23
24 def _real_extract(self, url):
25 mobj = re.match(self._VALID_URL, url)
26 song_id = mobj.group('id')
27
28 api_res = self._download_json(
29 'https://api.reverbnation.com/song/%s?callback=api_response_5&_=%d'
30 % (song_id, int(time.time() * 1000)),
31 song_id,
32 transform_source=strip_jsonp,
33 note='Downloading information of song %s' % song_id
34 )
35
36 return {
37 'id': song_id,
38 'title': api_res.get('name'),
39 'url': api_res.get('url'),
40 'uploader': api_res.get('artist', {}).get('name'),
41 'uploader_id': api_res.get('artist', {}).get('id'),
42 'thumbnail': api_res.get('image', api_res.get('thumbnail')),
43 'ext': 'mp3',
44 'vcodec': 'none',
45 }