web: debug nfo fix
Local Docker Build (Dev) / build-dev (push) Successful in 4s

This commit is contained in:
2025-10-26 12:14:06 -04:00
parent 4d7d9752fc
commit 319838d305
+40
View File
@@ -1575,7 +1575,15 @@ async def get_episodes_missing_nfo_dateadded(dependencies: dict):
missing_dateadded = []
nfo_manager = dependencies["nfo_manager"]
print(f"🔍 DEBUG: Starting NFO scan of {len(all_items)} items...")
processed_count = 0
nfo_found_count = 0
nfo_missing_dateadded_count = 0
for item in all_items:
processed_count += 1
if processed_count <= 10 or processed_count % 100 == 0: # Log progress
print(f"🔍 DEBUG: Processing item {processed_count}/{len(all_items)}: {item['imdb_id']}")
try:
media_type = item['media_type']
item_path = Path(item['series_path'])
@@ -1585,29 +1593,42 @@ async def get_episodes_missing_nfo_dateadded(dependencies: dict):
season_dir = item_path / config.tv_season_dir_format.format(season=item['season'])
if not season_dir.exists():
if processed_count <= 5: # Debug first few
print(f"🔍 DEBUG: Season dir doesn't exist: {season_dir}")
continue
# Find NFO file for this episode
nfo_files = list(season_dir.glob(f"*S{item['season']:02d}E{item['episode']:02d}*.nfo"))
if not nfo_files:
if processed_count <= 5: # Debug first few
print(f"🔍 DEBUG: No NFO found for {item['imdb_id']} S{item['season']:02d}E{item['episode']:02d} in {season_dir}")
continue
nfo_path = nfo_files[0] # Use first match
nfo_found_count += 1
elif media_type == 'movie':
# Handle movies
if not item_path.exists():
if processed_count <= 5: # Debug first few
print(f"🔍 DEBUG: Movie path doesn't exist: {item_path}")
continue
# Find NFO file for this movie
nfo_files = list(item_path.glob("*.nfo"))
if not nfo_files:
if processed_count <= 5: # Debug first few
print(f"🔍 DEBUG: No NFO found for movie {item['imdb_id']} in {item_path}")
continue
nfo_path = nfo_files[0] # Use first match
nfo_found_count += 1
else:
continue
if processed_count <= 5: # Debug first few
print(f"🔍 DEBUG: Found NFO file: {nfo_path}")
# Parse NFO and check for dateadded
try:
import xml.etree.ElementTree as ET
@@ -1618,8 +1639,15 @@ async def get_episodes_missing_nfo_dateadded(dependencies: dict):
# Check if dateadded is missing or empty
has_dateadded = dateadded_elem is not None and dateadded_elem.text and dateadded_elem.text.strip()
if processed_count <= 5: # Debug first few
print(f"🔍 DEBUG: NFO {nfo_path} - dateadded element: {dateadded_elem}")
print(f"🔍 DEBUG: dateadded text: {dateadded_elem.text if dateadded_elem is not None else 'None'}")
print(f"🔍 DEBUG: has_dateadded: {has_dateadded}")
# If NFO is missing dateadded, check if item should have a date
if not has_dateadded:
nfo_missing_dateadded_count += 1
# Item should have a date if it has one in the database, or if it has aired date
should_have_date = (
item['dateadded'] is not None or
@@ -1627,6 +1655,9 @@ async def get_episodes_missing_nfo_dateadded(dependencies: dict):
media_type == 'movie' # Movies should generally have dateadded
)
if processed_count <= 5: # Debug first few
print(f"🔍 DEBUG: should_have_date: {should_have_date} (db_date: {item['dateadded']}, aired: {item.get('aired')})")
if should_have_date:
missing_dateadded.append({
**item,
@@ -1636,6 +1667,9 @@ async def get_episodes_missing_nfo_dateadded(dependencies: dict):
'should_have_date': True
})
if processed_count <= 5: # Debug first few
print(f"🔍 DEBUG: Added to missing list: {item['imdb_id']}")
except ET.ParseError:
# NFO file is corrupted
missing_dateadded.append({
@@ -1653,6 +1687,12 @@ async def get_episodes_missing_nfo_dateadded(dependencies: dict):
print(f"Error checking NFO for movie {item['imdb_id']}: {e}")
continue
print(f"🔍 DEBUG: NFO scan complete!")
print(f"🔍 DEBUG: Total items: {len(all_items)}")
print(f"🔍 DEBUG: NFO files found: {nfo_found_count}")
print(f"🔍 DEBUG: NFO files missing dateadded: {nfo_missing_dateadded_count}")
print(f"🔍 DEBUG: Items that should have dateadded: {len(missing_dateadded)}")
return {
"success": True,
"total_episodes_checked": len(episodes),