This commit is contained in:
@@ -2291,6 +2291,9 @@ def register_routes(app, dependencies: dict):
|
||||
|
||||
print("🔧 Starting NFO repair scan from core container")
|
||||
|
||||
import time
|
||||
scan_start_time = time.time()
|
||||
|
||||
missing_items = {
|
||||
"episodes": [],
|
||||
"movies": []
|
||||
@@ -2314,7 +2317,24 @@ def register_routes(app, dependencies: dict):
|
||||
|
||||
print(f"📊 Found {len(episodes)} episodes in database")
|
||||
|
||||
processed_count = 0
|
||||
for episode in episodes:
|
||||
processed_count += 1
|
||||
|
||||
# Progress logging every 1000 items
|
||||
if processed_count % 1000 == 0:
|
||||
elapsed = time.time() - scan_start_time
|
||||
print(f"📊 Progress: {processed_count}/{len(episodes)} episodes processed in {elapsed:.1f}s, {len(missing_items['episodes'])} missing found so far")
|
||||
|
||||
# Time-based exit (max 3 minutes for episodes)
|
||||
if time.time() - scan_start_time > 180:
|
||||
print(f"⏰ Episode scan timeout after 3 minutes - processed {processed_count}/{len(episodes)} episodes")
|
||||
break
|
||||
|
||||
# Early exit if we find too many missing items (performance safety)
|
||||
if len(missing_items['episodes']) > 1000:
|
||||
print(f"⚠️ Found {len(missing_items['episodes'])} missing episodes - stopping scan to prevent performance issues")
|
||||
break
|
||||
# Build NFO path using series path
|
||||
series_name = os.path.basename(episode["series_path"])
|
||||
|
||||
@@ -2399,7 +2419,24 @@ def register_routes(app, dependencies: dict):
|
||||
|
||||
print(f"📊 Found {len(movies)} movies in database")
|
||||
|
||||
processed_count = 0
|
||||
for movie in movies:
|
||||
processed_count += 1
|
||||
|
||||
# Progress logging every 500 items
|
||||
if processed_count % 500 == 0:
|
||||
elapsed = time.time() - scan_start_time
|
||||
print(f"📊 Progress: {processed_count}/{len(movies)} movies processed in {elapsed:.1f}s, {len(missing_items['movies'])} missing found so far")
|
||||
|
||||
# Time-based exit (max 5 minutes total)
|
||||
if time.time() - scan_start_time > 300:
|
||||
print(f"⏰ Total scan timeout after 5 minutes - processed {processed_count}/{len(movies)} movies")
|
||||
break
|
||||
|
||||
# Early exit if we find too many missing items (performance safety)
|
||||
if len(missing_items['movies']) > 500:
|
||||
print(f"⚠️ Found {len(missing_items['movies'])} missing movies - stopping scan to prevent performance issues")
|
||||
break
|
||||
# Build NFO path using movie path
|
||||
movie_title = os.path.basename(movie["path"])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user