]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/reverbnation.py
[ie/orf:on] Improve extraction (#9677)
[yt-dlp.git] / yt_dlp / extractor / reverbnation.py
CommitLineData
36cb99f9 1from .common import InfoExtractor
f68901e5
S
2from ..utils import (
3 qualities,
4 str_or_none,
5)
36cb99f9
FV
6
7
8class 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',
3adb9d11 12 'md5': 'c0aaf339bcee189495fdf5a8c8ba8645',
36cb99f9 13 'info_dict': {
611c1dd9
S
14 'id': '16965047',
15 'ext': 'mp3',
16 'title': 'MONA LISA',
17 'uploader': 'ALKILADOS',
18 'uploader_id': '216429',
ec85ded8 19 'thumbnail': r're:^https?://.*\.jpg',
36cb99f9
FV
20 },
21 }]
22
23 def _real_extract(self, url):
3adb9d11 24 song_id = self._match_id(url)
36cb99f9
FV
25
26 api_res = self._download_json(
511c4325 27 'https://api.reverbnation.com/song/%s' % song_id,
36cb99f9 28 song_id,
36cb99f9
FV
29 note='Downloading information of song %s' % song_id
30 )
31
f68901e5
S
32 THUMBNAILS = ('thumbnail', 'image')
33 quality = qualities(THUMBNAILS)
3adb9d11 34 thumbnails = []
f68901e5
S
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 })
3adb9d11 41
36cb99f9
FV
42 return {
43 'id': song_id,
3adb9d11
DR
44 'title': api_res['name'],
45 'url': api_res['url'],
36cb99f9 46 'uploader': api_res.get('artist', {}).get('name'),
40a90862 47 'uploader_id': str_or_none(api_res.get('artist', {}).get('id')),
3adb9d11 48 'thumbnails': thumbnails,
36cb99f9
FV
49 'ext': 'mp3',
50 'vcodec': 'none',
51 }