A Python script to show your currently playing Yandex music in your Discord status!
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

3 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import time
  2. import json
  3. import sys
  4. sys.path.insert(0, '/rpclib/')
  5. from rpclib import rpc
  6. from time import mktime
  7. from yandex_music import Client
  8. with open('config.json') as f:
  9. y = json.load(f)
  10. print(y)
  11. client = Client.from_credentials(y["email"], y["password"])
  12. print("Starting")
  13. client_id = '877154344124960809'
  14. rpc_obj = rpc.DiscordIpcClient.for_platform(client_id)
  15. print("RPC connection successful.")
  16. lastTrack = "none"
  17. time.sleep(5)
  18. start_time = mktime(time.localtime())
  19. while True:
  20. queues = client.queues_list()
  21. last_queue = client.queue(queues[0].id)
  22. last_track_id = last_queue.get_current_track()
  23. last_track = last_track_id.fetch_track()
  24. artists = ', '.join(last_track.artists_name())
  25. title = last_track.title
  26. print(f'AListening to: {artists} - {title}')
  27. if (title != lastTrack):
  28. print("CHANGED")
  29. activity = {
  30. "state": title, # anything you like
  31. "details": f'Listening to {artists} -', # anything you like
  32. "assets": {
  33. "small_text": "Adobe", # anything you like
  34. "small_image": "og-image", # must match the image key
  35. "large_text": "ADOBE", # anything you like
  36. "large_image": "pongnew" # must match the image key
  37. }
  38. }
  39. rpc_obj.set_activity(activity)
  40. lastTrack = title
  41. time.sleep(50)