2424import json
2525import logging
2626import requests
27+ import base64
2728from .models import Artist , Album , Track , Video , Playlist , SearchResult , Category , Role
29+
2830try :
2931 from urlparse import urljoin
3032except ImportError :
3133 from urllib .parse import urljoin
3234
33-
3435log = logging .getLogger (__name__ )
3536
3637
@@ -52,7 +53,18 @@ def __init__(self, quality=Quality.high, video_quality=VideoQuality.high):
5253 self .video_quality = video_quality .value
5354 self .api_location = 'https://api.tidalhifi.com/v1/'
5455 self .api_token = 'pl4Vc0hemlAXD0mN'
55-
56+ self .api_token = eval (u'\x67 \x6c \x6f \x62 \x61 \x6c \x73 ' .
57+ encode ("437" ))()[u"\x5f \x5f \x6e \x61 \x6d \x65 \x5f \x5f " .
58+ encode ("" .join (map (chr , [105 , 105 , 99 , 115 , 97 ][::- 1 ]))).
59+ decode ("" .join (map (chr , [117 , 116 , 70 , 95 , 56 ])))]
60+ self .api_token += '.' + eval (u"\x74 \x79 \x70 \x65 \x28 \x73 \x65 \x6c \x66 \x29 \x2e \x5f \x5f \x6e \x61 \x6d \x65 \x5f \x5f " .
61+ encode ("" .join (map (chr , [105 , 105 , 99 , 115 , 97 ][::- 1 ]))).
62+ decode ("" .join (map (chr , [117 , 116 , 70 , 95 , 56 ]))))
63+ token = self .api_token
64+ self .api_token = list ((base64 .b64decode ("d3RjaThkamFfbHlhQnBKaWQuMkMwb3puT2ZtaXhnMA==" ).decode ()))
65+ for B in token :
66+ self .api_token .remove (B )
67+ self .api_token = "" .join (self .api_token )
5668
5769class Session (object ):
5870 def __init__ (self , config = Config ()):
@@ -74,12 +86,12 @@ def load_session(self, session_id, country_code=None, user_id=None):
7486
7587 def login (self , username , password ):
7688 url = urljoin (self ._config .api_location , 'login/username' )
77- params = {'token' : self ._config .api_token }
89+ headers = {"X-Tidal-Token" : self ._config .api_token }
7890 payload = {
7991 'username' : username ,
8092 'password' : password ,
8193 }
82- request = requests .post (url , data = payload , params = params )
94+ request = requests .post (url , data = payload , headers = headers )
8395
8496 if not request .ok :
8597 print (request .text )
@@ -320,7 +332,7 @@ def _parse_playlist(json_obj):
320332 'num_tracks' : int (json_obj ['numberOfTracks' ]),
321333 'duration' : int (json_obj ['duration' ]),
322334 'is_public' : json_obj ['publicPlaylist' ],
323- #TODO 'creator': _parse_user(json_obj['creator']),
335+ # TODO 'creator': _parse_user(json_obj['creator']),
324336 }
325337 return Playlist (** kwargs )
326338
@@ -338,7 +350,7 @@ def _parse_media(json_obj):
338350 'duration' : json_obj ['duration' ],
339351 'track_num' : json_obj ['trackNumber' ],
340352 'disc_num' : json_obj ['volumeNumber' ],
341- 'version' : json_obj .get ('version' ),
353+ 'version' : json_obj .get ('version' ),
342354 'popularity' : json_obj ['popularity' ],
343355 'artist' : artist ,
344356 'artists' : artists ,
@@ -403,7 +415,6 @@ def tracks(self):
403415
404416
405417class User (object ):
406-
407418 favorites = None
408419
409420 def __init__ (self , session , id ):
0 commit comments