def login_V2(email, password): client1 = Client.fromCredentials(email, password) settings_dict = {} settings_dict["TOKEN"] = client1.token main_TOKEN = client1.token with open('settings.json', 'w') as fp: json.dump(settings_dict, fp) isLoggedIn = True if os.path.exists('tracks.json'): os.remove('tracks.json') return main_TOKEN
def login(): print("Enter your email and password") email = input("Email:") password = input("Password:"******"TOKEN"] = client1.token main_TOKEN = client1.token with open('settings.json', 'w') as fp: json.dump(settings_dict, fp) isLoggedIn = True if os.path.exists('tracks.json'): os.remove('tracks.json') return main_TOKEN client1 = Ya_Client(main_TOKEN)
import datetime from yandex_music.client import Client # Help text if len(sys.argv) == 1 or len(sys.argv) > 3: print('Usage: DailyPlaylistUpdater.py token') print('token - Authentication token') print('\nUsage: DailyPlaylistUpdater.py username password') print('username - username in format \'[email protected]\'') print('password - your password') quit() # Authorization elif len(sys.argv) == 2: client = Client.fromToken(sys.argv[1]) elif len(sys.argv) == 3: client = Client.fromCredentials(sys.argv[1], sys.argv[2]) # Current daily playlist PersonalPlaylistBlocks = client.landing(blocks=['personalplaylists']).blocks[0] DailyPlaylist = next( x.data.data for x in PersonalPlaylistBlocks.entities if x.data.data.generated_playlist_type == 'playlistOfTheDay') # Check if we don't need to update it if DailyPlaylist.play_counter.updated: modifiedDate = datetime.datetime.strptime(DailyPlaylist.modified, "%Y-%m-%dT%H:%M:%S%z").date() if datetime.datetime.now().date() == modifiedDate: print('\x1b[6;30;43m' + 'Looks like it has been already updated today' + '\x1b[0m') quit()