Task 3: remove non-reentrant TMDB context in NFOService and mark task done

This commit is contained in:
2026-04-19 18:49:21 +02:00
parent b10cce0489
commit 6ad14c03b5
2 changed files with 29 additions and 21 deletions

View File

@@ -98,6 +98,8 @@ If the TMDB API key is configured only via `config.json` (not the `TMDB_API_KEY`
## Task 3 — Remove non-reentrant `async with self.tmdb_client:` from NFOService public methods
- [x] Completed
### Where
`src/core/services/nfo_service.py``create_tvshow_nfo` (~line 151) and `update_tvshow_nfo` (~line 265)

View File

@@ -146,7 +146,9 @@ class NFOService:
logger.info("Creating series folder: %s", folder_path)
folder_path.mkdir(parents=True, exist_ok=True)
async with self.tmdb_client:
try:
await self.tmdb_client._ensure_session()
# Search for TV show with clean name (without year)
logger.debug("Searching TMDB for: %s", search_name)
search_results = await self.tmdb_client.search_tv_show(search_name)
@@ -202,6 +204,8 @@ class NFOService:
)
return nfo_path
finally:
await self.tmdb_client.close()
async def update_tvshow_nfo(
self,
@@ -260,8 +264,8 @@ class NFOService:
except ValueError as e:
raise TMDBAPIError(f"Invalid TMDB ID format in NFO: {e}")
# Fetch fresh data from TMDB
async with self.tmdb_client:
try:
await self.tmdb_client._ensure_session()
logger.debug("Fetching fresh data for TMDB ID: %s", tmdb_id)
details = await self.tmdb_client.get_tv_show_details(
tmdb_id,
@@ -299,6 +303,8 @@ class NFOService:
)
return nfo_path
finally:
await self.tmdb_client.close()
def parse_nfo_ids(self, nfo_path: Path) -> Dict[str, Optional[int]]:
"""Parse TMDB ID and TVDB ID from an existing NFO file.