From ffcf99a47b6dcc3aebf6ce93470f0ec6a6d1d07f Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Thu, 9 Oct 2025 16:37:15 -0400 Subject: [PATCH] Fetch html search endpoint from file --- backend/handler/metadata/hltb_handler.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/handler/metadata/hltb_handler.py b/backend/handler/metadata/hltb_handler.py index 298220a35..e6591c8ad 100644 --- a/backend/handler/metadata/hltb_handler.py +++ b/backend/handler/metadata/hltb_handler.py @@ -172,13 +172,24 @@ class HowLongToBeatHandler(MetadataHandler): def __init__(self) -> None: self.base_url = "https://howlongtobeat.com" self.user_endpoint = f"{self.base_url}/api/user" - self.search_url = f"{self.base_url}/api/seek/791cd10c5e8e894c" + self.search_url = f"{self.base_url}/api/search" self.min_similarity_score: Final = 0.85 + # HLTB rotates their search endpoint regularly + self.fetch_search_endpoint() + @classmethod def is_enabled(cls) -> bool: return HLTB_API_ENABLED + def fetch_search_endpoint(self): + """Fetch the API endpoint from the gist.""" + github_file_url = "https://raw.githubusercontent.com/rommapp/romm/refs/heads/master/backend/handler/metadata/fixtures/hltb_api_url" + + with httpx.Client() as client: + response = client.get(github_file_url) + self.search_url = response.text.strip() + async def heartbeat(self) -> bool: if not self.is_enabled(): return False