@@ -30,12 +30,10 @@ def database_controller(
30
30
31
31
@database_controller .route ("populate_user" , methods = ["GET" ])
32
32
def populate_user ():
33
- access_token = request .cookies .get ("spotify_access_token " )
34
- user = spotify .get_user_by_id (access_token )
33
+ user_id = request .cookies .get ("user_id " )
34
+ user = spotify .get_user_by_id (user_id = user_id )
35
35
(db_user , _ ) = get_or_create_user (user )
36
- simplified_playlists = spotify .get_all_playlists (
37
- user_id = user .id , access_token = access_token
38
- )
36
+ simplified_playlists = spotify .get_all_playlists (user_id = user .id )
39
37
40
38
for simplified_playlist in simplified_playlists :
41
39
with database .database .atomic ():
@@ -50,7 +48,6 @@ def populate_user():
50
48
delete_playlist (db_playlist .id )
51
49
playlist = spotify .get_playlist (
52
50
user_id = user .id ,
53
- access_token = access_token ,
54
51
id = simplified_playlist .id ,
55
52
)
56
53
create_playlist (playlist , db_user )
@@ -59,21 +56,19 @@ def populate_user():
59
56
60
57
@database_controller .route ("populate_playlist/<id>" , methods = ["GET" ])
61
58
def populate_playlist (id ):
62
- access_token = request .cookies .get ("spotify_access_token " )
63
- user = spotify .get_user_by_id (access_token )
59
+ user_id = request .cookies .get ("user_id " )
60
+ user = spotify .get_user_by_id (user_id = user_id )
64
61
(db_user , _ ) = get_or_create_user (user )
65
62
db_playlist = get_playlist_by_id_or_none (id )
66
63
if db_playlist is not None :
67
64
delete_playlist (db_playlist .id )
68
- playlist = spotify .get_playlist (
69
- user_id = user .id , access_token = access_token , id = id
70
- )
65
+ playlist = spotify .get_playlist (user_id = user .id , id = id )
71
66
create_playlist (playlist , db_user )
72
67
albums = get_playlist_albums (playlist .id )
73
68
batch_albums = split_list (albums , 20 )
74
69
for album_chunk in batch_albums :
75
70
albums = spotify .get_multiple_albums (
76
- access_token = access_token , ids = [album .id for album in album_chunk ]
71
+ user_id = user_id , ids = [album .id for album in album_chunk ]
77
72
)
78
73
for db_album in albums :
79
74
with database .database .atomic ():
@@ -86,13 +81,12 @@ def populate_playlist(id):
86
81
87
82
@database_controller .route ("populate_additional_album_details" , methods = ["GET" ])
88
83
def populate_additional_album_details ():
89
- access_token = request .cookies .get ("spotify_access_token" )
90
- user = spotify .get_user_by_id (access_token )
91
- albums = get_user_albums_with_no_artists (user .id )
84
+ user_id = request .cookies .get ("user_id" )
85
+ albums = get_user_albums_with_no_artists (user_id = user_id )
92
86
batch_albums = split_list (albums , 20 )
93
87
for album_chunk in batch_albums :
94
88
albums = spotify .get_multiple_albums (
95
- access_token = access_token , ids = [album .id for album in album_chunk ]
89
+ user_id = user_id , ids = [album .id for album in album_chunk ]
96
90
)
97
91
for db_album in albums :
98
92
with database .database .atomic ():
@@ -111,8 +105,8 @@ def populate_universal_genre_list():
111
105
112
106
@database_controller .route ("populate_user_album_genres" , methods = ["GET" ])
113
107
def populate_user_album_genres ():
114
- access_token = request .cookies .get ("spotify_access_token " )
115
- user = spotify .get_user_by_id (access_token )
108
+ user_id = request .cookies .get ("user_id " )
109
+ user = spotify .get_user_by_id (user_id = user_id )
116
110
populate_album_genres_by_user_id (user .id , musicbrainz )
117
111
return make_response ("User album genres populated" , 201 )
118
112
0 commit comments