Raise exception when try to download track with unavailable bitrate

このコミットが含まれているのは:
lemonpaul 2020-02-24 12:01:26 +03:00
コミット 3e2e9f5fce
2個のファイルの変更10行の追加0行の削除

ファイルの表示

@ -26,6 +26,12 @@ class Unauthorized(YandexMusicError):
pass
class InvalidBitrate(YandexMusicError):
"""Класс исключения, вызываемого при попытке загрузки трека
с недоступным битрейтом.
"""
class Captcha(YandexMusicError):
"""Базовый класс, представляющий исключение связанное с капчей.

ファイルの表示

@ -1,6 +1,7 @@
from typing import TYPE_CHECKING, Optional, List, Union
from yandex_music import YandexMusicObject
from yandex_music.exceptions import InvalidBitrate
if TYPE_CHECKING:
from yandex_music import Client, Normalization, Major, Album, Artist, Supplement, DownloadInfo
@ -114,6 +115,9 @@ class Track(YandexMusicObject):
for info in self.download_info:
if info.codec == codec and info.bitrate_in_kbps == bitrate_in_kbps:
info.download(filename)
break
else:
raise InvalidBitrate('Unavailable bitrate')
def like(self, *args, **kwargs) -> bool:
"""Сокращение для::