feat: Add three-tier optimization for maximum performance
Local Docker Build (Dev) / build-dev (push) Successful in 19s

Implemented smart caching system that dramatically reduces processing time:

TIER 1 (Fastest): NFO File Check
- If NFO already has NFOGuard dateadded + lockdata, use it directly
- Skips both database queries AND API calls
- Perfect for movies already processed by NFOGuard

TIER 2 (Fast): Database Check
- If database has complete dateadded data, use it
- Skips expensive API calls to TMDB/OMDB/Radarr
- Creates NFO from cached data

TIER 3 (Slowest): Full Processing
- Only when neither NFO nor database have data
- Queries all APIs, processes dates, saves to database

This should dramatically improve full scan performance, especially
on subsequent runs where most movies already have NFOGuard data.

Expected speedup: 90%+ reduction in processing time for warm scans.
This commit is contained in:
2025-09-24 11:21:38 -04:00
parent 172a364e6e
commit 3889d3a31c
2 changed files with 52 additions and 1 deletions
+35
View File
@@ -114,6 +114,41 @@ class NFOManager:
print(f"❌ No IMDb ID found in directory, filenames, or NFO for: {movie_dir.name}")
return None
def extract_nfoguard_dates_from_nfo(self, nfo_path: Path) -> Optional[Dict[str, str]]:
"""Extract NFOGuard-managed dates from existing NFO file"""
if not nfo_path.exists():
return None
try:
tree = ET.parse(nfo_path)
root = tree.getroot()
# Look for NFOGuard fields
dateadded_elem = root.find('.//dateadded')
premiered_elem = root.find('.//premiered')
lockdata_elem = root.find('.//lockdata')
# Only consider it NFOGuard-managed if it has dateadded and lockdata
if (dateadded_elem is not None and dateadded_elem.text and
lockdata_elem is not None and lockdata_elem.text == "true"):
result = {
"dateadded": dateadded_elem.text.strip(),
"source": "nfo_file_existing"
}
if premiered_elem is not None and premiered_elem.text:
result["released"] = premiered_elem.text.strip()
print(f"✅ Found NFOGuard data in NFO: dateadded={result['dateadded']}, released={result.get('released', 'None')}")
return result
except (ET.ParseError, Exception) as e:
print(f"⚠️ Error parsing NFO for NFOGuard data: {e}")
pass
return None
def _parse_nfo_with_tolerance(self, nfo_path: Path):
"""Parse NFO file with tolerance for URLs appended after XML"""
try: