-
Notifications
You must be signed in to change notification settings - Fork 0
/
recommendations.py
75 lines (64 loc) · 2.25 KB
/
recommendations.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from ytmusicapi import YTMusic
POP_HITS = "RDCLAK5uy_nmS3YoxSwVVQk9lEQJ0UX4ZCjXsW_psU8"
HIP_HOP_HITS = "RDCLAK5uy_kw2wIlEv9llILhO0qoMTLsBBhmjzuibAc"
INDIE_HITS = "RDCLAK5uy_kFs4DBLn3pFmAiXodtYyzaB5Xa_njue3A"
ROCK_HITS = "RDCLAK5uy_k6CicQMBYujmwL9DB5xBripE9EfgeKpHM"
class Recommendations:
def __init__(self):
self.ytmusic = YTMusic("oauth.json")
def pop_hits(self):
yt_response = self.ytmusic.get_playlist(playlistId=POP_HITS)
response = {
"songs": [
{
"title": song["title"],
"artist": song["artists"][0]["name"],
"id": song["videoId"],
"thumbnail": song["thumbnails"][0]["url"],
}
for song in yt_response["tracks"]
]
}
return response
def hip_hop_hits(self):
yt_response = self.ytmusic.get_playlist(playlistId=HIP_HOP_HITS)
response = {
"songs": [
{
"title": song["title"],
"artist": song["artists"][0]["name"],
"id": song["videoId"],
"thumbnail": song["thumbnails"][0]["url"],
}
for song in yt_response["tracks"]
]
}
return response
def indie_hits(self):
yt_response = self.ytmusic.get_playlist(playlistId=INDIE_HITS)
response = {
"songs": [
{
"title": song["title"],
"artist": song["artists"][0]["name"],
"id": song["videoId"],
"thumbnail": song["thumbnails"][0]["url"],
}
for song in yt_response["tracks"]
]
}
return response
def rock_hits(self):
yt_response = self.ytmusic.get_playlist(playlistId=ROCK_HITS)
response = {
"songs": [
{
"title": song["title"],
"artist": song["artists"][0]["name"],
"id": song["videoId"],
"thumbnail": song["thumbnails"][0]["url"],
}
for song in yt_response["tracks"]
]
}
return response