featuer: smart scan to skip ones with dates
Local Docker Build (Dev) / build-dev (push) Successful in 4s
Local Docker Build (Dev) / build-dev (push) Successful in 4s
This commit is contained in:
+30
-3
@@ -573,6 +573,9 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
|
||||
tv_series_total = 0
|
||||
tv_series_skipped = 0
|
||||
tv_series_processed = 0
|
||||
movie_total = 0
|
||||
movie_skipped = 0
|
||||
movie_processed = 0
|
||||
|
||||
paths_to_scan = []
|
||||
if path:
|
||||
@@ -659,9 +662,17 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
|
||||
movie_count += 1
|
||||
print(f"INFO: Processing movie: {item.name}")
|
||||
try:
|
||||
movie_processor.process_movie(item)
|
||||
# Determine force_scan based on scan mode
|
||||
force_scan = (scan_mode == "full")
|
||||
result = movie_processor.process_movie(item, webhook_mode=False, force_scan=force_scan)
|
||||
movie_total += 1
|
||||
if result == "skipped":
|
||||
movie_skipped += 1
|
||||
elif result == "processed":
|
||||
movie_processed += 1
|
||||
except Exception as e:
|
||||
print(f"ERROR: Failed processing movie {item}: {e}")
|
||||
movie_total += 1
|
||||
|
||||
# Yield control every 2 movies to allow other requests (webhooks, web interface)
|
||||
if movie_count % 2 == 0:
|
||||
@@ -697,10 +708,26 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
|
||||
|
||||
# Print optimization statistics for TV scans
|
||||
if scan_type in ["both", "tv"] and tv_series_total > 0:
|
||||
print(f"📊 SCAN OPTIMIZATION STATS: Total: {tv_series_total}, Processed: {tv_series_processed}, Skipped: {tv_series_skipped}")
|
||||
print(f"📊 TV SCAN OPTIMIZATION: Total: {tv_series_total}, Processed: {tv_series_processed}, Skipped: {tv_series_skipped}")
|
||||
if tv_series_skipped > 0:
|
||||
skip_percentage = (tv_series_skipped / tv_series_total) * 100
|
||||
print(f"⚡ PERFORMANCE BOOST: {tv_series_skipped}/{tv_series_total} series skipped ({skip_percentage:.1f}% time saved!)")
|
||||
print(f"⚡ TV PERFORMANCE BOOST: {tv_series_skipped}/{tv_series_total} series skipped ({skip_percentage:.1f}% time saved!)")
|
||||
|
||||
# Print optimization statistics for movie scans
|
||||
if scan_type in ["both", "movies"] and movie_total > 0:
|
||||
print(f"📊 MOVIE SCAN OPTIMIZATION: Total: {movie_total}, Processed: {movie_processed}, Skipped: {movie_skipped}")
|
||||
if movie_skipped > 0:
|
||||
skip_percentage = (movie_skipped / movie_total) * 100
|
||||
print(f"⚡ MOVIE PERFORMANCE BOOST: {movie_skipped}/{movie_total} movies skipped ({skip_percentage:.1f}% time saved!)")
|
||||
|
||||
# Print combined optimization statistics for "both" scans
|
||||
if scan_type == "both" and (tv_series_total > 0 or movie_total > 0):
|
||||
total_items = tv_series_total + movie_total
|
||||
total_skipped = tv_series_skipped + movie_skipped
|
||||
total_processed = tv_series_processed + movie_processed
|
||||
if total_skipped > 0:
|
||||
overall_skip_percentage = (total_skipped / total_items) * 100
|
||||
print(f"🎯 OVERALL OPTIMIZATION: {total_skipped}/{total_items} items skipped ({overall_skip_percentage:.1f}% total time saved!)")
|
||||
|
||||
background_tasks.add_task(run_scan)
|
||||
return {"status": "started", "message": f"Manual {scan_type} scan started (mode: {scan_mode})"}
|
||||
|
||||
Reference in New Issue
Block a user