]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/reverbnation.py
[ie/orf:on] Improve extraction (#9677)
[yt-dlp.git] / yt_dlp / extractor / reverbnation.py
1 from .common import InfoExtractor
2 from ..utils import (
3 qualities,
4 str_or_none,
5 )
6
7
8 class ReverbNationIE(InfoExtractor):
9 _VALID_URL = r'^https?://(?:www\.)?reverbnation\.com/.*?/song/(?P<id>\d+).*?$'
10 _TESTS = [{
11 'url': 'http://www.reverbnation.com/alkilados/song/16965047-mona-lisa',
12 'md5': 'c0aaf339bcee189495fdf5a8c8ba8645',
13 'info_dict': {
14 'id': '16965047',
15 'ext': 'mp3',
16 'title': 'MONA LISA',
17 'uploader': 'ALKILADOS',
18 'uploader_id': '216429',
19 'thumbnail': r're:^https?://.*\.jpg',
20 },
21 }]
22
23 def _real_extract(self, url):
24 song_id = self._match_id(url)
25
26 api_res = self._download_json(
27 'https://api.reverbnation.com/song/%s' % song_id,
28 song_id,
29 note='Downloading information of song %s' % song_id
30 )
31
32 THUMBNAILS = ('thumbnail', 'image')
33 quality = qualities(THUMBNAILS)
34 thumbnails = []
35 for thumb_key in THUMBNAILS:
36 if api_res.get(thumb_key):
37 thumbnails.append({
38 'url': api_res[thumb_key],
39 'preference': quality(thumb_key)
40 })
41
42 return {
43 'id': song_id,
44 'title': api_res['name'],
45 'url': api_res['url'],
46 'uploader': api_res.get('artist', {}).get('name'),
47 'uploader_id': str_or_none(api_res.get('artist', {}).get('id')),
48 'thumbnails': thumbnails,
49 'ext': 'mp3',
50 'vcodec': 'none',
51 }