This commit is contained in:
@@ -7,11 +7,13 @@ Phase 4: Replace NFO-based initial population with direct DB/API queries
|
|||||||
import time
|
import time
|
||||||
from typing import Dict, List, Optional, Tuple
|
from typing import Dict, List, Optional, Tuple
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from core.database import NFOGuardDatabase
|
from core.database import NFOGuardDatabase
|
||||||
from clients.radarr_client import RadarrClient
|
from clients.radarr_client import RadarrClient
|
||||||
from clients.sonarr_client import SonarrClient
|
from clients.sonarr_client import SonarrClient
|
||||||
from utils.logging import _log
|
from utils.logging import _log
|
||||||
|
from utils.imdb_utils import parse_imdb_from_path
|
||||||
|
|
||||||
|
|
||||||
class DatabasePopulator:
|
class DatabasePopulator:
|
||||||
@@ -66,9 +68,20 @@ class DatabasePopulator:
|
|||||||
# Process each movie
|
# Process each movie
|
||||||
for movie in movies:
|
for movie in movies:
|
||||||
try:
|
try:
|
||||||
|
# Get movie path first (we'll need it for IMDb extraction)
|
||||||
|
path = movie.get('path', '')
|
||||||
|
|
||||||
|
# Try to get IMDb ID from Radarr database
|
||||||
imdb_id = movie.get('imdbId')
|
imdb_id = movie.get('imdbId')
|
||||||
|
|
||||||
|
# If not in database, try extracting from directory/filename
|
||||||
|
if not imdb_id and path:
|
||||||
|
imdb_id = parse_imdb_from_path(Path(path))
|
||||||
|
if imdb_id:
|
||||||
|
_log("DEBUG", f"Extracted IMDb ID {imdb_id} from path for: {movie.get('title')}")
|
||||||
|
|
||||||
if not imdb_id:
|
if not imdb_id:
|
||||||
_log("DEBUG", f"Skipping movie without IMDb ID: {movie.get('title')}")
|
_log("DEBUG", f"Skipping movie without IMDb ID: {movie.get('title')} (path: {path})")
|
||||||
stats['skipped'] += 1
|
stats['skipped'] += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -79,9 +92,6 @@ class DatabasePopulator:
|
|||||||
stats['skipped'] += 1
|
stats['skipped'] += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Get movie path
|
|
||||||
path = movie.get('path', '')
|
|
||||||
|
|
||||||
# Get release date
|
# Get release date
|
||||||
released = None
|
released = None
|
||||||
if movie.get('digitalRelease'):
|
if movie.get('digitalRelease'):
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ def create_web_app() -> FastAPI:
|
|||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title="NFOGuard Web Interface",
|
title="NFOGuard Web Interface",
|
||||||
description="Web interface for NFOGuard media database management",
|
description="Web interface for NFOGuard media database management",
|
||||||
version="2.8.6-sql-fix",
|
version="2.8.7-imdb-path-extraction",
|
||||||
docs_url="/docs" if web_config.web_debug else None,
|
docs_url="/docs" if web_config.web_debug else None,
|
||||||
redoc_url="/redoc" if web_config.web_debug else None
|
redoc_url="/redoc" if web_config.web_debug else None
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-2
@@ -29,7 +29,7 @@ def create_web_app() -> FastAPI:
|
|||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title="NFOGuard Web Interface",
|
title="NFOGuard Web Interface",
|
||||||
description="Web interface for NFOGuard media database management",
|
description="Web interface for NFOGuard media database management",
|
||||||
version="2.8.6-sql-fix",
|
version="2.8.7-imdb-path-extraction",
|
||||||
docs_url=None, # Disable docs in production
|
docs_url=None, # Disable docs in production
|
||||||
redoc_url=None
|
redoc_url=None
|
||||||
)
|
)
|
||||||
@@ -94,7 +94,7 @@ def setup_static_files(app: FastAPI) -> None:
|
|||||||
"status": "healthy",
|
"status": "healthy",
|
||||||
"service": "nfoguard-web",
|
"service": "nfoguard-web",
|
||||||
"timestamp": time.time(),
|
"timestamp": time.time(),
|
||||||
"version": "2.8.6-sql-fix"
|
"version": "2.8.7-imdb-path-extraction"
|
||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
from fastapi import HTTPException
|
from fastapi import HTTPException
|
||||||
|
|||||||
Reference in New Issue
Block a user