-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmusic_commands.py
31 lines (28 loc) · 986 Bytes
/
music_commands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import music_request
def getArtist(artist):
token = music_request.get_token()
result = music_request.search_for_artist(token, artist)
artist_name = result["name"]
return artist_name
def getRelatedArtists(artist):
token = music_request.get_token()
result = music_request.search_for_artist(token, artist)
artist_id = result["id"]
related_artists = music_request.get_related_artists(token, artist_id)
final_message = ""
i = 0
for artist in related_artists:
i+=1
name = artist['name']
final_message += f"{i}. {name}\n"
return final_message
def getTrack(artist):
tracks = ""
token = music_request.get_token()
result = music_request.search_for_artist(token, artist)
artist_id = result["id"]
songs = music_request.get_songs_by_artists(token, artist_id)
for i, song in enumerate(songs):
tracks += (str(i + 1) + ". " + song['name'] + "\n")
response = f"\n{tracks}"
return response