mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
10 years ago
|
from .common import InfoExtractor
|
||
8 years ago
|
from ..utils import (
|
||
|
qualities,
|
||
|
str_or_none,
|
||
|
)
|
||
10 years ago
|
|
||
|
|
||
|
class ReverbNationIE(InfoExtractor):
|
||
|
_VALID_URL = r'^https?://(?:www\.)?reverbnation\.com/.*?/song/(?P<id>\d+).*?$'
|
||
|
_TESTS = [{
|
||
|
'url': 'http://www.reverbnation.com/alkilados/song/16965047-mona-lisa',
|
||
8 years ago
|
'md5': 'c0aaf339bcee189495fdf5a8c8ba8645',
|
||
10 years ago
|
'info_dict': {
|
||
9 years ago
|
'id': '16965047',
|
||
|
'ext': 'mp3',
|
||
|
'title': 'MONA LISA',
|
||
|
'uploader': 'ALKILADOS',
|
||
|
'uploader_id': '216429',
|
||
8 years ago
|
'thumbnail': r're:^https?://.*\.jpg',
|
||
10 years ago
|
},
|
||
|
}]
|
||
|
|
||
|
def _real_extract(self, url):
|
||
8 years ago
|
song_id = self._match_id(url)
|
||
10 years ago
|
|
||
|
api_res = self._download_json(
|
||
10 years ago
|
'https://api.reverbnation.com/song/%s' % song_id,
|
||
10 years ago
|
song_id,
|
||
|
note='Downloading information of song %s' % song_id
|
||
|
)
|
||
|
|
||
8 years ago
|
THUMBNAILS = ('thumbnail', 'image')
|
||
|
quality = qualities(THUMBNAILS)
|
||
8 years ago
|
thumbnails = []
|
||
8 years ago
|
for thumb_key in THUMBNAILS:
|
||
|
if api_res.get(thumb_key):
|
||
|
thumbnails.append({
|
||
|
'url': api_res[thumb_key],
|
||
|
'preference': quality(thumb_key)
|
||
|
})
|
||
8 years ago
|
|
||
10 years ago
|
return {
|
||
|
'id': song_id,
|
||
8 years ago
|
'title': api_res['name'],
|
||
|
'url': api_res['url'],
|
||
10 years ago
|
'uploader': api_res.get('artist', {}).get('name'),
|
||
10 years ago
|
'uploader_id': str_or_none(api_res.get('artist', {}).get('id')),
|
||
8 years ago
|
'thumbnails': thumbnails,
|
||
10 years ago
|
'ext': 'mp3',
|
||
|
'vcodec': 'none',
|
||
|
}
|