add discord part
This commit is contained in:
9
discord.py
Normal file
9
discord.py
Normal 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
22
main.py
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user