This commit is contained in:
+39
-2
@@ -2291,6 +2291,9 @@ def register_routes(app, dependencies: dict):
|
|||||||
|
|
||||||
print("🔧 Starting NFO repair scan from core container")
|
print("🔧 Starting NFO repair scan from core container")
|
||||||
|
|
||||||
|
import time
|
||||||
|
scan_start_time = time.time()
|
||||||
|
|
||||||
missing_items = {
|
missing_items = {
|
||||||
"episodes": [],
|
"episodes": [],
|
||||||
"movies": []
|
"movies": []
|
||||||
@@ -2313,8 +2316,25 @@ def register_routes(app, dependencies: dict):
|
|||||||
episodes = [dict(row) for row in cursor.fetchall()]
|
episodes = [dict(row) for row in cursor.fetchall()]
|
||||||
|
|
||||||
print(f"📊 Found {len(episodes)} episodes in database")
|
print(f"📊 Found {len(episodes)} episodes in database")
|
||||||
|
|
||||||
|
processed_count = 0
|
||||||
for episode in episodes:
|
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
|
# Build NFO path using series path
|
||||||
series_name = os.path.basename(episode["series_path"])
|
series_name = os.path.basename(episode["series_path"])
|
||||||
|
|
||||||
@@ -2398,8 +2418,25 @@ def register_routes(app, dependencies: dict):
|
|||||||
movies = [dict(row) for row in cursor.fetchall()]
|
movies = [dict(row) for row in cursor.fetchall()]
|
||||||
|
|
||||||
print(f"📊 Found {len(movies)} movies in database")
|
print(f"📊 Found {len(movies)} movies in database")
|
||||||
|
|
||||||
|
processed_count = 0
|
||||||
for movie in movies:
|
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
|
# Build NFO path using movie path
|
||||||
movie_title = os.path.basename(movie["path"])
|
movie_title = os.path.basename(movie["path"])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user