mirror of
https://github.com/rommapp/romm.git
synced 2026-02-18 23:42:07 +01:00
[ROMM-2554] Remove htlb from manual search
This commit is contained in:
@@ -11,7 +11,6 @@ class SearchRomSchema(BaseModel):
|
||||
sgdb_id: int | None = None
|
||||
flashpoint_id: str | None = None
|
||||
launchbox_id: int | None = None
|
||||
hltb_id: int | None = None
|
||||
platform_id: int
|
||||
name: str
|
||||
slug: str = ""
|
||||
@@ -22,7 +21,6 @@ class SearchRomSchema(BaseModel):
|
||||
sgdb_url_cover: str = ""
|
||||
flashpoint_url_cover: str = ""
|
||||
launchbox_url_cover: str = ""
|
||||
hltb_url_cover: str = ""
|
||||
is_unidentified: bool
|
||||
is_identified: bool
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ from handler.filesystem import fs_resource_handler, fs_rom_handler
|
||||
from handler.filesystem.base_handler import CoverSize
|
||||
from handler.metadata import (
|
||||
meta_flashpoint_handler,
|
||||
meta_hltb_handler,
|
||||
meta_igdb_handler,
|
||||
meta_launchbox_handler,
|
||||
meta_moby_handler,
|
||||
@@ -739,16 +738,8 @@ async def update_rom(
|
||||
"ss_id": data.get("ss_id", rom.ss_id),
|
||||
"launchbox_id": data.get("launchbox_id", rom.launchbox_id),
|
||||
"flashpoint_id": data.get("flashpoint_id", rom.flashpoint_id),
|
||||
"hltb_id": data.get("hltb_id", rom.hltb_id),
|
||||
}
|
||||
|
||||
if (
|
||||
cleaned_data.get("hltb_id", "")
|
||||
and int(cleaned_data.get("hltb_id", "")) != rom.hltb_id
|
||||
):
|
||||
hltb_rom = await meta_hltb_handler.get_rom_by_id(cleaned_data["hltb_id"])
|
||||
cleaned_data.update(hltb_rom)
|
||||
|
||||
if (
|
||||
cleaned_data.get("flashpoint_id", "")
|
||||
and cleaned_data.get("flashpoint_id", "") != rom.flashpoint_id
|
||||
|
||||
@@ -9,7 +9,6 @@ from handler.auth.constants import Scope
|
||||
from handler.database import db_rom_handler
|
||||
from handler.metadata import (
|
||||
meta_flashpoint_handler,
|
||||
meta_hltb_handler,
|
||||
meta_igdb_handler,
|
||||
meta_launchbox_handler,
|
||||
meta_moby_handler,
|
||||
@@ -17,7 +16,6 @@ from handler.metadata import (
|
||||
meta_ss_handler,
|
||||
)
|
||||
from handler.metadata.flashpoint_handler import FlashpointRom
|
||||
from handler.metadata.hltb_handler import HLTBRom
|
||||
from handler.metadata.igdb_handler import IGDBRom
|
||||
from handler.metadata.launchbox_handler import LaunchboxRom
|
||||
from handler.metadata.moby_handler import MobyGamesRom
|
||||
@@ -63,7 +61,6 @@ async def search_rom(
|
||||
and not meta_moby_handler.is_enabled()
|
||||
and not meta_flashpoint_handler.is_enabled()
|
||||
and not meta_launchbox_handler.is_enabled()
|
||||
and not meta_hltb_handler.is_enabled()
|
||||
):
|
||||
log.error("Search error: No metadata providers enabled")
|
||||
raise HTTPException(
|
||||
@@ -94,7 +91,6 @@ async def search_rom(
|
||||
ss_matched_roms: list[SSRom] = []
|
||||
flashpoint_matched_roms: list[FlashpointRom] = []
|
||||
launchbox_matched_roms: list[LaunchboxRom] = []
|
||||
hltb_matched_roms: list[HLTBRom] = []
|
||||
|
||||
if search_by.lower() == "id":
|
||||
try:
|
||||
@@ -120,7 +116,6 @@ async def search_rom(
|
||||
ss_matched_roms,
|
||||
flashpoint_matched_roms,
|
||||
launchbox_matched_roms,
|
||||
hltb_matched_roms,
|
||||
) = await asyncio.gather(
|
||||
meta_igdb_handler.get_matched_roms_by_name(
|
||||
search_term, get_main_platform_igdb_id(rom.platform)
|
||||
@@ -135,7 +130,6 @@ async def search_rom(
|
||||
meta_launchbox_handler.get_matched_roms_by_name(
|
||||
search_term, rom.platform.slug
|
||||
),
|
||||
meta_hltb_handler.get_matched_roms_by_name(search_term, rom.platform.slug),
|
||||
)
|
||||
|
||||
merged_dict: dict[str, dict] = {}
|
||||
@@ -215,21 +209,6 @@ async def search_rom(
|
||||
**merged_dict.get(launchbox_name, {}),
|
||||
}
|
||||
|
||||
for hltb_rom in hltb_matched_roms:
|
||||
if hltb_rom["hltb_id"]:
|
||||
hltb_name = meta_hltb_handler.normalize_search_term(
|
||||
hltb_rom.get("name", ""),
|
||||
remove_articles=False,
|
||||
)
|
||||
merged_dict[hltb_name] = {
|
||||
**hltb_rom,
|
||||
"is_identified": True,
|
||||
"is_unidentified": False,
|
||||
"platform_id": rom.platform_id,
|
||||
"hltb_url_cover": hltb_rom.pop("url_cover", ""),
|
||||
**merged_dict.get(hltb_name, {}),
|
||||
}
|
||||
|
||||
async def get_sgdb_rom(name: str) -> tuple[str, SGDBRom]:
|
||||
return name, await meta_sgdb_handler.get_details_by_names([name])
|
||||
|
||||
|
||||
@@ -212,14 +212,6 @@ class HowLongToBeatHandler(MetadataHandler):
|
||||
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def extract_hltb_id_from_filename(fs_name: str) -> int | None:
|
||||
"""Extract HLTB ID from filename tag like (hltb-12345)."""
|
||||
match = HLTB_TAG_REGEX.search(fs_name)
|
||||
if match:
|
||||
return int(match.group(1))
|
||||
return None
|
||||
|
||||
async def _request(self, url: str, payload: dict) -> dict:
|
||||
"""
|
||||
Sends a POST request to HowLongToBeat API.
|
||||
@@ -386,21 +378,6 @@ class HowLongToBeatHandler(MetadataHandler):
|
||||
if not HLTB_API_ENABLED:
|
||||
return HLTBRom(hltb_id=None)
|
||||
|
||||
# Check for HLTB ID tag in filename first
|
||||
hltb_id_from_tag = self.extract_hltb_id_from_filename(fs_name)
|
||||
if hltb_id_from_tag:
|
||||
log.debug(f"Found HLTB ID tag in filename: {hltb_id_from_tag}")
|
||||
rom_by_id = await self.get_rom_by_id(hltb_id_from_tag)
|
||||
if rom_by_id["hltb_id"]:
|
||||
log.debug(
|
||||
f"Successfully matched ROM by HLTB ID tag: {fs_name} -> {hltb_id_from_tag}"
|
||||
)
|
||||
return rom_by_id
|
||||
else:
|
||||
log.warning(
|
||||
f"HLTB ID tag found but no match: {fs_name} -> {hltb_id_from_tag}"
|
||||
)
|
||||
|
||||
# We replace " - " with ": " to match HowLongToBeat's naming convention
|
||||
search_term = fs_rom_handler.get_file_name_with_no_tags(fs_name).replace(
|
||||
" - ", ": "
|
||||
@@ -493,29 +470,6 @@ class HowLongToBeatHandler(MetadataHandler):
|
||||
|
||||
return roms
|
||||
|
||||
async def get_rom_by_id(self, hltb_id: int) -> HLTBRom:
|
||||
"""
|
||||
Get ROM information by HowLongToBeat ID.
|
||||
Note: HLTB doesn't have a direct "get by ID" endpoint,
|
||||
so this method searches by the game name if we can find it.
|
||||
|
||||
:param hltb_id: The HowLongToBeat game ID.
|
||||
:return: A HLTBRom object.
|
||||
"""
|
||||
if not HLTB_API_ENABLED:
|
||||
return HLTBRom(hltb_id=None)
|
||||
|
||||
if not hltb_id:
|
||||
return HLTBRom(hltb_id=None)
|
||||
|
||||
# Unfortunately, HLTB doesn't provide a direct "get by ID" endpoint
|
||||
# This is a limitation of their API - we would need to search and filter
|
||||
# In practice, this method might not be very useful for HLTB
|
||||
log.debug(
|
||||
f"get_rom_by_id not fully supported for HowLongToBeat (ID: {hltb_id})"
|
||||
)
|
||||
return HLTBRom(hltb_id=hltb_id)
|
||||
|
||||
async def price_check(
|
||||
self, hltb_id: int, steam_id: int = 0, itch_id: int = 0
|
||||
) -> HLTBPriceCheckResponse | None:
|
||||
|
||||
@@ -10,7 +10,6 @@ export type SearchRomSchema = {
|
||||
sgdb_id?: (number | null);
|
||||
flashpoint_id?: (string | null);
|
||||
launchbox_id?: (number | null);
|
||||
hltb_id?: (number | null);
|
||||
platform_id: number;
|
||||
name: string;
|
||||
slug?: string;
|
||||
@@ -21,7 +20,6 @@ export type SearchRomSchema = {
|
||||
sgdb_url_cover?: string;
|
||||
flashpoint_url_cover?: string;
|
||||
launchbox_url_cover?: string;
|
||||
hltb_url_cover?: string;
|
||||
is_unidentified: boolean;
|
||||
is_identified: boolean;
|
||||
};
|
||||
|
||||
@@ -154,8 +154,7 @@ const largeCover = computed(() => {
|
||||
props.rom.moby_url_cover ||
|
||||
props.rom.ss_url_cover ||
|
||||
props.rom.launchbox_url_cover ||
|
||||
props.rom.flashpoint_url_cover ||
|
||||
props.rom.hltb_url_cover
|
||||
props.rom.flashpoint_url_cover
|
||||
);
|
||||
const pathCoverLarge = isWebpEnabled.value
|
||||
? props.rom.path_cover_large?.replace(EXTENSION_REGEX, ".webp")
|
||||
@@ -270,8 +269,7 @@ onBeforeUnmount(() => {
|
||||
!rom.ss_url_cover &&
|
||||
!rom.sgdb_url_cover &&
|
||||
!rom.launchbox_url_cover &&
|
||||
!rom.flashpoint_url_cover &&
|
||||
!rom.hltb_url_cover)
|
||||
!rom.flashpoint_url_cover)
|
||||
"
|
||||
class="translucent text-white"
|
||||
:class="
|
||||
|
||||
@@ -101,24 +101,5 @@ defineProps<{ rom: SearchRomSchema }>();
|
||||
</v-avatar>
|
||||
</template>
|
||||
</v-tooltip>
|
||||
<v-tooltip
|
||||
location="top"
|
||||
class="tooltip"
|
||||
transition="fade-transition"
|
||||
text="HowLongToBeat matched"
|
||||
open-delay="500"
|
||||
>
|
||||
<template #activator="{ props }">
|
||||
<v-avatar
|
||||
v-bind="props"
|
||||
v-if="rom.hltb_id"
|
||||
class="mr-1 mb-1"
|
||||
size="28"
|
||||
rounded="1"
|
||||
>
|
||||
<v-img src="/assets/scrappers/hltb.png" />
|
||||
</v-avatar>
|
||||
</template>
|
||||
</v-tooltip>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
@@ -25,7 +25,6 @@ type MatchedSource = {
|
||||
| "Screenscraper"
|
||||
| "Flashpoint"
|
||||
| "Launchbox"
|
||||
| "HowLongToBeat"
|
||||
| "SteamGridDB";
|
||||
logo_path: string;
|
||||
};
|
||||
@@ -56,7 +55,6 @@ const isMobyFiltered = ref(true);
|
||||
const isSSFiltered = ref(true);
|
||||
const isFlashpointFiltered = ref(true);
|
||||
const isLaunchboxFiltered = ref(true);
|
||||
const isHLTBFiltered = ref(true);
|
||||
const computedAspectRatio = computed(() => {
|
||||
const ratio =
|
||||
platfotmsStore.getAspectRatio(rom.value?.platform_id ?? -1) ||
|
||||
@@ -101,20 +99,15 @@ function toggleSourceFilter(source: MatchedSource["name"]) {
|
||||
heartbeat.value.METADATA_SOURCES.LAUNCHBOX_API_ENABLED
|
||||
) {
|
||||
isLaunchboxFiltered.value = !isLaunchboxFiltered.value;
|
||||
} else if (
|
||||
source == "HowLongToBeat" &&
|
||||
heartbeat.value.METADATA_SOURCES.HLTB_API_ENABLED
|
||||
) {
|
||||
isHLTBFiltered.value = !isHLTBFiltered.value;
|
||||
}
|
||||
|
||||
filteredMatchedRoms.value = matchedRoms.value.filter((rom) => {
|
||||
if (
|
||||
(rom.igdb_id && isIGDBFiltered.value) ||
|
||||
(rom.moby_id && isMobyFiltered.value) ||
|
||||
(rom.ss_id && isSSFiltered.value) ||
|
||||
(rom.flashpoint_id && isFlashpointFiltered.value) ||
|
||||
(rom.launchbox_id && isLaunchboxFiltered.value) ||
|
||||
(rom.hltb_id && isHLTBFiltered.value)
|
||||
(rom.launchbox_id && isLaunchboxFiltered.value)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
@@ -146,8 +139,7 @@ async function searchRom() {
|
||||
(rom.moby_id && isMobyFiltered.value) ||
|
||||
(rom.ss_id && isSSFiltered.value) ||
|
||||
(rom.flashpoint_id && isFlashpointFiltered.value) ||
|
||||
(rom.launchbox_id && isLaunchboxFiltered.value) ||
|
||||
(rom.hltb_id && isHLTBFiltered.value)
|
||||
(rom.launchbox_id && isLaunchboxFiltered.value)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
@@ -219,13 +211,6 @@ function showSources(matchedRom: SearchRomSchema) {
|
||||
logo_path: "/assets/scrappers/launchbox.png",
|
||||
});
|
||||
}
|
||||
if (matchedRom.hltb_url_cover) {
|
||||
sources.value.push({
|
||||
url_cover: matchedRom.hltb_url_cover,
|
||||
name: "HowLongToBeat",
|
||||
logo_path: "/assets/scrappers/hltb.png",
|
||||
});
|
||||
}
|
||||
if (sources.value.length == 1) {
|
||||
selectedCover.value = sources.value[0];
|
||||
}
|
||||
@@ -277,7 +262,6 @@ async function updateRom(
|
||||
moby_id: selectedRom.moby_id || null,
|
||||
flashpoint_id: selectedRom.flashpoint_id || null,
|
||||
launchbox_id: selectedRom.launchbox_id || null,
|
||||
hltb_id: selectedRom.hltb_id || null,
|
||||
name: selectedRom.name || null,
|
||||
slug: selectedRom.slug || null,
|
||||
summary: selectedRom.summary || null,
|
||||
@@ -288,7 +272,6 @@ async function updateRom(
|
||||
selectedRom.moby_url_cover ||
|
||||
selectedRom.flashpoint_url_cover ||
|
||||
selectedRom.launchbox_url_cover ||
|
||||
selectedRom.hltb_url_cover ||
|
||||
null,
|
||||
};
|
||||
|
||||
@@ -500,35 +483,6 @@ onBeforeUnmount(() => {
|
||||
</v-avatar>
|
||||
</template>
|
||||
</v-tooltip>
|
||||
<v-tooltip
|
||||
location="top"
|
||||
class="tooltip"
|
||||
transition="fade-transition"
|
||||
:text="
|
||||
heartbeat.value.METADATA_SOURCES.HLTB_API_ENABLED
|
||||
? 'Filter HowLongToBeat matches'
|
||||
: 'HowLongToBeat source is not enabled'
|
||||
"
|
||||
open-delay="500"
|
||||
><template #activator="{ props }">
|
||||
<v-avatar
|
||||
@click="toggleSourceFilter('HowLongToBeat')"
|
||||
v-bind="props"
|
||||
class="ml-3 cursor-pointer opacity-40"
|
||||
:class="{
|
||||
'opacity-100':
|
||||
isHLTBFiltered &&
|
||||
heartbeat.value.METADATA_SOURCES.HLTB_API_ENABLED,
|
||||
'cursor-not-allowed':
|
||||
!heartbeat.value.METADATA_SOURCES.HLTB_API_ENABLED,
|
||||
}"
|
||||
size="30"
|
||||
rounded="1"
|
||||
>
|
||||
<v-img src="/assets/scrappers/hltb.png" />
|
||||
</v-avatar>
|
||||
</template>
|
||||
</v-tooltip>
|
||||
</template>
|
||||
<template #toolbar>
|
||||
<v-row class="align-center" no-gutters>
|
||||
|
||||
@@ -273,7 +273,6 @@ async function updateRom({
|
||||
formData.append("launchbox_id", rom.launchbox_id.toString());
|
||||
if (rom.flashpoint_id)
|
||||
formData.append("flashpoint_id", rom.flashpoint_id.toString());
|
||||
if (rom.hltb_id) formData.append("hltb_id", rom.hltb_id.toString());
|
||||
formData.append("name", rom.name || "");
|
||||
formData.append("fs_name", rom.fs_name);
|
||||
formData.append("summary", rom.summary || "");
|
||||
|
||||
Reference in New Issue
Block a user