Compare commits

...

2 Commits

Author SHA1 Message Date
d0fcb3e57c handle paused state 2025-12-10 03:32:10 +01:00
4d76ef02d9 remove rich presence caching 2025-12-10 03:28:03 +01:00
5 changed files with 10 additions and 10 deletions

View File

@@ -4,3 +4,5 @@
- Updated Jellyfin image fetching logic to use `ParentId` for episodes and music tracks to ensure correct artwork is displayed in Discord Rich Presence
- Added `coloredlogs` dependency for improved logging output
- Added a formatting script (`scripts/format.sh`) that uses `autopep8` to automatically format the codebase for better readability and consistency
- Removed caching of last fetched items to ensure the most up-to-date information is always displayed in Discord Rich Presence
- Handle paused state correctly by checking the `PlayState` property from Jellyfin and updating Discord Rich Presence accordingly

View File

@@ -8,6 +8,6 @@ class DiscordRPCUpdatePayload(BaseModel):
subtitle: str
image_url: str
details: str
start: int
end: int
start: int | None
end: int | None
activity_type: ActivityType

View File

@@ -9,16 +9,11 @@ class DiscordRPC:
self.logger = logging.getLogger('DiscordRPC')
self.logger.info("Connecting to Discord RPC...")
self.last_update_id = None
self.rpc = Presence(settings.discord_app_id)
self.rpc.connect()
self.logger.info("Connected to Discord RPC.")
def update(self, payload: DiscordRPCUpdatePayload):
if self.last_update_id == payload.id:
self.logger.debug("No update needed for Discord RPC presence.")
return
self.logger.info("Updating Discord RPC presence...")
self.rpc.update(
activity_type=payload.activity_type,
@@ -29,7 +24,6 @@ class DiscordRPC:
start=payload.start,
end=payload.end
)
self.last_update_id = payload.id
self.logger.info("Discord RPC presence updated.")
def clear(self):

View File

@@ -75,6 +75,10 @@ class JellyfinApiClient:
def get_playback_info(self, media: dict) -> tuple[int, int]:
play_state = media.get('PlayState')
is_paused = play_state.get('IsPaused')
if is_paused:
return (None, None)
runtime_ticks = media.get('RunTimeTicks')
total_runtime_seconds = runtime_ticks // 10_000_000

View File

@@ -13,6 +13,6 @@ class JellyfinMediaItem(BaseModel):
name: str
type: JellyfinMediaType
image_url: str
start: int
end: int
start: int | None
end: int | None
metadata: dict