SHARE
TWEET

Untitled

a guest Jun 14th, 2017 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import tidalapi
  2. import json
  3.  
  4.  
  5. session = tidalapi.Session()
  6.  
  7. with open('credentials.json') as data_file:
  8.     data = json.load(data_file)
  9.     print(data)
  10.  
  11.  
  12. login = data["login"]
  13. password = data["password"]
  14. session.login(login, password)
  15. id = 0000000 #Id of user (?). gen be get from browser player
  16.  
  17. #For quick test
  18. '''
  19. tracks = session.get_album_tracks(album_id=16909093)
  20. for track in tracks:
  21.     print(track.name)
  22.  
  23.  
  24. #user = tidalapi.User(session,id)
  25.  
  26. '''
  27.  
  28. favorites = tidalapi.Favorites(session,id);
  29. artists = favorites.artists();
  30. print('===========================')
  31.  
  32. file = open('artists.txt','w', encoding='utf-8')
  33. for artist in artists:
  34.     file.write(artist.name + '\n')
  35.  
  36. tracks = favorites.tracks();
  37. tracks_list = []
  38. for track in tracks:
  39.     tracks_list.append({"track_name": track.name, "track_artist" : track.artist.name})
  40. with open('tracks.json', 'w') as f:
  41.     for track in tracks_list:
  42.         json.dump(track, f, ensure_ascii=False)
  43.         f.write('\n')
  44.  
  45.  
  46.  
  47. albums = favorites.albums();
  48. albums_list = []
  49. for album in albums:
  50.     albums_list.append({"album_name": album.name, "album_artist" : album.artist.name})
  51. albums_json = json.dumps(albums_list)
  52. print(albums_json)
  53. with open('albums.json', 'w') as f:
  54.     for album in albums_list:
  55.         json.dump(album, f, ensure_ascii=False)
  56.         f.write('\n')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top