diff --git a/backend/endpoints/responses/platform.py b/backend/endpoints/responses/platform.py index 5984028c6..d5267f504 100644 --- a/backend/endpoints/responses/platform.py +++ b/backend/endpoints/responses/platform.py @@ -1,5 +1,6 @@ from datetime import datetime +from handler.metadata.moby_handler import MOBYGAMES_PLATFORM_LIST from models.platform import DEFAULT_COVER_ASPECT_RATIO from pydantic import Field, computed_field, field_validator @@ -36,7 +37,6 @@ class PlatformSchema(BaseModel): fs_size_bytes: int is_unidentified: bool is_identified: bool - missing_from_fs: bool class Config: @@ -50,3 +50,14 @@ class PlatformSchema(BaseModel): @field_validator("firmware") def sort_files(cls, v: list[FirmwareSchema]) -> list[FirmwareSchema]: return sorted(v, key=lambda x: x.file_name) + + @computed_field # type: ignore + @property + def moby_slug(self) -> str | None: + if not self.moby_id: + return None + + if self.slug not in MOBYGAMES_PLATFORM_LIST: + return None + + return MOBYGAMES_PLATFORM_LIST[self.slug].get("slug", None) diff --git a/backend/models/platform.py b/backend/models/platform.py index 01c185d67..31899fe1a 100644 --- a/backend/models/platform.py +++ b/backend/models/platform.py @@ -62,21 +62,14 @@ class Platform(BaseModel): and not self.moby_id and not self.ss_id and not self.launchbox_id + and not self.ra_id + and not self.hasheous_id ) @property def is_identified(self) -> bool: return not self.is_unidentified - @property - def is_fully_identified(self) -> bool: - return ( - bool(self.igdb_id) - and bool(self.moby_id) - and bool(self.ss_id) - and bool(self.launchbox_id) - ) - @cached_property def fs_size_bytes(self) -> int: from handler.database import db_stats_handler diff --git a/backend/models/rom.py b/backend/models/rom.py index ce6e75e71..7d4d812a6 100644 --- a/backend/models/rom.py +++ b/backend/models/rom.py @@ -327,22 +327,13 @@ class Rom(BaseModel): and not self.ss_id and not self.ra_id and not self.launchbox_id + and not self.hasheous_id ) @property def is_identified(self) -> bool: return not self.is_unidentified - @property - def is_fully_identified(self) -> bool: - return ( - bool(self.igdb_id) - and bool(self.moby_id) - and bool(self.ss_id) - and bool(self.ra_id) - and bool(self.launchbox_id) - ) - def has_m3u_file(self) -> bool: """ Check if the ROM has an M3U file associated with it. diff --git a/frontend/src/__generated__/models/PlatformSchema.ts b/frontend/src/__generated__/models/PlatformSchema.ts index 7ec0e9e95..90cbe3415 100644 --- a/frontend/src/__generated__/models/PlatformSchema.ts +++ b/frontend/src/__generated__/models/PlatformSchema.ts @@ -13,6 +13,7 @@ export type PlatformSchema = { igdb_id?: (number | null); sgdb_id?: (number | null); moby_id?: (number | null); + moby_slug?: (string | null); launchbox_id?: (number | null); ss_id?: (number | null); ra_id?: (number | null); diff --git a/frontend/src/components/Details/Info/GameInfo.vue b/frontend/src/components/Details/Info/GameInfo.vue index e70d44fba..e0b5c1760 100644 --- a/frontend/src/components/Details/Info/GameInfo.vue +++ b/frontend/src/components/Details/Info/GameInfo.vue @@ -4,7 +4,7 @@ import RDialog from "@/components/common/RDialog.vue"; import RAvatar from "@/components/common/Collection/RAvatar.vue"; import type { DetailedRom } from "@/stores/roms"; import { ROUTES } from "@/plugins/router"; -import { ref } from "vue"; +import { computed, ref } from "vue"; import { useRouter } from "vue-router"; import { useDisplay, useTheme } from "vuetify"; import { useI18n } from "vue-i18n"; @@ -12,8 +12,8 @@ import { MdPreview } from "md-editor-v3"; import { get } from "lodash"; // Props +const props = defineProps<{ rom: DetailedRom }>(); const { t } = useI18n(); -defineProps<{ rom: DetailedRom }>(); const { xs } = useDisplay(); const theme = useTheme(); const show = ref(false); @@ -36,6 +36,60 @@ const filters = [ { key: "companies", path: "metadatum.companies", name: t("rom.companies") }, ] as const; +const dataSources = computed(() => { + return [ + { + name: "IGDB", + condition: props.rom.igdb_id, + url: `https://www.igdb.com/games/${props.rom.slug}`, + }, + { + name: "ScreenScraper", + condition: props.rom.ss_id, + url: `https://www.screenscraper.fr/gameinfos.php?gameid=${props.rom.ss_id}`, + }, + { + name: "MobyGames", + condition: props.rom.moby_id, + url: `https://www.mobygames.com/game/${props.rom.moby_id}`, + }, + { + name: "LaunchBox", + condition: props.rom.launchbox_id, + url: `https://gamesdb.launchbox-app.com/games/details/${props.rom.launchbox_id}`, + }, + { + name: "RetroAchievements", + condition: props.rom.ra_id, + url: `https://retroachievements.org/game/${props.rom.ra_id}`, + }, + { + name: "Hasheous", + condition: props.rom.hasheous_id, + url: `https://hasheous.org/index.html?page=dataobjectdetail&type=game&id=${props.rom.hasheous_id}`, + }, + ].filter((source) => source.condition); +}); + +const coverImageSource = computed(() => { + if (!props.rom.url_cover) return null; + + try { + const hostname = new URL(props.rom.url_cover).hostname; + + if (hostname == "images.igdb.com") return "IGDB"; + if (hostname == "screenscraper.fr") return "ScreenScraper"; + if (hostname == "cdn.mobygames.com") return "MobyGames"; + if (hostname == "images.launchbox-app.com") return "LaunchBox"; + if (hostname == "media.retroachievements.org") return "RetroAchievements"; + if (hostname == "cdn2.steamgriddb.com") return "SteamGridDB"; + + return null; + } catch (error) { + return null; + } +}); + // Functions function onFilterClick(filter: FilterType, value: string) { router.push({ @@ -245,6 +299,32 @@ function onFilterClick(filter: FilterType, value: string) { + + +
+ Data provided by + . +
+
+ Cover image provided by + + {{ coverImageSource }}. +
+
+
diff --git a/frontend/src/components/Details/Title.vue b/frontend/src/components/Details/Title.vue index 3c77ab445..c64b242a1 100644 --- a/frontend/src/components/Details/Title.vue +++ b/frontend/src/components/Details/Title.vue @@ -188,22 +188,30 @@ const hashMatches = computed(() => { mdi-star - - - - - {{ rom.launchbox_id }} - - {{ - rom.launchbox_metadata?.community_rating?.toFixed(2) - }} - mdi-star - + + + + + {{ rom.launchbox_id }} + + {{ + rom.launchbox_metadata?.community_rating?.toFixed(2) + }} + mdi-star + + { {{ rom.ra_id }} - - + + {{ rom.hasheous_id }} - + @@ -379,17 +383,21 @@ watch( {{ currentPlatform.launchbox_id }} - - - - - {{ currentPlatform.hasheous_id }} - + + + + + {{ currentPlatform.hasheous_id }} + +