handle paused state

This commit is contained in:
2025-12-10 03:32:10 +01:00
parent 4d76ef02d9
commit d0fcb3e57c
4 changed files with 9 additions and 4 deletions

View File

@@ -5,3 +5,4 @@
- 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

@@ -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