added playlist export

This commit is contained in:
aj 2019-02-27 23:48:19 +00:00
parent 920f2e4ed7
commit ce560396aa
5 changed files with 142 additions and 5 deletions

22
main.py
View File

@ -6,15 +6,27 @@ if __name__ == '__main__':
user = userclass.User() user = userclass.User()
playlists = playlist.getPlaylists(user) #playlists = playlist.getPlaylists(user)
#for playlister in playlists: #for playlister in playlists:
#print(playlister['name']) #print(playlister['name'])
print(playlists[0]) #print(playlists[0])
#print(len(playlists)) #print(len(playlists))
print(user.username) #print(user.username)
moreplaylists = playlist.getUserPlaylists(user) #moreplaylists = playlist.getUserPlaylists(user)
print(len(moreplaylists)) #print(len(moreplaylists))
#tracks = playlist.getPlaylistTracks(user, '000Eh2vXzYGgrEFlgcWZj3')
#print(tracks[0])
#print(len(tracks))
import spotframework.io.csv as csvwrite
csvwrite.exportPlaylist(user, '000Eh2vXzYGgrEFlgcWZj3')
print(user.access_token)

60
out.csv Normal file
View File

@ -0,0 +1,60 @@
name,artist,album,album artist,added,spotify id,added by
Senses - DJ Q Remix,"My Nu Leng, Iyamah, DJ Q",Senses (DJ Q Remix),My Nu Leng,2019-02-01T11:31:35Z,1qBxCLvpRJ5bG2i1Y0x8hD,sarsoo
M.O.D,"Holy Goof, Notion",Globes,Holy Goof,2019-02-01T11:57:09Z,49vPDBFvOB9RKQNtzeLDay,sarsoo
Only Us - VIP,"Francois & Louis Benton, Riddim Commission, Asha",Globes,Holy Goof,2019-02-01T11:57:09Z,6fPoorVRF5PyhSw6G7Yg1W,sarsoo
Shutdown - VIP,"Holy Goof, Chris Lorenzo",Globes,Holy Goof,2019-02-01T11:57:09Z,6axdwbHCgU8nDBqDr9zOi4,sarsoo
Time,"Notion, Cecelia",Globes,Holy Goof,2019-02-01T11:57:09Z,2IemEFiwZ3hoTmiGYlotG4,sarsoo
Let You Go,"Holy Goof, TS7",Globes,Holy Goof,2019-02-01T11:57:09Z,7M5Y2qx08PuUBNH6TyhbF9,sarsoo
Flows,Skue-K,Globes,Holy Goof,2019-02-01T11:57:09Z,1sN1DfP5uRzyWJi8b6fl0j,sarsoo
What 2 Say,"Holy Goof, FineArt",Globes,Holy Goof,2019-02-01T11:57:09Z,6hDMIFH7o679EYUsuWFKOH,sarsoo
About To Get Hype,"Pelikann, Barely Royal, Purple Velvet Curtains",Globes,Holy Goof,2019-02-01T11:57:09Z,3KvlsQNvQ8BLwJI7rkZCJp,sarsoo
The Force,"Holy Goof, Skepsis, Inja",Globes,Holy Goof,2019-02-01T11:57:09Z,1ncjDgvOzlKXAx6RJSuWCQ,sarsoo
I Believe,FooR,Globes,Holy Goof,2019-02-01T11:57:09Z,1kPSrfIC22Ns3nBVXVdgUy,sarsoo
Supersonic,Livsey,Globes,Holy Goof,2019-02-01T11:57:09Z,6D4rvRXWyakmNxIPQLPnwI,sarsoo
Gully,"Holy Goof, My Nu Leng, Takura",Globes,Holy Goof,2019-02-01T11:57:09Z,3jKucb0CVbI66ilDMcDwiI,sarsoo
Show Me How,Bushbaby,Globes,Holy Goof,2019-02-01T11:57:09Z,4gkKcAyrh61Hfcpj81mtH6,sarsoo
Take Me Away,XX92,Globes,Holy Goof,2019-02-01T11:57:09Z,6Mx8OezYdRyxXHXhO3j1M0,sarsoo
Edge,"Shapes, Prima",Globes,Holy Goof,2019-02-01T11:57:09Z,0mzFgjWXLxgn9guxkLUu7f,sarsoo
Countdown,"DJ Q, Jamie Duggan",Globes,Holy Goof,2019-02-01T11:57:09Z,5hkRkPXBLgstXExcsxUBDd,sarsoo
Evidence,"NuBass, Dread MC",Globes,Holy Goof,2019-02-01T11:57:09Z,2fSjvd4JqvqsPhKjnP21Yn,sarsoo
No Warning,Taiki Nulight,Globes,Holy Goof,2019-02-01T11:57:09Z,6LuNP7oYy3LPslUgHtkLFj,sarsoo
Spicy Noodles,Flava D,Globes,Holy Goof,2019-02-01T11:57:09Z,4N42f3TrE3gFSaEXPHr9Zp,sarsoo
Stubborn,Freddie Martin,Globes,Holy Goof,2019-02-01T11:57:09Z,3gj3J1HRil2MSi32qtMoaP,sarsoo
Go Hard,XX92,Globes,Holy Goof,2019-02-01T11:57:09Z,49UcKfLR5XYUcVJ46RMo1G,sarsoo
Vulpix,YAKO,Globes,Holy Goof,2019-02-01T11:57:09Z,7bUjqwgOQo1xlvouS0prY8,sarsoo
Pack Rack,Dommix,Globes,Holy Goof,2019-02-01T11:57:09Z,6QWGVEHzVsD4CO2lkcUz97,sarsoo
Back Again,"Jauz, Holy Goof",Globes,Holy Goof,2019-02-01T11:57:09Z,2A0BiNS9v0RAeRR6QPY3Or,sarsoo
Jumpin on a Jet,Future,Future Hndrxx Presents: The WIZRD,Future,2019-02-01T16:11:42Z,1I3ZAmPmbFV78oNKnibOiW,sarsoo
Hilary $wank,Joey Bada$$,Summer Knights,Joey Bada$$,2019-02-15T10:38:21Z,6XMJJGQ6gksbWOEzF2UpVO,sarsoo
My Yout (feat. Maverick Sabre),"Joey Bada$$, Maverick Sabre",Summer Knights,Joey Bada$$,2019-02-15T10:43:48Z,3uOM0nNQiWDP1oUnjCSax3,sarsoo
Sit n' Prey (feat. Dessy & T'nah Apex),"Joey Bada$$, Dessy, T'nah Apex",Summer Knights,Joey Bada$$,2019-02-15T10:43:48Z,0F1DQ2uVP823zh96gm6AUI,sarsoo
95 Till Infinity,Joey Bada$$,Summer Knights,Joey Bada$$,2019-02-15T10:58:42Z,7GTQgSPs8BYbn3YbmS78N8,sarsoo
#LongLiveSteelo (feat. T'nah Apex),"Joey Bada$$, T'nah Apex",Summer Knights,Joey Bada$$,2019-02-15T10:58:42Z,2jwQCbqmKxk2lsIFRLXNT4,sarsoo
My Jeep (feat. Flatbush Zombies & The Underachievers),"Joey Bada$$, Meechie Darko, Issa Gold, Chuck Strangers",Summer Knights,Joey Bada$$,2019-02-15T10:58:42Z,3O220xHBIQsN1mhqzpEPSJ,sarsoo
My Yout (feat. Collie Buddz),"Joey Bada$$, Collie Buddz",Summer Knights,Joey Bada$$,2019-02-15T10:58:42Z,5USzBvFBG43xcj0bY5mWmJ,sarsoo
Save The Children,Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,7gvJadQt9vhgVHG7O1L2sc,sarsoo
Greenbax (Introlude),Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,0wmY92RjMZNGu54vEUmcUT,sarsoo
Paper Trail$,Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,5jNrszQHRIVKmS9Ptb63pe,sarsoo
Piece of Mind,Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,79eDnbSBUXoSaoRPqUhTur,sarsoo
Big Dusty,Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,12Gtheom5qK2Hjo1qTCNkx,sarsoo
Hazeus View,Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,5wrM3MbU9xNuSZGbmRm9B7,sarsoo
Like Me (feat. BJ The Chicago Kid),Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,7c5EpKbPpL86QVaP8yla8e,sarsoo
Belly of the Beast (feat. Chronixx),Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,7lGRaop0gCoVMeY9fSZIkR,sarsoo
No. 99,Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,1Ora7FZJR5xWId7upB1dlo,sarsoo
Christ Conscious,Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,2w9Qq5cflc8Z6BraiDCyes,sarsoo
On & On (feat. Maverick Sabre & Dyemond Lewis),Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,3nndHObJ5j5wpSKhTVODDG,sarsoo
Escape 120 (feat. Raury),Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,28j9YL5SeBl2EXFU1G1WEn,sarsoo
Black Beetles,Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,7gZC4WIaFSGg38tvKD2jlA,sarsoo
O.C.B.,Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,14MrWN36U9DSjKo7pOCQiN,sarsoo
Curry Chicken,Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,4v3MF3UyP6ZilmkDDhWmS9,sarsoo
Run Up On Ya (feat. Action Bronson & Elle Varner) (Bonus),Joey Bada$$,B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,3eJKAy9ZJaZLGS8EJlihXy,sarsoo
Teach Me,"Joey Bada$$, Kiesza",B4.DA.$$,Joey Bada$$,2019-02-15T11:35:01Z,2qMjIHWyYgnEtcmoZc3R0u,sarsoo
Caterpillar - Drumsound & Bassline Smith Remix,"Black Sun Empire, State of Mind, Drumsound & Bassline Smith",The Wrong Room Remixed,Black Sun Empire,2019-02-19T08:54:36Z,5Ycplzm1BPZYMQs9iMxNsB,sarsoo
One Drink,"DLMT, Paraleven",One Drink,"DLMT, Paraleven",2019-02-19T09:22:02Z,7Fo51x6cURFo9jCzcv7WOL,sarsoo
What's Up Danger - Black Caviar Remix,"Blackway, Black Caviar",What's Up Danger (Black Caviar Remix),"Blackway, Black Caviar",2019-02-19T09:28:44Z,0fOxkxw7FKXuzNs64bsmyb,sarsoo
Flat Tummy Tea,"Freddie Gibbs, Madlib",Flat Tummy Tea,"Freddie Gibbs, Madlib",2019-02-20T09:47:09Z,6eF5uKCQV2d0bhblAxLujV,sarsoo
Rampage Anthem VIP,"SASASAS, Macky Gee, DJ Phantasy, MC Shabba D, Stormin MC, MC Skibadee, Harry Shotta",Rampage Anthem VIP,"SASASAS, Macky Gee, DJ Phantasy",2019-02-22T08:55:29Z,0m9BpxJvsHlPTyQta201uF,sarsoo
How Did I Get Here (feat. J. Cole),"Offset, J. Cole",FATHER OF 4,Offset,2019-02-22T15:39:36Z,32iPykTXUNZ9oGyACGUybq,sarsoo
Tats On My Face,Offset,FATHER OF 4,Offset,2019-02-22T15:47:29Z,4TzXqUIcdpAmre24puQ6Uu,sarsoo
Made Men,Offset,FATHER OF 4,Offset,2019-02-22T15:49:47Z,7vkL4wrBEmzr1wsiWRd1zO,sarsoo
Astral Projection,Enrico Sangiuliano,Astral Projection,Enrico Sangiuliano,2019-02-26T11:02:48Z,32nw9Qc5rYjsPWGLy14Yh5,sarsoo
1 name artist album album artist added spotify id added by
2 Senses - DJ Q Remix My Nu Leng, Iyamah, DJ Q Senses (DJ Q Remix) My Nu Leng 2019-02-01T11:31:35Z 1qBxCLvpRJ5bG2i1Y0x8hD sarsoo
3 M.O.D Holy Goof, Notion Globes Holy Goof 2019-02-01T11:57:09Z 49vPDBFvOB9RKQNtzeLDay sarsoo
4 Only Us - VIP Francois & Louis Benton, Riddim Commission, Asha Globes Holy Goof 2019-02-01T11:57:09Z 6fPoorVRF5PyhSw6G7Yg1W sarsoo
5 Shutdown - VIP Holy Goof, Chris Lorenzo Globes Holy Goof 2019-02-01T11:57:09Z 6axdwbHCgU8nDBqDr9zOi4 sarsoo
6 Time Notion, Cecelia Globes Holy Goof 2019-02-01T11:57:09Z 2IemEFiwZ3hoTmiGYlotG4 sarsoo
7 Let You Go Holy Goof, TS7 Globes Holy Goof 2019-02-01T11:57:09Z 7M5Y2qx08PuUBNH6TyhbF9 sarsoo
8 Flows Skue-K Globes Holy Goof 2019-02-01T11:57:09Z 1sN1DfP5uRzyWJi8b6fl0j sarsoo
9 What 2 Say Holy Goof, FineArt Globes Holy Goof 2019-02-01T11:57:09Z 6hDMIFH7o679EYUsuWFKOH sarsoo
10 About To Get Hype Pelikann, Barely Royal, Purple Velvet Curtains Globes Holy Goof 2019-02-01T11:57:09Z 3KvlsQNvQ8BLwJI7rkZCJp sarsoo
11 The Force Holy Goof, Skepsis, Inja Globes Holy Goof 2019-02-01T11:57:09Z 1ncjDgvOzlKXAx6RJSuWCQ sarsoo
12 I Believe FooR Globes Holy Goof 2019-02-01T11:57:09Z 1kPSrfIC22Ns3nBVXVdgUy sarsoo
13 Supersonic Livsey Globes Holy Goof 2019-02-01T11:57:09Z 6D4rvRXWyakmNxIPQLPnwI sarsoo
14 Gully Holy Goof, My Nu Leng, Takura Globes Holy Goof 2019-02-01T11:57:09Z 3jKucb0CVbI66ilDMcDwiI sarsoo
15 Show Me How Bushbaby Globes Holy Goof 2019-02-01T11:57:09Z 4gkKcAyrh61Hfcpj81mtH6 sarsoo
16 Take Me Away XX92 Globes Holy Goof 2019-02-01T11:57:09Z 6Mx8OezYdRyxXHXhO3j1M0 sarsoo
17 Edge Shapes, Prima Globes Holy Goof 2019-02-01T11:57:09Z 0mzFgjWXLxgn9guxkLUu7f sarsoo
18 Countdown DJ Q, Jamie Duggan Globes Holy Goof 2019-02-01T11:57:09Z 5hkRkPXBLgstXExcsxUBDd sarsoo
19 Evidence NuBass, Dread MC Globes Holy Goof 2019-02-01T11:57:09Z 2fSjvd4JqvqsPhKjnP21Yn sarsoo
20 No Warning Taiki Nulight Globes Holy Goof 2019-02-01T11:57:09Z 6LuNP7oYy3LPslUgHtkLFj sarsoo
21 Spicy Noodles Flava D Globes Holy Goof 2019-02-01T11:57:09Z 4N42f3TrE3gFSaEXPHr9Zp sarsoo
22 Stubborn Freddie Martin Globes Holy Goof 2019-02-01T11:57:09Z 3gj3J1HRil2MSi32qtMoaP sarsoo
23 Go Hard XX92 Globes Holy Goof 2019-02-01T11:57:09Z 49UcKfLR5XYUcVJ46RMo1G sarsoo
24 Vulpix YAKO Globes Holy Goof 2019-02-01T11:57:09Z 7bUjqwgOQo1xlvouS0prY8 sarsoo
25 Pack Rack Dommix Globes Holy Goof 2019-02-01T11:57:09Z 6QWGVEHzVsD4CO2lkcUz97 sarsoo
26 Back Again Jauz, Holy Goof Globes Holy Goof 2019-02-01T11:57:09Z 2A0BiNS9v0RAeRR6QPY3Or sarsoo
27 Jumpin on a Jet Future Future Hndrxx Presents: The WIZRD Future 2019-02-01T16:11:42Z 1I3ZAmPmbFV78oNKnibOiW sarsoo
28 Hilary $wank Joey Bada$$ Summer Knights Joey Bada$$ 2019-02-15T10:38:21Z 6XMJJGQ6gksbWOEzF2UpVO sarsoo
29 My Yout (feat. Maverick Sabre) Joey Bada$$, Maverick Sabre Summer Knights Joey Bada$$ 2019-02-15T10:43:48Z 3uOM0nNQiWDP1oUnjCSax3 sarsoo
30 Sit n' Prey (feat. Dessy & T'nah Apex) Joey Bada$$, Dessy, T'nah Apex Summer Knights Joey Bada$$ 2019-02-15T10:43:48Z 0F1DQ2uVP823zh96gm6AUI sarsoo
31 95 Till Infinity Joey Bada$$ Summer Knights Joey Bada$$ 2019-02-15T10:58:42Z 7GTQgSPs8BYbn3YbmS78N8 sarsoo
32 #LongLiveSteelo (feat. T'nah Apex) Joey Bada$$, T'nah Apex Summer Knights Joey Bada$$ 2019-02-15T10:58:42Z 2jwQCbqmKxk2lsIFRLXNT4 sarsoo
33 My Jeep (feat. Flatbush Zombies & The Underachievers) Joey Bada$$, Meechie Darko, Issa Gold, Chuck Strangers Summer Knights Joey Bada$$ 2019-02-15T10:58:42Z 3O220xHBIQsN1mhqzpEPSJ sarsoo
34 My Yout (feat. Collie Buddz) Joey Bada$$, Collie Buddz Summer Knights Joey Bada$$ 2019-02-15T10:58:42Z 5USzBvFBG43xcj0bY5mWmJ sarsoo
35 Save The Children Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 7gvJadQt9vhgVHG7O1L2sc sarsoo
36 Greenbax (Introlude) Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 0wmY92RjMZNGu54vEUmcUT sarsoo
37 Paper Trail$ Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 5jNrszQHRIVKmS9Ptb63pe sarsoo
38 Piece of Mind Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 79eDnbSBUXoSaoRPqUhTur sarsoo
39 Big Dusty Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 12Gtheom5qK2Hjo1qTCNkx sarsoo
40 Hazeus View Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 5wrM3MbU9xNuSZGbmRm9B7 sarsoo
41 Like Me (feat. BJ The Chicago Kid) Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 7c5EpKbPpL86QVaP8yla8e sarsoo
42 Belly of the Beast (feat. Chronixx) Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 7lGRaop0gCoVMeY9fSZIkR sarsoo
43 No. 99 Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 1Ora7FZJR5xWId7upB1dlo sarsoo
44 Christ Conscious Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 2w9Qq5cflc8Z6BraiDCyes sarsoo
45 On & On (feat. Maverick Sabre & Dyemond Lewis) Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 3nndHObJ5j5wpSKhTVODDG sarsoo
46 Escape 120 (feat. Raury) Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 28j9YL5SeBl2EXFU1G1WEn sarsoo
47 Black Beetles Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 7gZC4WIaFSGg38tvKD2jlA sarsoo
48 O.C.B. Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 14MrWN36U9DSjKo7pOCQiN sarsoo
49 Curry Chicken Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 4v3MF3UyP6ZilmkDDhWmS9 sarsoo
50 Run Up On Ya (feat. Action Bronson & Elle Varner) (Bonus) Joey Bada$$ B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 3eJKAy9ZJaZLGS8EJlihXy sarsoo
51 Teach Me Joey Bada$$, Kiesza B4.DA.$$ Joey Bada$$ 2019-02-15T11:35:01Z 2qMjIHWyYgnEtcmoZc3R0u sarsoo
52 Caterpillar - Drumsound & Bassline Smith Remix Black Sun Empire, State of Mind, Drumsound & Bassline Smith The Wrong Room Remixed Black Sun Empire 2019-02-19T08:54:36Z 5Ycplzm1BPZYMQs9iMxNsB sarsoo
53 One Drink DLMT, Paraleven One Drink DLMT, Paraleven 2019-02-19T09:22:02Z 7Fo51x6cURFo9jCzcv7WOL sarsoo
54 What's Up Danger - Black Caviar Remix Blackway, Black Caviar What's Up Danger (Black Caviar Remix) Blackway, Black Caviar 2019-02-19T09:28:44Z 0fOxkxw7FKXuzNs64bsmyb sarsoo
55 Flat Tummy Tea Freddie Gibbs, Madlib Flat Tummy Tea Freddie Gibbs, Madlib 2019-02-20T09:47:09Z 6eF5uKCQV2d0bhblAxLujV sarsoo
56 Rampage Anthem VIP SASASAS, Macky Gee, DJ Phantasy, MC Shabba D, Stormin MC, MC Skibadee, Harry Shotta Rampage Anthem VIP SASASAS, Macky Gee, DJ Phantasy 2019-02-22T08:55:29Z 0m9BpxJvsHlPTyQta201uF sarsoo
57 How Did I Get Here (feat. J. Cole) Offset, J. Cole FATHER OF 4 Offset 2019-02-22T15:39:36Z 32iPykTXUNZ9oGyACGUybq sarsoo
58 Tats On My Face Offset FATHER OF 4 Offset 2019-02-22T15:47:29Z 4TzXqUIcdpAmre24puQ6Uu sarsoo
59 Made Men Offset FATHER OF 4 Offset 2019-02-22T15:49:47Z 7vkL4wrBEmzr1wsiWRd1zO sarsoo
60 Astral Projection Enrico Sangiuliano Astral Projection Enrico Sangiuliano 2019-02-26T11:02:48Z 32nw9Qc5rYjsPWGLy14Yh5 sarsoo

View File

36
spotframework/io/csv.py Normal file
View File

@ -0,0 +1,36 @@
import csv
import spotframework.net.playlist as playlistpull
headers = ['name', 'artist', 'album', 'album artist', 'added', 'spotify id', 'added by']
def exportPlaylist(user, playlistid):
playlist = playlistpull.getPlaylistTracks(user, playlistid)
with open('out.csv', 'w') as fileobj:
writer = csv.DictWriter(fileobj, fieldnames = headers)
writer.writeheader()
for track in playlist:
trackdict = {
'name':track['track']['name'],
'album':track['track']['album']['name'],
'added':track['added_at'],
'spotify id':track['track']['id'],
'added by':track['added_by']['id']}
alart = []
for albumartist in track['track']['album']['artists']:
alart.append(albumartist['name'])
trackdict['album artist'] = ', '.join(alart)
art = []
for artist in track['track']['artists']:
art.append(artist['name'])
trackdict['artist'] = ', '.join(art)
writer.writerow(trackdict)

View File

@ -44,3 +44,32 @@ def getUserPlaylists(user):
return returnlist return returnlist
def getPlaylistTracks(user, playlistid, offset = 0):
headers = {'Authorization': 'Bearer ' + user.access_token}
tracks = []
params = {'offset': offset, 'limit': limit}
req = requests.get(const.api_url + 'playlists/{}/tracks'.format(playlistid), params = params, headers = headers)
#print(req.text)
if req.status_code == 200:
print(req.text)
resp = req.json()
tracks += resp['items']
if resp['next']:
tracks += getPlaylistTracks(user, playlistid, offset + limit)
#print(req.text)
return tracks
else:
return None