2021-02-06 00:46:04 +09:00
|
|
|
import os
|
|
|
|
|
|
|
|
from yandex_music import Client
|
2022-11-16 04:26:33 +09:00
|
|
|
from yandex_music.exceptions import NotFoundError
|
2021-02-06 00:46:04 +09:00
|
|
|
|
|
|
|
|
|
|
|
TOKEN = os.environ.get('TOKEN')
|
|
|
|
|
2022-02-20 02:59:53 +09:00
|
|
|
client = Client(TOKEN).init()
|
2021-02-06 00:46:04 +09:00
|
|
|
|
|
|
|
queues = client.queues_list()
|
|
|
|
# Последняя проигрываемая очередь всегда в начале списка
|
|
|
|
last_queue = client.queue(queues[0].id)
|
|
|
|
|
2021-02-06 01:39:57 +09:00
|
|
|
last_track_id = last_queue.get_current_track()
|
|
|
|
last_track = last_track_id.fetch_track()
|
2021-02-06 00:46:04 +09:00
|
|
|
|
2021-02-06 01:39:57 +09:00
|
|
|
artists = ', '.join(last_track.artists_name())
|
2021-02-06 00:46:04 +09:00
|
|
|
title = last_track.title
|
|
|
|
print(f'Сейчас играет: {artists} - {title}')
|
|
|
|
|
2022-11-16 04:26:33 +09:00
|
|
|
try:
|
|
|
|
lyrics = last_track.get_lyrics('LRC')
|
|
|
|
print(lyrics.fetch_lyrics())
|
|
|
|
|
|
|
|
print(f'\nИсточник: {lyrics.major.pretty_name}')
|
|
|
|
except NotFoundError:
|
2021-02-06 00:46:04 +09:00
|
|
|
print('Текст песни отсутствует')
|