исправлен tracks_download_info при get_direct_links=True в асинхронной версии

このコミットが含まれているのは:
Il'ya (Marshal) 2022-02-20 00:36:38 +01:00
コミット 57bcbad472
4個のファイルの変更27行の追加5行の削除

ファイルの表示

@ -77,6 +77,7 @@ def gen_client(output_client_filename):
'self.rotor_station_feedback(',
'await self.rotor_station_feedback('
)
code = code.replace('return DownloadInfo.de_list', 'return await DownloadInfo.de_list_async')
code = DISCLAIMER + code
with open(output_client_filename, 'w') as f:

ファイルの表示

@ -566,8 +566,6 @@ class Client(YandexMusicObject):
result = self._request.get(url, timeout=timeout, *args, **kwargs)
# TODO (MarshalX) fix get_direct_links=True in async version
return DownloadInfo.de_list(result, self, get_direct_links)
@log

ファイルの表示

@ -572,9 +572,7 @@ class ClientAsync(YandexMusicObject):
result = await self._request.get(url, timeout=timeout, *args, **kwargs)
# TODO (MarshalX) fix get_direct_links=True in async version
return DownloadInfo.de_list(result, self, get_direct_links)
return await DownloadInfo.de_list_async(result, self, get_direct_links)
@log
async def track_supplement(

ファイルの表示

@ -151,6 +151,31 @@ class DownloadInfo(YandexMusicObject):
return downloads_info
@classmethod
async def de_list_async(cls, data: dict, client: 'Client', get_direct_links: bool = False) -> List['DownloadInfo']:
"""Десериализация списка объектов.
Args:
data (:obj:`list`): Список словарей с полями и значениями десериализуемого объекта.
get_direct_links (:obj:`bool`): Получать ли сразу прямые ссылки на загрузку.
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
Returns:
:obj:`list` из :obj:`yandex_music.DownloadInfo`: Варианты загрузки треков.
"""
if not data:
return []
downloads_info = list()
for download_info in data:
downloads_info.append(cls.de_json(download_info, client))
if get_direct_links:
for info in downloads_info:
await info.get_direct_link_async()
return downloads_info
# camelCase псевдонимы
#: Псевдоним для :attr:`get_direct_link`