]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/reverbnation.py
Merge remote-tracking branch 'h-collector/master'
[yt-dlp.git] / youtube_dl / extractor / reverbnation.py
CommitLineData
36cb99f9
FV
1from __future__ import unicode_literals
2
3import re
36cb99f9
FV
4
5from .common import InfoExtractor
40a90862 6from ..utils import str_or_none
36cb99f9
FV
7
8
9class 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',
36cb99f9
FV
13 'md5': '3da12ebca28c67c111a7f8b262d3f7a7',
14 'info_dict': {
85a69924
JMF
15 "id": "16965047",
16 "ext": "mp3",
36cb99f9
FV
17 "title": "MONA LISA",
18 "uploader": "ALKILADOS",
40a90862 19 "uploader_id": "216429",
4dc5286e 20 "thumbnail": "re:^https://gp1\.wac\.edgecastcdn\.net/.*?\.jpg$"
36cb99f9
FV
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(
511c4325 29 'https://api.reverbnation.com/song/%s' % song_id,
36cb99f9 30 song_id,
36cb99f9
FV
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'),
40a90862 39 'uploader_id': str_or_none(api_res.get('artist', {}).get('id')),
4dc5286e
JMF
40 'thumbnail': self._proto_relative_url(
41 api_res.get('image', api_res.get('thumbnail'))),
36cb99f9
FV
42 'ext': 'mp3',
43 'vcodec': 'none',
44 }