]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/reverbnation.py
Fix "invalid escape sequences" error on Python 3.6
[yt-dlp.git] / youtube_dl / extractor / reverbnation.py
CommitLineData
36cb99f9
FV
1from __future__ import unicode_literals
2
36cb99f9 3from .common import InfoExtractor
f68901e5
S
4from ..utils import (
5 qualities,
6 str_or_none,
7)
36cb99f9
FV
8
9
10class 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',
3adb9d11 14 'md5': 'c0aaf339bcee189495fdf5a8c8ba8645',
36cb99f9 15 'info_dict': {
611c1dd9
S
16 'id': '16965047',
17 'ext': 'mp3',
18 'title': 'MONA LISA',
19 'uploader': 'ALKILADOS',
20 'uploader_id': '216429',
ec85ded8 21 'thumbnail': r're:^https?://.*\.jpg',
36cb99f9
FV
22 },
23 }]
24
25 def _real_extract(self, url):
3adb9d11 26 song_id = self._match_id(url)
36cb99f9
FV
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
f68901e5
S
34 THUMBNAILS = ('thumbnail', 'image')
35 quality = qualities(THUMBNAILS)
3adb9d11 36 thumbnails = []
f68901e5
S
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 })
3adb9d11 43
36cb99f9
FV
44 return {
45 'id': song_id,
3adb9d11
DR
46 'title': api_res['name'],
47 'url': api_res['url'],
36cb99f9 48 'uploader': api_res.get('artist', {}).get('name'),
40a90862 49 'uploader_id': str_or_none(api_res.get('artist', {}).get('id')),
3adb9d11 50 'thumbnails': thumbnails,
36cb99f9
FV
51 'ext': 'mp3',
52 'vcodec': 'none',
53 }