validate jellyfin image url

This commit is contained in:
2025-12-10 04:10:06 +01:00
parent eb69650423
commit d4febbc3b2
3 changed files with 7 additions and 5 deletions

View File

@@ -8,3 +8,4 @@
- Handle paused state correctly by checking the `PlayState` property from Jellyfin and updating Discord Rich Presence accordingly - Handle paused state correctly by checking the `PlayState` property from Jellyfin and updating Discord Rich Presence accordingly
- Set the `auth.ssl` configuration option in Jellyfin Client dynamically based on the `jellyfin_server_url` - Set the `auth.ssl` configuration option in Jellyfin Client dynamically based on the `jellyfin_server_url`
- Removed `to_rpc_payload` function in favor of a class method within the `JellyfinMediaItem` class for better encapsulation and organization of code - Removed `to_rpc_payload` function in favor of a class method within the `JellyfinMediaItem` class for better encapsulation and organization of code
- Added major improvements to typing and type hints throughout the codebase for better code clarity and maintainability

View File

@@ -28,6 +28,7 @@ class DiscordRPC:
payload (DiscordRPCUpdatePayload): The payload containing presence information. payload (DiscordRPCUpdatePayload): The payload containing presence information.
""" """
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,
details=payload.title, details=payload.title,

View File

@@ -1,4 +1,4 @@
from pydantic import BaseModel from pydantic import BaseModel, HttpUrl
from enum import StrEnum from enum import StrEnum
from typing import Optional, Union from typing import Optional, Union
from discord.models import DiscordRPCUpdatePayload from discord.models import DiscordRPCUpdatePayload
@@ -28,7 +28,7 @@ class JellyfinMediaItem(BaseModel):
id: str id: str
name: str name: str
type: JellyfinMediaType type: JellyfinMediaType
image_url: str image_url: HttpUrl
start: Optional[int] start: Optional[int]
end: Optional[int] end: Optional[int]
metadata: Union[JellyfinMusicMediaMetadata, metadata: Union[JellyfinMusicMediaMetadata,
@@ -49,7 +49,7 @@ class JellyfinMediaItem(BaseModel):
self.name}", self.name}",
subtitle=f"by { subtitle=f"by {
self.metadata.artist}", self.metadata.artist}",
image_url=self.image_url, image_url=str(self.image_url),
details=self.metadata.album, details=self.metadata.album,
activity_type=ActivityType.LISTENING, activity_type=ActivityType.LISTENING,
start=self.start, start=self.start,
@@ -59,7 +59,7 @@ class JellyfinMediaItem(BaseModel):
id=self.id, id=self.id,
title=f"Watching {self.name}", title=f"Watching {self.name}",
subtitle=self.metadata.date, subtitle=self.metadata.date,
image_url=self.image_url, image_url=str(self.image_url),
details=self.name, details=self.name,
activity_type=ActivityType.WATCHING, activity_type=ActivityType.WATCHING,
start=self.start, start=self.start,
@@ -70,7 +70,7 @@ class JellyfinMediaItem(BaseModel):
id=self.id, id=self.id,
title=f"Watching {self.name}", title=f"Watching {self.name}",
subtitle=self.metadata.subtitle, subtitle=self.metadata.subtitle,
image_url=self.image_url, image_url=str(self.image_url),
details=self.name, details=self.name,
activity_type=ActivityType.WATCHING, activity_type=ActivityType.WATCHING,
start=self.start, start=self.start,