Raise exception when try to download track with unavailable bitrate
このコミットが含まれているのは:
コミット
3e2e9f5fce
|
@ -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:
|
||||
"""Сокращение для::
|
||||
|
|
読み込み中…
新しいイシューから参照