feat(pm_handler): allow disabling playmatch via env

This commit is contained in:
Yukine
2025-06-05 14:36:40 +02:00
parent e245426be1
commit 9bbe0613c6
3 changed files with 15 additions and 1 deletions

View File

@@ -72,6 +72,9 @@ REFRESH_RETROACHIEVEMENTS_CACHE_DAYS: Final = int(
os.environ.get("REFRESH_RETROACHIEVEMENTS_CACHE_DAYS", 30)
)
# PLAYMATCH
PLAYMATCH_ENABLED: Final = str_to_bool(os.environ.get("PLAYMATCH_ENABLED", "true"))
# MOBYGAMES
MOBYGAMES_API_KEY: Final = os.environ.get("MOBYGAMES_API_KEY", "").strip()

View File

@@ -1,5 +1,5 @@
from enum import Enum
from typing import NotRequired, Optional, TypedDict, cast
from typing import Final, NotRequired, Optional, TypedDict, cast
import httpx
import yarl
@@ -7,6 +7,10 @@ from fastapi import HTTPException, status
from logger.logger import log
from utils.context import ctx_httpx_client
from backend.config import PLAYMATCH_ENABLED
PM_ENABLED: Final = bool(PLAYMATCH_ENABLED)
class PlaymatchProvider(str, Enum):
"""
@@ -72,6 +76,10 @@ class PlaymatchHandler:
:return: The IGDB provider ID if a match is found, otherwise None.
:raises HTTPException: If the request fails or the service is unavailable.
"""
if not PM_ENABLED:
log.debug("Playmatch is not enabled, skipping identification.")
return None
url = f"{self.base_url}/identify/ids"
response = await self._request(

View File

@@ -21,6 +21,9 @@ SCREENSCRAPER_PASSWORD=
# SteamGridDB
STEAMGRIDDB_API_KEY=
# Playmatch
PLAYMATCH_ENABLED=
# RetroAchievements
RETROACHIEVEMENTS_API_KEY=