matrix-music-bot

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit a9083260920c9d5f85ef13a69a081b50dbba16ff
parent 5ad8a9b5c367593cf06ddd3bb33bb02ed7d80c3e
Author: John <mail@johnkubach.com>
Date:   Wed, 19 Oct 2022 19:41:40 -0400

Get Similar Artists

Diffstat:
Mfunctions/extract_info.py | 13+++++++++++++
Mmusic.py | 4+++-
2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/functions/extract_info.py b/functions/extract_info.py @@ -30,6 +30,19 @@ def get_artist_info(artist): return info +def get_similar_artists(artist): + try: + info = lastfm_network.get_artist(artist).get_similar(limit=3) + artist_list = [] + for t in info: + artist_list.append(t.item.get_name()) + + format_tags = ', '.join(artist_list) + except pylast.WSError as e: + format_tags = None + + return format_tags + def get_tags(artist): try: info = lastfm_network.get_artist(artist).get_top_tags(limit=2) diff --git a/music.py b/music.py @@ -8,6 +8,7 @@ from functions.extract_info import ( get_video_info, get_artist_song, get_artist_info, + get_similar_artists, get_tags ) @@ -41,9 +42,10 @@ def youtube(event): if artist: tags = get_tags(artist) bio = get_artist_info(artist) - + similar_artists = get_similar_artists(artist) if tags and bio: song_info.append("Genre: " + tags) + song_info.append("Similar Artists: " + similar_artists) song_info.append(re.sub('<.*?>', '', bio)) else: song_info.append(desc)