This commit is contained in:
@@ -1575,7 +1575,15 @@ async def get_episodes_missing_nfo_dateadded(dependencies: dict):
|
|||||||
missing_dateadded = []
|
missing_dateadded = []
|
||||||
nfo_manager = dependencies["nfo_manager"]
|
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:
|
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:
|
try:
|
||||||
media_type = item['media_type']
|
media_type = item['media_type']
|
||||||
item_path = Path(item['series_path'])
|
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'])
|
season_dir = item_path / config.tv_season_dir_format.format(season=item['season'])
|
||||||
|
|
||||||
if not season_dir.exists():
|
if not season_dir.exists():
|
||||||
|
if processed_count <= 5: # Debug first few
|
||||||
|
print(f"🔍 DEBUG: Season dir doesn't exist: {season_dir}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Find NFO file for this episode
|
# Find NFO file for this episode
|
||||||
nfo_files = list(season_dir.glob(f"*S{item['season']:02d}E{item['episode']:02d}*.nfo"))
|
nfo_files = list(season_dir.glob(f"*S{item['season']:02d}E{item['episode']:02d}*.nfo"))
|
||||||
if not nfo_files:
|
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
|
continue
|
||||||
|
|
||||||
nfo_path = nfo_files[0] # Use first match
|
nfo_path = nfo_files[0] # Use first match
|
||||||
|
nfo_found_count += 1
|
||||||
|
|
||||||
elif media_type == 'movie':
|
elif media_type == 'movie':
|
||||||
# Handle movies
|
# Handle movies
|
||||||
if not item_path.exists():
|
if not item_path.exists():
|
||||||
|
if processed_count <= 5: # Debug first few
|
||||||
|
print(f"🔍 DEBUG: Movie path doesn't exist: {item_path}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Find NFO file for this movie
|
# Find NFO file for this movie
|
||||||
nfo_files = list(item_path.glob("*.nfo"))
|
nfo_files = list(item_path.glob("*.nfo"))
|
||||||
if not nfo_files:
|
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
|
continue
|
||||||
|
|
||||||
nfo_path = nfo_files[0] # Use first match
|
nfo_path = nfo_files[0] # Use first match
|
||||||
|
nfo_found_count += 1
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if processed_count <= 5: # Debug first few
|
||||||
|
print(f"🔍 DEBUG: Found NFO file: {nfo_path}")
|
||||||
|
|
||||||
# Parse NFO and check for dateadded
|
# Parse NFO and check for dateadded
|
||||||
try:
|
try:
|
||||||
import xml.etree.ElementTree as ET
|
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
|
# Check if dateadded is missing or empty
|
||||||
has_dateadded = dateadded_elem is not None and dateadded_elem.text and dateadded_elem.text.strip()
|
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 NFO is missing dateadded, check if item should have a date
|
||||||
if not has_dateadded:
|
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
|
# Item should have a date if it has one in the database, or if it has aired date
|
||||||
should_have_date = (
|
should_have_date = (
|
||||||
item['dateadded'] is not None or
|
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
|
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:
|
if should_have_date:
|
||||||
missing_dateadded.append({
|
missing_dateadded.append({
|
||||||
**item,
|
**item,
|
||||||
@@ -1636,6 +1667,9 @@ async def get_episodes_missing_nfo_dateadded(dependencies: dict):
|
|||||||
'should_have_date': True
|
'should_have_date': True
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if processed_count <= 5: # Debug first few
|
||||||
|
print(f"🔍 DEBUG: Added to missing list: {item['imdb_id']}")
|
||||||
|
|
||||||
except ET.ParseError:
|
except ET.ParseError:
|
||||||
# NFO file is corrupted
|
# NFO file is corrupted
|
||||||
missing_dateadded.append({
|
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}")
|
print(f"Error checking NFO for movie {item['imdb_id']}: {e}")
|
||||||
continue
|
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 {
|
return {
|
||||||
"success": True,
|
"success": True,
|
||||||
"total_episodes_checked": len(episodes),
|
"total_episodes_checked": len(episodes),
|
||||||
|
|||||||
Reference in New Issue
Block a user