Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- playlist_name = raw_input("Enter playlist name: ")
- def get_share_token_by_playlist_name(input_playlist_name):
- """
- Function gets all user playlists and returns share token.
- If playlist isn't found -> returns error message.
- """
- lists = api.get_all_playlists()
- for i in range(len(lists)):
- if lists[i]["name"] == input_playlist_name:
- token = lists[i]["shareToken"]
- return token
- print "Playlist is not found or isn't shared."
- def get_share_token():
- """
- If share token is found -> returns token.
- Else -> requests correct playlist name
- """
- global playlist_name
- while True:
- if get_share_token_by_playlist_name(playlist_name):
- token = get_share_token_by_playlist_name(playlist_name)
- return token
- else:
- playlist_name = raw_input("Enter playlist name" +
- " or print 'close' to exit: ")
- if playlist_name == 'close':
- print 'Good Bye!'
- sleep(1)
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement