]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/reverbnation.py
Update upstream source from tag 'upstream/2019.09.28'
[youtubedl] / youtube_dl / extractor / reverbnation.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import (
5 qualities,
6 str_or_none,
7 )
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 'md5': 'c0aaf339bcee189495fdf5a8c8ba8645',
15 'info_dict': {
16 'id': '16965047',
17 'ext': 'mp3',
18 'title': 'MONA LISA',
19 'uploader': 'ALKILADOS',
20 'uploader_id': '216429',
21 'thumbnail': r're:^https?://.*\.jpg',
22 },
23 }]
24
25 def _real_extract(self, url):
26 song_id = self._match_id(url)
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 THUMBNAILS = ('thumbnail', 'image')
35 quality = qualities(THUMBNAILS)
36 thumbnails = []
37 for thumb_key in THUMBNAILS:
38 if api_res.get(thumb_key):
39 thumbnails.append({
40 'url': api_res[thumb_key],
41 'preference': quality(thumb_key)
42 })
43
44 return {
45 'id': song_id,
46 'title': api_res['name'],
47 'url': api_res['url'],
48 'uploader': api_res.get('artist', {}).get('name'),
49 'uploader_id': str_or_none(api_res.get('artist', {}).get('id')),
50 'thumbnails': thumbnails,
51 'ext': 'mp3',
52 'vcodec': 'none',
53 }