mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-07-18 19:28:31 +00:00
[ie/reverbnation] removed starting position from url regex and updated extraction code to use traverse_obj
This commit is contained in:
parent
300de37201
commit
8cdec2d470
@ -1,12 +1,12 @@
|
||||
import functools
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..utils import InAdvancePagedList, int_or_none, qualities, str_or_none, traverse_obj
|
||||
from ..utils import InAdvancePagedList, float_or_none, int_or_none, qualities, str_or_none, traverse_obj, url_or_none
|
||||
|
||||
|
||||
class ReverbNationIE(InfoExtractor):
|
||||
IE_NAME = 'reverbnation:song'
|
||||
_VALID_URL = r'^https?://(?:www\.)?reverbnation\.com/.*?/song/(?P<id>\d+).*?$'
|
||||
_VALID_URL = r'https?://(?:www\.)?reverbnation\.com/.*?/song/(?P<id>\d+).*?$'
|
||||
_TESTS = [{
|
||||
'url': 'http://www.reverbnation.com/alkilados/song/16965047-mona-lisa',
|
||||
'md5': 'c0aaf339bcee189495fdf5a8c8ba8645',
|
||||
@ -42,22 +42,24 @@ def _real_extract(self, url):
|
||||
})
|
||||
|
||||
return {
|
||||
'id': song_id,
|
||||
'title': api_res['name'],
|
||||
'url': api_res['url'],
|
||||
'uploader': api_res.get('artist', {}).get('name'),
|
||||
'uploader_id': str_or_none(api_res.get('artist', {}).get('id')),
|
||||
'thumbnails': thumbnails,
|
||||
'duration': api_res.get('duration'),
|
||||
'tbr': api_res.get('bitrate'),
|
||||
'id': str_or_none(song_id),
|
||||
'ext': 'mp3',
|
||||
'vcodec': 'none',
|
||||
'thumbnails': thumbnails,
|
||||
**traverse_obj(api_res, {
|
||||
'title': ('name', {str_or_none}),
|
||||
'url': ('url', {url_or_none}),
|
||||
'uploader': ('artist', 'name', {str_or_none}),
|
||||
'uploader_id': ('artist', 'id', {str_or_none}),
|
||||
'duration': ('duration', {float_or_none}),
|
||||
'tbr': ('bitrate', {int_or_none}),
|
||||
}),
|
||||
}
|
||||
|
||||
|
||||
class ReverbNationArtistIE(InfoExtractor):
|
||||
IE_NAME = 'reverbnation:artist'
|
||||
_VALID_URL = r'^https?://(?:www\.)?reverbnation\.com/(?P<id>[\w-]+)(?:/songs)?$'
|
||||
_VALID_URL = r'https?://(?:www\.)?reverbnation\.com/(?P<id>[\w-]+)(?:/songs)?$'
|
||||
_TESTS = [{
|
||||
'url': 'https://www.reverbnation.com/morganandersson',
|
||||
'info_dict': {
|
||||
@ -77,19 +79,20 @@ class ReverbNationArtistIE(InfoExtractor):
|
||||
|
||||
def _yield_songs(self, json_data):
|
||||
for song in json_data.get('results'):
|
||||
data = {
|
||||
'id': str_or_none(song.get('id')),
|
||||
'title': song.get('name'),
|
||||
'url': song.get('url'),
|
||||
'uploader': song.get('artist', {}).get('name'),
|
||||
'uploader_id': str_or_none(song.get('artist', {}).get('id')),
|
||||
'thumbnail': song.get('thumbnail'),
|
||||
'duration': int_or_none(song.get('duration')),
|
||||
'tbr': int_or_none(song.get('bitrate')),
|
||||
yield {
|
||||
'ext': 'mp3',
|
||||
'vcodec': 'none',
|
||||
**traverse_obj(song, {
|
||||
'id': ('id', {str_or_none}),
|
||||
'title': ('name', {str_or_none}),
|
||||
'url': ('url', {url_or_none}),
|
||||
'uploader': ('artist', 'name', {str_or_none}),
|
||||
'uploader_id': ('artist', 'id', {str_or_none}),
|
||||
'duration': ('duration', {float_or_none}),
|
||||
'tbr': ('bitrate', {int_or_none}),
|
||||
'thumbnail': ('thumbnail', {url_or_none}),
|
||||
}),
|
||||
}
|
||||
yield data
|
||||
|
||||
def _fetch_page(self, artist_id, page):
|
||||
return self._download_json(f'https://www.reverbnation.com/api/artist/{artist_id}/songs?page={page}&per_page={self._PAGE_SIZE}', f'{artist_id}_{page}')
|
||||
|
Loading…
Reference in New Issue
Block a user