Compare commits
2 Commits
ede88e55a9
...
d0fcb3e57c
| Author | SHA1 | Date | |
|---|---|---|---|
|
d0fcb3e57c
|
|||
|
4d76ef02d9
|
@@ -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
|
- 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 `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
|
- 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
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ class DiscordRPCUpdatePayload(BaseModel):
|
|||||||
subtitle: str
|
subtitle: str
|
||||||
image_url: str
|
image_url: str
|
||||||
details: str
|
details: str
|
||||||
start: int
|
start: int | None
|
||||||
end: int
|
end: int | None
|
||||||
activity_type: ActivityType
|
activity_type: ActivityType
|
||||||
|
|||||||
@@ -9,16 +9,11 @@ class DiscordRPC:
|
|||||||
self.logger = logging.getLogger('DiscordRPC')
|
self.logger = logging.getLogger('DiscordRPC')
|
||||||
|
|
||||||
self.logger.info("Connecting to Discord RPC...")
|
self.logger.info("Connecting to Discord RPC...")
|
||||||
self.last_update_id = None
|
|
||||||
self.rpc = Presence(settings.discord_app_id)
|
self.rpc = Presence(settings.discord_app_id)
|
||||||
self.rpc.connect()
|
self.rpc.connect()
|
||||||
self.logger.info("Connected to Discord RPC.")
|
self.logger.info("Connected to Discord RPC.")
|
||||||
|
|
||||||
def update(self, payload: DiscordRPCUpdatePayload):
|
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.logger.info("Updating Discord RPC presence...")
|
||||||
self.rpc.update(
|
self.rpc.update(
|
||||||
activity_type=payload.activity_type,
|
activity_type=payload.activity_type,
|
||||||
@@ -29,7 +24,6 @@ class DiscordRPC:
|
|||||||
start=payload.start,
|
start=payload.start,
|
||||||
end=payload.end
|
end=payload.end
|
||||||
)
|
)
|
||||||
self.last_update_id = payload.id
|
|
||||||
self.logger.info("Discord RPC presence updated.")
|
self.logger.info("Discord RPC presence updated.")
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ class JellyfinApiClient:
|
|||||||
|
|
||||||
def get_playback_info(self, media: dict) -> tuple[int, int]:
|
def get_playback_info(self, media: dict) -> tuple[int, int]:
|
||||||
play_state = media.get('PlayState')
|
play_state = media.get('PlayState')
|
||||||
|
is_paused = play_state.get('IsPaused')
|
||||||
|
|
||||||
|
if is_paused:
|
||||||
|
return (None, None)
|
||||||
|
|
||||||
runtime_ticks = media.get('RunTimeTicks')
|
runtime_ticks = media.get('RunTimeTicks')
|
||||||
total_runtime_seconds = runtime_ticks // 10_000_000
|
total_runtime_seconds = runtime_ticks // 10_000_000
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ class JellyfinMediaItem(BaseModel):
|
|||||||
name: str
|
name: str
|
||||||
type: JellyfinMediaType
|
type: JellyfinMediaType
|
||||||
image_url: str
|
image_url: str
|
||||||
start: int
|
start: int | None
|
||||||
end: int
|
end: int | None
|
||||||
metadata: dict
|
metadata: dict
|
||||||
|
|||||||
Reference in New Issue
Block a user