import time import json import sys sys.path.insert(0, '/rpclib/') from rpclib import rpc from time import mktime from yandex_music import Client with open('config.json') as f: y = json.load(f) print(y) client = Client.from_credentials(y["email"], y["password"]) print("Starting") client_id = '877154344124960809' rpc_obj = rpc.DiscordIpcClient.for_platform(client_id) print("RPC connection successful.") lastTrack = "none" time.sleep(5) start_time = mktime(time.localtime()) while True: queues = client.queues_list() last_queue = client.queue(queues[0].id) last_track_id = last_queue.get_current_track() last_track = last_track_id.fetch_track() artists = ', '.join(last_track.artists_name()) title = last_track.title print(f'AListening to: {artists} - {title}') if (title != lastTrack): print("CHANGED") activity = { "state": title, "details": f'Listening to {artists} -', "assets": { "small_text": "Yandex", "small_image": "og-image", "large_text": "Madi", "large_image": "pongnew" } } rpc_obj.set_activity(activity) lastTrack = title time.sleep(50)