]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/reverbnation.py
Update the changelog.
[youtubedl] / youtube_dl / extractor / reverbnation.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import str_or_none
7
8
9 class ReverbNationIE(InfoExtractor):
10 _VALID_URL = r'^https?://(?:www\.)?reverbnation\.com/.*?/song/(?P<id>\d+).*?$'
11 _TESTS = [{
12 'url': 'http://www.reverbnation.com/alkilados/song/16965047-mona-lisa',
13 'md5': '3da12ebca28c67c111a7f8b262d3f7a7',
14 'info_dict': {
15 'id': '16965047',
16 'ext': 'mp3',
17 'title': 'MONA LISA',
18 'uploader': 'ALKILADOS',
19 'uploader_id': '216429',
20 'thumbnail': 're:^https://gp1\.wac\.edgecastcdn\.net/.*?\.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' % song_id,
30 song_id,
31 note='Downloading information of song %s' % song_id
32 )
33
34 return {
35 'id': song_id,
36 'title': api_res.get('name'),
37 'url': api_res.get('url'),
38 'uploader': api_res.get('artist', {}).get('name'),
39 'uploader_id': str_or_none(api_res.get('artist', {}).get('id')),
40 'thumbnail': self._proto_relative_url(
41 api_res.get('image', api_res.get('thumbnail'))),
42 'ext': 'mp3',
43 'vcodec': 'none',
44 }