<s> import sys <EOL> import os <EOL> import spotipy <EOL> import spotipy . util as util <EOL> def show_tracks ( results ) : <EOL> for i , item in enumerate ( tracks [ '<STR_LIT>' ] ) : <EOL> track = item [ '<STR_LIT>' ] <EOL> print ( "<STR_LIT>" % ( i , track [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:name>' ] , track [ '<STR_LIT:name>' ] ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> if len ( sys . argv ) > <NUM_LIT:1> : <EOL> username = sys . argv [ <NUM_LIT:1> ] <EOL> else : <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> sys . exit ( ) <EOL> token = util . prompt_for_user_token ( username ) <EOL> if token : <EOL> top = <NUM_LIT> <EOL> sp = spotipy . Spotify ( auth = token ) <EOL> playlists = sp . user_playlists ( username ) <EOL> for playlist in playlists [ '<STR_LIT>' ] : <EOL> if playlist [ '<STR_LIT>' ] [ '<STR_LIT:id>' ] == username : <EOL> print ( ) <EOL> print ( playlist [ '<STR_LIT:name>' ] ) <EOL> print ( '<STR_LIT>' , playlist [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> results = sp . user_playlist ( username , playlist [ '<STR_LIT:id>' ] , fields = "<STR_LIT>" ) <EOL> tracks = results [ '<STR_LIT>' ] <EOL> show_tracks ( tracks ) <EOL> while tracks [ '<STR_LIT>' ] : <EOL> tracks = sp . next ( tracks ) <EOL> show_tracks ( tracks ) <EOL> else : <EOL> print ( "<STR_LIT>" , username ) </s>
