From 864a82cbc50acd86b54fc53fd2170d5b18506d85 Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Wed, 22 Oct 2025 20:31:12 -0400 Subject: [PATCH] web: updates --- api/routes.py | 56 +++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/api/routes.py b/api/routes.py index 4625640..74b657e 100644 --- a/api/routes.py +++ b/api/routes.py @@ -720,35 +720,35 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N update_scan_status(current_item=item.name, movies_processed=movie_count) print(f"INFO: Processing movie: {item.name}") try: - # Determine force_scan based on scan mode - force_scan = (scan_mode == "full") - shutdown_event = dependencies.get("shutdown_event") - result = movie_processor.process_movie(item, webhook_mode=False, force_scan=force_scan, shutdown_event=shutdown_event) - movie_total += 1 - if result == "skipped": - movie_skipped += 1 - elif result == "processed": - movie_processed += 1 - elif result == "no_video_files": - print(f"INFO: Skipped empty directory: {item.name}") - movie_skipped += 1 - elif result == "shutdown": - print("INFO: ⚠️ SHUTDOWN SIGNAL RECEIVED - Stopping movie scan gracefully") - return - except Exception as e: - print(f"ERROR: Failed processing movie {item}: {e}") - movie_total += 1 + # Determine force_scan based on scan mode + force_scan = (scan_mode == "full") + shutdown_event = dependencies.get("shutdown_event") + result = movie_processor.process_movie(item, webhook_mode=False, force_scan=force_scan, shutdown_event=shutdown_event) + movie_total += 1 + if result == "skipped": + movie_skipped += 1 + elif result == "processed": + movie_processed += 1 + elif result == "no_video_files": + print(f"INFO: Skipped empty directory: {item.name}") + movie_skipped += 1 + elif result == "shutdown": + print("INFO: ⚠️ SHUTDOWN SIGNAL RECEIVED - Stopping movie scan gracefully") + return + 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: + await asyncio.sleep(0.2) # 200ms yield to process other requests + print(f"INFO: Processed {movie_count} movies, yielding to other requests...") - # Yield control every 2 movies to allow other requests (webhooks, web interface) - if movie_count % 2 == 0: - await asyncio.sleep(0.2) # 200ms yield to process other requests - print(f"INFO: Processed {movie_count} movies, yielding to other requests...") - - # Check for shutdown signal - shutdown_event = dependencies.get("shutdown_event") - if shutdown_event and shutdown_event.is_set(): - print("INFO: ⚠️ SHUTDOWN SIGNAL RECEIVED - Stopping scan gracefully") - return + # Check for shutdown signal + shutdown_event = dependencies.get("shutdown_event") + if shutdown_event and shutdown_event.is_set(): + print("INFO: ⚠️ SHUTDOWN SIGNAL RECEIVED - Stopping scan gracefully") + return print(f"INFO: Completed movie scan: {movie_count} movies processed in {scan_path}")