10
10
11
11
12
12
def login_user (username : str , password : str , login_data_dir : str )-> list :
13
- logger .debug (f"logging in user '{ username [:4 ]} ****@****.***'" )
13
+ logger .info (f"logging in user '{ username [:4 ]} ****@****.***'" )
14
14
# Check the username and if pickled sessionfile exists load the session and append
15
15
# Returns: [Success: Bool, Session: Session, PicklePath: str, premium: Bool]
16
16
sessobj_pikpath = os .path .join (login_data_dir , username + "_GUZpotifylogin.json" )
17
17
os .makedirs (os .path .dirname (sessobj_pikpath ), exist_ok = True )
18
18
if os .path .isfile (sessobj_pikpath ):
19
- logger .debug (f"Session file exists for user, attempting to use it '{ username [:4 ]} ****@****.***'" )
20
- logger .info ("Restoring user session" )
19
+ logger .info (f"Session file exists for user, attempting to use it '{ username [:4 ]} ****@****.***'" )
20
+ logger .debug ("Restoring user session" )
21
21
# Session exists try loading it
22
22
try :
23
23
config = Session .Configuration .Builder ().set_stored_credential_file (sessobj_pikpath ).build ()
@@ -27,7 +27,7 @@ def login_user(username: str, password: str, login_data_dir: str)->list:
27
27
session = Session .Builder (conf = config ).stored_file (sessobj_pikpath ).create ()
28
28
logger .debug ("Session created" )
29
29
premium = True if session .get_user_attribute ("type" ) == "premium" else False
30
- logger .debug (f"Login successful for user '{ username [:4 ]} ****@****.***'" )
30
+ logger .info (f"Login successful for user '{ username [:4 ]} ****@****.***'" )
31
31
return [True , session , sessobj_pikpath , premium ]
32
32
except (RuntimeError , Session .SpotifyAuthenticationException ):
33
33
logger .error (f"Failed logging in user '{ username [:4 ]} ****@****.***', invalid credentials" )
@@ -36,14 +36,14 @@ def login_user(username: str, password: str, login_data_dir: str)->list:
36
36
logger .error (f"Failed to login user '{ username [:4 ]} ****@****.***' due to unexpected error: { traceback .format_exc ()} " )
37
37
return [False , None , "" , False ]
38
38
else :
39
- logger .debug (f"Session file does not exist user '{ username [:4 ]} ****@****.***', attempting login with uname/pass" )
39
+ logger .info (f"Session file does not exist user '{ username [:4 ]} ****@****.***', attempting login with uname/pass" )
40
40
try :
41
- logger .debug (f"logging in user '{ username [:4 ]} ****@****.***'" )
41
+ logger .info (f"logging in user '{ username [:4 ]} ****@****.***'" )
42
42
config = Session .Configuration .Builder ().set_stored_credential_file (sessobj_pikpath ).build ()
43
43
print ("logging in !" )
44
44
session = Session .Builder (conf = config ).user_pass (username , password ).create ()
45
45
premium = True if session .get_user_attribute ("type" ) == "premium" else False
46
- logger .debug (f"Login successful for user '{ username [:4 ]} ****@****.***'" )
46
+ logger .info (f"Login successful for user '{ username [:4 ]} ****@****.***'" )
47
47
return [True , session , sessobj_pikpath , premium ]
48
48
except (RuntimeError , Session .SpotifyAuthenticationException ):
49
49
logger .error (f"Failed logging in user '{ username [:4 ]} ****@****.***', invalid credentials" )
@@ -54,7 +54,7 @@ def login_user(username: str, password: str, login_data_dir: str)->list:
54
54
return [False , None , "" , False ]
55
55
56
56
def remove_user (username : str , login_data_dir : str , config )-> bool :
57
- logger .debug (f"Removing user '{ username [:4 ]} ****@****.***' from saved entries" )
57
+ logger .info (f"Removing user '{ username [:4 ]} ****@****.***' from saved entries" )
58
58
sessobj_pikpath = os .path .join (login_data_dir , username + "_GUZpotifylogin.json" )
59
59
if os .path .isfile (sessobj_pikpath ):
60
60
os .remove (sessobj_pikpath )
@@ -69,14 +69,14 @@ def remove_user(username: str, login_data_dir: str, config)->bool:
69
69
removed = True
70
70
break
71
71
if removed :
72
- logger .debug (f"Saved Account user '{ username [:4 ]} ****@****.***' found and removed" )
72
+ logger .info (f"Saved Account user '{ username [:4 ]} ****@****.***' found and removed" )
73
73
config .set_ ("accounts" , accounts_copy )
74
74
config .update ()
75
75
return removed
76
76
77
77
78
78
def regex_input_for_urls (search_input ):
79
- logger .debug (f"Parsing url '{ search_input } '" )
79
+ logger .info (f"Parsing url '{ search_input } '" )
80
80
track_uri_search = re .search (
81
81
r"^spotify:track:(?P<TrackID>[0-9a-zA-Z]{22})$" , search_input )
82
82
track_url_search = re .search (
@@ -165,22 +165,22 @@ def regex_input_for_urls(search_input):
165
165
def get_url_data (url ):
166
166
track_id_str , album_id_str , playlist_id_str , episode_id_str , show_id_str , artist_id_str = regex_input_for_urls (url )
167
167
if track_id_str is not None :
168
- logger .debug (f"Parse result for url '{ url } '-> track, { track_id_str } " )
168
+ logger .info (f"Parse result for url '{ url } '-> track, { track_id_str } " )
169
169
return "track" , track_id_str
170
170
elif album_id_str is not None :
171
- logger .debug (f"Parse result for url '{ url } '-> album, { album_id_str } " )
171
+ logger .info (f"Parse result for url '{ url } '-> album, { album_id_str } " )
172
172
return "album" , album_id_str
173
173
elif playlist_id_str is not None :
174
- logger .debug (f"Parse result for url '{ url } '-> playlist, { playlist_id_str } " )
174
+ logger .info (f"Parse result for url '{ url } '-> playlist, { playlist_id_str } " )
175
175
return "playlist" , playlist_id_str
176
176
elif episode_id_str is not None :
177
- logger .debug (f"Parse result for url '{ url } '-> episode, { episode_id_str } " )
177
+ logger .info (f"Parse result for url '{ url } '-> episode, { episode_id_str } " )
178
178
return "episode" , episode_id_str
179
179
elif show_id_str is not None :
180
- logger .debug (f"Parse result for url '{ url } '-> podcast, { show_id_str } " )
180
+ logger .info (f"Parse result for url '{ url } '-> podcast, { show_id_str } " )
181
181
return "podcast" , show_id_str
182
182
elif artist_id_str is not None :
183
- logger .debug (f"Parse result for url '{ url } '-> artist, { artist_id_str } " )
183
+ logger .info (f"Parse result for url '{ url } '-> artist, { artist_id_str } " )
184
184
return "artist" , artist_id_str
185
185
else :
186
186
logger .error (f"Parse result for url '{ url } ' failed, invalid spotify url !" )
0 commit comments