瀏覽代碼

Added timer and stuff

master
Madiwka3 3 年之前
父節點
當前提交
e2ba04a960
共有 1 個檔案被更改,包括 18 行新增4 行删除
  1. +18
    -4
      main.py

+ 18
- 4
main.py 查看文件

@@ -19,22 +19,35 @@ rpc_obj = rpc.DiscordIpcClient.for_platform(client_id)
print("RPC connection successful.")
lastTrack = "none"
time.sleep(5)
start_time = mktime(time.localtime())
while True:
print("CHECK")
queues = client.queues_list()
print("1")
last_queue = client.queue(queues[0].id)
print("2")
last_track_id = last_queue.get_current_track()
print("3")
last_track = last_track_id.fetch_track()
print("4")
artists = ', '.join(last_track.artists_name())
print("5")
title = last_track.title
print(f'AListening to: {artists} - {title}')
if (title != lastTrack):
print("CHANGED")
start_time = mktime(time.localtime())
print(start_time)
print(start_time + (last_track.duration_ms/1000))
print(last_track.duration_ms/1000)
activity = {
"state": title,
"details": f'Listening to {artists} -',
"timestamps": {
"start": round(start_time),
"end": round(start_time + (last_track.duration_ms/1000))
},
"assets": {
"small_text": "Yandex",
"small_image": "og-image",
@@ -44,5 +57,6 @@ while True:
}
rpc_obj.set_activity(activity)
lastTrack = title
time.sleep(50)
time.sleep(5)
print("CHECK2")


Loading…
取消
儲存