diff --git a/changelog/0.1.1.md b/changelog/0.1.1.md index e8b40a8..c35a3dc 100644 --- a/changelog/0.1.1.md +++ b/changelog/0.1.1.md @@ -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 diff --git a/discord/models.py b/discord/models.py index ae0eebe..f611692 100644 --- a/discord/models.py +++ b/discord/models.py @@ -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 diff --git a/jellyfin/api_client.py b/jellyfin/api_client.py index f6f32f8..8d724d4 100644 --- a/jellyfin/api_client.py +++ b/jellyfin/api_client.py @@ -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 diff --git a/jellyfin/models.py b/jellyfin/models.py index 24480a0..1229ce1 100644 --- a/jellyfin/models.py +++ b/jellyfin/models.py @@ -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