add discord part

This commit is contained in:
2025-12-09 20:26:36 +01:00
parent 81a3981d18
commit fc013af993
2 changed files with 31 additions and 2 deletions

9
discord.py Normal file
View File

@@ -0,0 +1,9 @@
from pypresence import Presence
import os
def get_rpc():
app_id = os.getenv('DISCORD_APP_ID')
RPC = Presence(app_id)
RPC.connect()
return RPC

22
main.py
View File

@@ -1,9 +1,29 @@
from dotenv import load_dotenv
from jellyfin import get_client, get_active_media
from discord import get_rpc
import time
load_dotenv()
rpc = get_rpc()
client = get_client()
while True:
media_list = get_active_media(client)
print(media_list)
if len(media_list) == 0:
print("No active media found.")
continue
media = media_list[0]
print(f"Updating Discord RPC: Listening to {media['title']} by {media['artist']}")
rpc.update(
state=f"by {media['artist']}",
details=f"Listening to {media['title']}",
large_image=media['image'],
large_text=media['title'],
)
time.sleep(15)