2021-02-01 21:46:20 +09:00
|
|
|
import os
|
|
|
|
|
|
|
|
from yandex_music import Client
|
|
|
|
|
|
|
|
|
|
|
|
CHART_ID = 'world'
|
|
|
|
TOKEN = os.environ.get('TOKEN')
|
|
|
|
|
2022-02-20 02:59:53 +09:00
|
|
|
client = Client(TOKEN).init()
|
2021-02-01 21:46:20 +09:00
|
|
|
chart = client.chart(CHART_ID).chart
|
|
|
|
|
|
|
|
text = [f'🏆 {chart.title}', chart.description, '', 'Треки:']
|
|
|
|
|
|
|
|
for track_short in chart.tracks:
|
|
|
|
track, chart = track_short.track, track_short.chart
|
|
|
|
artists = ''
|
|
|
|
if track.artists:
|
|
|
|
artists = ' - ' + ', '.join(artist.name for artist in track.artists)
|
|
|
|
|
|
|
|
track_text = f'{track.title}{artists}'
|
|
|
|
|
|
|
|
if chart.progress == 'down':
|
|
|
|
track_text = '🔻 ' + track_text
|
|
|
|
elif chart.progress == 'up':
|
|
|
|
track_text = '🔺 ' + track_text
|
|
|
|
elif chart.progress == 'new':
|
|
|
|
track_text = '🆕 ' + track_text
|
|
|
|
elif chart.position == 1:
|
|
|
|
track_text = '👑 ' + track_text
|
|
|
|
|
|
|
|
track_text = f'{chart.position} {track_text}'
|
|
|
|
text.append(track_text)
|
|
|
|
|
|
|
|
print('\n'.join(text))
|