mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 12:01:28 +00:00
[yandexmusic] Capture and output API errors
This commit is contained in:
parent
9d303bf29b
commit
ae7d31af1c
|
@ -10,13 +10,27 @@
|
|||
compat_urllib_parse,
|
||||
)
|
||||
from ..utils import (
|
||||
ExtractorError,
|
||||
int_or_none,
|
||||
float_or_none,
|
||||
sanitized_Request,
|
||||
)
|
||||
|
||||
|
||||
class YandexMusicTrackIE(InfoExtractor):
|
||||
class YandexMusicBaseIE(InfoExtractor):
|
||||
@staticmethod
|
||||
def _handle_error(response):
|
||||
error = response.get('error')
|
||||
if error:
|
||||
raise ExtractorError(error, expected=True)
|
||||
|
||||
def _download_json(self, *args, **kwargs):
|
||||
response = super(YandexMusicBaseIE, self)._download_json(*args, **kwargs)
|
||||
self._handle_error(response)
|
||||
return response
|
||||
|
||||
|
||||
class YandexMusicTrackIE(YandexMusicBaseIE):
|
||||
IE_NAME = 'yandexmusic:track'
|
||||
IE_DESC = 'Яндекс.Музыка - Трек'
|
||||
_VALID_URL = r'https?://music\.yandex\.(?:ru|kz|ua|by)/album/(?P<album_id>\d+)/track/(?P<id>\d+)'
|
||||
|
@ -73,7 +87,7 @@ def _real_extract(self, url):
|
|||
return self._get_track_info(track)
|
||||
|
||||
|
||||
class YandexMusicPlaylistBaseIE(InfoExtractor):
|
||||
class YandexMusicPlaylistBaseIE(YandexMusicBaseIE):
|
||||
def _build_playlist(self, tracks):
|
||||
return [
|
||||
self.url_result(
|
||||
|
|
Loading…
Reference in a new issue