import asyncio import json import os import plexapi.myplex import struct import subprocess import sys import tempfile import threading import time isLinux = sys.platform in ["linux", "darwin"] os.system("clear" if isLinux else "cls") class plexConfig: plexServerName = "" plexUsername = "" plexPasswordOrToken = "" usingToken = False listenForUser = "" class discordRichPresence: def __init__(self, clientID): self.IPCPipe = ((os.environ.get("XDG_RUNTIME_DIR", None) or os.environ.get("TMPDIR", None) or os.environ.get("TMP", None) or os.environ.get("TEMP", None) or "/tmp") + "/discord-ipc-0") if isLinux else "\\\\?\\pipe\\discord-ipc-0" self.clientID = clientID self.pipeReader = None self.pipeWriter = None self.process = None self.running = False self.resetNext = False async def read(self): try: print("\nReading:") data = await self.pipeReader.read(1024) print(json.loads(data[8:].decode("utf-8"))) except Exception as e: print("Error: " + str(e)) self.resetNext = True def write(self, op, payload): print("\nWriting:") payload = json.dumps(payload) print(payload) data = self.pipeWriter.write(struct.pack("