Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch_lyrics_async ERROR #620

Closed
Koddom opened this issue Nov 1, 2023 · 1 comment · Fixed by #627
Closed

fetch_lyrics_async ERROR #620

Koddom opened this issue Nov 1, 2023 · 1 comment · Fixed by #627
Assignees
Labels
bug Что-то не работает

Comments

@Koddom
Copy link

Koddom commented Nov 1, 2023

Ошибка при получении текста песни
Если у вас асинхронный клиент и вы попытаетесь получить текст песни, сработает исключение.

код

lyrics = await track.get_lyrics_async()
text = await lyrics.fetch_lyrics_async()

Ошибка

# RuntimeWarning: coroutine 'Request.retrieve' was never awaited
# return await self.client.request.retrieve(self.download_url).decode('UTF-8')
# RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Решение
Чуток изменить код метода

  async def fetch_lyrics_async(self) -> str:
       """Получает текст песни по ссылке :attr:`yandex_music.TrackLyrics.download_url`.

       Returns:
           :obj:`str`: Текст песни.
       """
       text = await self.client.request.retrieve(self.download_url)  # сначала дождаться выполнения корутины
       text = text.decode('UTF-8')  # затем применить метод
                       
       return   text

Дополнительная информация
Спасибо за ваш труд! Вы крутые ребята! "Зачем служить на флоте, если можно быть пиратом" )))
контакты:
tg.me/koddom
www.koddom.com

@Koddom Koddom added the bug Что-то не работает label Nov 1, 2023
@MarshalX
Copy link
Owner

Спасибо!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Что-то не работает
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants