Add property for path_video and refactor places which use similar logic to access video paths

This commit is contained in:
Jamie Bond
2026-03-10 20:32:54 +01:00
parent 332fca94c1
commit 1e6f0d6000
5 changed files with 19 additions and 19 deletions

View File

@@ -262,6 +262,8 @@ class RomSchema(BaseModel):
path_manual: str | None
url_manual: str | None
path_video: str | None
is_identifying: bool = False
is_unidentified: bool
is_identified: bool

View File

@@ -347,6 +347,15 @@ class Rom(BaseModel):
else ""
)
@property
def path_video(self) -> str | None:
return (
(self.ss_metadata or {}).get("video_path")
or (self.ss_metadata or {}).get("video_normalized_path")
or (self.gamelist_metadata or {}).get("video_path")
or None
)
@property
def is_unidentified(self) -> bool:
return (

View File

@@ -56,11 +56,10 @@ class GamelistExporter:
f"{FRONTEND_RESOURCES_PATH}/{rom.path_cover_l}"
)
video_path = (rom.ss_metadata or {}).get("video_path") or (
rom.gamelist_metadata or {}
).get("video_path")
if video_path:
SubElement(game, "video").text = f"{FRONTEND_RESOURCES_PATH}/{video_path}"
if path_video := rom.path_video:
SubElement(game, "video").text = (
f"{FRONTEND_RESOURCES_PATH}/{path_video}"
)
elif rom.youtube_video_id:
SubElement(game, "video").text = (
f"{YOUTUBE_BASE_URL}/embed/{rom.youtube_video_id}"

View File

@@ -23,13 +23,6 @@ const youtubeVideoId = computed(
props.rom.manual_metadata?.youtube_video_id || props.rom.youtube_video_id,
);
const localVideoPath = computed(() => {
return (
props.rom.ss_metadata?.video_path ||
props.rom.ss_metadata?.video_normalized_path ||
props.rom.gamelist_metadata?.video_path
);
});
const screenshots = computed(() => props.rom.merged_screenshots);
const mediaPaths = computed(() => {
const ss = props.rom.ss_metadata;
@@ -103,12 +96,12 @@ const carouselHeight = computed(() => {
/>
</v-carousel-item>
<v-carousel-item
v-if="localVideoPath"
:key="localVideoPath"
v-if="rom.path_video"
:key="rom.path_video"
content-class="d-flex justify-center align-center"
>
<video
:src="`${FRONTEND_RESOURCES_PATH}/${localVideoPath}`"
:src="`${FRONTEND_RESOURCES_PATH}/${rom.path_video}`"
class="h-full object-contain"
controls
/>

View File

@@ -196,10 +196,7 @@ export function useGameAnimation({
if (!romsStore.isSimpleRom(rom)) return null;
// Only play video if boxart style is miximage
if (boxartStyle.value !== "miximage_path") return null;
const ssVideo =
rom.ss_metadata?.video_path || rom.ss_metadata?.video_normalized_path;
const gamelistVideo = rom.gamelist_metadata?.video_path;
return ssVideo || gamelistVideo || null;
return rom.path_video ?? null;
});
const playVideoEnabled = computed(() => {