From 6a68c84033f02fe6c26f3f9d8b0b934b04bdbe36 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Sat, 12 Jul 2025 19:55:49 -0400 Subject: [PATCH 1/7] start adding attribution to sources on details page --- backend/endpoints/responses/platform.py | 13 ++- .../__generated__/models/PlatformSchema.ts | 1 + .../src/components/Details/Info/GameInfo.vue | 95 ++++++++++++++++++- frontend/src/components/Details/Title.vue | 49 ++++++---- .../AppBar/Platform/PlatformInfoDrawer.vue | 30 +++--- 5 files changed, 158 insertions(+), 30 deletions(-) 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/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..4176853c1 100644 --- a/frontend/src/components/Details/Info/GameInfo.vue +++ b/frontend/src/components/Details/Info/GameInfo.vue @@ -12,8 +12,8 @@ import { MdPreview } from "md-editor-v3"; import { get } from "lodash"; // Props -const { t } = useI18n(); defineProps<{ rom: DetailedRom }>(); +const { t } = useI18n(); const { xs } = useDisplay(); const theme = useTheme(); const show = ref(false); @@ -36,6 +36,46 @@ const filters = [ { key: "companies", path: "metadatum.companies", name: t("rom.companies") }, ] as const; +// const metadataSources = computed(() => { +// return [ +// { +// name: "IGDB", +// isMatch: props.rom.igdb_id, +// isCover: props.rom.url_cover?.includes("igdb.com") +// }, +// { +// name: "Hasheous", +// isMatch: props.rom.hasheous_id, +// isCover: false, +// }, +// { +// name: "Screenscraper", +// isMatch: props.rom.ss_id, +// isCover: props.rom.url_cover?.includes("screenscraper.fr") +// }, +// { +// name: "RetroAchievements", +// isMatch: props.rom.ra_id, +// isCover: false, +// }, +// { +// name: "Launchbox", +// isMatch: props.rom.launchbox_id, +// isCover: props.rom.url_cover?.includes("launchbox-app.com") +// }, +// { +// name: "TheGamesDB", +// isMatch: props.rom.tgdb_id, +// isCover: props.rom.url_cover?.includes("thegamesdb.net") +// }, +// { +// name: "SteamGridDB", +// isMatch: props.rom.sgdb_id, +// isCover: props.rom.url_cover?.includes("steamgriddb.com") +// } +// ] +// }); + // Functions function onFilterClick(filter: FilterType, value: string) { router.push({ @@ -245,6 +285,59 @@ function onFilterClick(filter: FilterType, value: string) { + + + Data provided by + IGDB, + + ScreenScraper, + + + MobyGames, + + + LaunchBox, + + + RetroAchievements, + + + Hasheous, + + + 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 }} + + From 145d2459b6d5fc63326310f5e87ecec3cf124be3 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Sat, 12 Jul 2025 20:27:49 -0400 Subject: [PATCH 2/7] finish data attribution --- .../src/components/Details/Info/GameInfo.vue | 164 ++++++++---------- 1 file changed, 73 insertions(+), 91 deletions(-) diff --git a/frontend/src/components/Details/Info/GameInfo.vue b/frontend/src/components/Details/Info/GameInfo.vue index 4176853c1..2b13147ed 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,7 +12,7 @@ import { MdPreview } from "md-editor-v3"; import { get } from "lodash"; // Props -defineProps<{ rom: DetailedRom }>(); +const props = defineProps<{ rom: DetailedRom }>(); const { t } = useI18n(); const { xs } = useDisplay(); const theme = useTheme(); @@ -36,45 +36,54 @@ const filters = [ { key: "companies", path: "metadatum.companies", name: t("rom.companies") }, ] as const; -// const metadataSources = computed(() => { -// return [ -// { -// name: "IGDB", -// isMatch: props.rom.igdb_id, -// isCover: props.rom.url_cover?.includes("igdb.com") -// }, -// { -// name: "Hasheous", -// isMatch: props.rom.hasheous_id, -// isCover: false, -// }, -// { -// name: "Screenscraper", -// isMatch: props.rom.ss_id, -// isCover: props.rom.url_cover?.includes("screenscraper.fr") -// }, -// { -// name: "RetroAchievements", -// isMatch: props.rom.ra_id, -// isCover: false, -// }, -// { -// name: "Launchbox", -// isMatch: props.rom.launchbox_id, -// isCover: props.rom.url_cover?.includes("launchbox-app.com") -// }, -// { -// name: "TheGamesDB", -// isMatch: props.rom.tgdb_id, -// isCover: props.rom.url_cover?.includes("thegamesdb.net") -// }, -// { -// name: "SteamGridDB", -// isMatch: props.rom.sgdb_id, -// isCover: props.rom.url_cover?.includes("steamgriddb.com") -// } -// ] -// }); +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; + + if (props.rom.url_cover.includes("igdb.com")) return "IGDB"; + if (props.rom.url_cover.includes("screenscraper.fr")) return "ScreenScraper"; + if (props.rom.url_cover.includes("mobygames.com")) return "MobyGames"; + if (props.rom.url_cover.includes("launchbox-app.com")) return "LaunchBox"; + if (props.rom.url_cover.includes("retroachievements.org")) + return "RetroAchievements"; + if (props.rom.url_cover.includes("hasheous.org")) return "Hasheous"; + + return null; +}); // Functions function onFilterClick(filter: FilterType, value: string) { @@ -286,56 +295,29 @@ function onFilterClick(filter: FilterType, value: string) { - - Data provided by - IGDB, - - ScreenScraper, - - - MobyGames, - - - LaunchBox, - - - RetroAchievements, - - - Hasheous, - + +
+ Data provided by + . +
+
+ Cover image provided by + + {{ coverImageSource }}. +
From 6fd354609a5d22b6d1bec122478dcd2fc3291ef7 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Sat, 12 Jul 2025 20:32:49 -0400 Subject: [PATCH 3/7] add sgdb --- frontend/src/components/Details/Info/GameInfo.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/components/Details/Info/GameInfo.vue b/frontend/src/components/Details/Info/GameInfo.vue index 2b13147ed..c5ac18a5f 100644 --- a/frontend/src/components/Details/Info/GameInfo.vue +++ b/frontend/src/components/Details/Info/GameInfo.vue @@ -81,6 +81,7 @@ const coverImageSource = computed(() => { if (props.rom.url_cover.includes("retroachievements.org")) return "RetroAchievements"; if (props.rom.url_cover.includes("hasheous.org")) return "Hasheous"; + if (props.rom.url_cover.includes("steamgriddb.com")) return "SteamGridDB"; return null; }); From 8613a9739dde36a3f4068f12a1565d099275757b Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Sat, 12 Jul 2025 20:35:32 -0400 Subject: [PATCH 4/7] add ra and hasheous to is_identified --- backend/models/platform.py | 4 ++++ backend/models/rom.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/backend/models/platform.py b/backend/models/platform.py index 01c185d67..b1d3f4f51 100644 --- a/backend/models/platform.py +++ b/backend/models/platform.py @@ -62,6 +62,8 @@ 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 @@ -75,6 +77,8 @@ class Platform(BaseModel): and bool(self.moby_id) and bool(self.ss_id) and bool(self.launchbox_id) + and bool(self.ra_id) + and bool(self.hasheous_id) ) @cached_property diff --git a/backend/models/rom.py b/backend/models/rom.py index ce6e75e71..2b2bf4956 100644 --- a/backend/models/rom.py +++ b/backend/models/rom.py @@ -327,6 +327,7 @@ class Rom(BaseModel): and not self.ss_id and not self.ra_id and not self.launchbox_id + and not self.hasheous_id ) @property @@ -341,6 +342,7 @@ class Rom(BaseModel): and bool(self.ss_id) and bool(self.ra_id) and bool(self.launchbox_id) + and bool(self.hasheous_id) ) def has_m3u_file(self) -> bool: From c5f3379957339cfc657ecf8ee140f8c03d69710b Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Sat, 12 Jul 2025 20:40:08 -0400 Subject: [PATCH 5/7] remove is_fully_iden --- backend/models/platform.py | 11 ----------- backend/models/rom.py | 11 ----------- 2 files changed, 22 deletions(-) diff --git a/backend/models/platform.py b/backend/models/platform.py index b1d3f4f51..31899fe1a 100644 --- a/backend/models/platform.py +++ b/backend/models/platform.py @@ -70,17 +70,6 @@ class Platform(BaseModel): 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) - and bool(self.ra_id) - and bool(self.hasheous_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 2b2bf4956..7d4d812a6 100644 --- a/backend/models/rom.py +++ b/backend/models/rom.py @@ -334,17 +334,6 @@ class Rom(BaseModel): 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) - and bool(self.hasheous_id) - ) - def has_m3u_file(self) -> bool: """ Check if the ROM has an M3U file associated with it. From 859e29c8c45c3036a9fcaedc29ca43aef9f2eba7 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Sat, 12 Jul 2025 20:46:07 -0400 Subject: [PATCH 6/7] fix codeql issue --- .../src/components/Details/Info/GameInfo.vue | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/Details/Info/GameInfo.vue b/frontend/src/components/Details/Info/GameInfo.vue index c5ac18a5f..83b82d669 100644 --- a/frontend/src/components/Details/Info/GameInfo.vue +++ b/frontend/src/components/Details/Info/GameInfo.vue @@ -74,16 +74,21 @@ const dataSources = computed(() => { const coverImageSource = computed(() => { if (!props.rom.url_cover) return null; - if (props.rom.url_cover.includes("igdb.com")) return "IGDB"; - if (props.rom.url_cover.includes("screenscraper.fr")) return "ScreenScraper"; - if (props.rom.url_cover.includes("mobygames.com")) return "MobyGames"; - if (props.rom.url_cover.includes("launchbox-app.com")) return "LaunchBox"; - if (props.rom.url_cover.includes("retroachievements.org")) - return "RetroAchievements"; - if (props.rom.url_cover.includes("hasheous.org")) return "Hasheous"; - if (props.rom.url_cover.includes("steamgriddb.com")) return "SteamGridDB"; + try { + const hostname = new URL(props.rom.url_cover).hostname; - return null; + if (hostname.includes("igdb.com")) return "IGDB"; + if (hostname.includes("screenscraper.fr")) return "ScreenScraper"; + if (hostname.includes("mobygames.com")) return "MobyGames"; + if (hostname.includes("launchbox-app.com")) return "LaunchBox"; + if (hostname.includes("retroachievements.org")) return "RetroAchievements"; + if (hostname.includes("hasheous.org")) return "Hasheous"; + if (hostname.includes("steamgriddb.com")) return "SteamGridDB"; + + return null; + } catch (error) { + return null; + } }); // Functions From ecb586a35484e85a0be347cb3df4d39e9035dd7c Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Sat, 12 Jul 2025 20:54:20 -0400 Subject: [PATCH 7/7] use exact check to make sql happy --- frontend/src/components/Details/Info/GameInfo.vue | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/Details/Info/GameInfo.vue b/frontend/src/components/Details/Info/GameInfo.vue index 83b82d669..e0b5c1760 100644 --- a/frontend/src/components/Details/Info/GameInfo.vue +++ b/frontend/src/components/Details/Info/GameInfo.vue @@ -77,13 +77,12 @@ const coverImageSource = computed(() => { try { const hostname = new URL(props.rom.url_cover).hostname; - if (hostname.includes("igdb.com")) return "IGDB"; - if (hostname.includes("screenscraper.fr")) return "ScreenScraper"; - if (hostname.includes("mobygames.com")) return "MobyGames"; - if (hostname.includes("launchbox-app.com")) return "LaunchBox"; - if (hostname.includes("retroachievements.org")) return "RetroAchievements"; - if (hostname.includes("hasheous.org")) return "Hasheous"; - if (hostname.includes("steamgriddb.com")) return "SteamGridDB"; + 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) {