This commit is contained in:
@@ -631,6 +631,12 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
|
||||
import re
|
||||
tv_count = 0
|
||||
for item in scan_path.iterdir():
|
||||
# Check for shutdown signal at start of each item
|
||||
shutdown_event = dependencies.get("shutdown_event")
|
||||
if shutdown_event and shutdown_event.is_set():
|
||||
print("INFO: ⚠️ SHUTDOWN SIGNAL RECEIVED - Stopping scan gracefully")
|
||||
return
|
||||
|
||||
if (item.is_dir() and
|
||||
not item.name.lower().startswith('season') and
|
||||
not re.match(r'^season\s+\d+$', item.name, re.IGNORECASE) and
|
||||
@@ -653,11 +659,23 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
|
||||
if tv_count % 1 == 0:
|
||||
await asyncio.sleep(0.2) # 200ms yield to process other requests
|
||||
print(f"INFO: Processed {tv_count} TV series, 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
|
||||
|
||||
if scan_type in ["both", "movies"] and scan_path in config.movie_paths:
|
||||
print(f"INFO: Scanning movies in: {scan_path}")
|
||||
movie_count = 0
|
||||
for item in scan_path.iterdir():
|
||||
# Check for shutdown signal at start of each movie
|
||||
shutdown_event = dependencies.get("shutdown_event")
|
||||
if shutdown_event and shutdown_event.is_set():
|
||||
print("INFO: ⚠️ SHUTDOWN SIGNAL RECEIVED - Stopping scan gracefully")
|
||||
return
|
||||
|
||||
if item.is_dir() and nfo_manager.find_movie_imdb_id(item):
|
||||
movie_count += 1
|
||||
print(f"INFO: Processing movie: {item.name}")
|
||||
@@ -678,6 +696,12 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
|
||||
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
|
||||
|
||||
print(f"INFO: Completed movie scan: {movie_count} movies processed in {scan_path}")
|
||||
|
||||
|
||||
+5
-5
@@ -173,13 +173,13 @@ async def get_tv_series_list(dependencies: dict,
|
||||
if date_filter:
|
||||
if date_filter == "complete":
|
||||
# All episodes have dates
|
||||
having_conditions.append("COUNT(e.episode) > 0 AND COUNT(CASE WHEN e.dateadded IS NULL OR e.dateadded = '' THEN 1 END) = 0")
|
||||
having_conditions.append("COUNT(e.episode) > 0 AND COUNT(CASE WHEN e.dateadded IS NULL THEN 1 END) = 0")
|
||||
elif date_filter == "incomplete":
|
||||
# Some episodes have dates, some don't
|
||||
having_conditions.append("COUNT(e.episode) > 0 AND COUNT(CASE WHEN e.dateadded IS NOT NULL AND e.dateadded != '' THEN 1 END) > 0 AND COUNT(CASE WHEN e.dateadded IS NULL OR e.dateadded = '' THEN 1 END) > 0")
|
||||
having_conditions.append("COUNT(e.episode) > 0 AND COUNT(CASE WHEN e.dateadded IS NOT NULL THEN 1 END) > 0 AND COUNT(CASE WHEN e.dateadded IS NULL THEN 1 END) > 0")
|
||||
elif date_filter == "none":
|
||||
# No episodes have dates
|
||||
having_conditions.append("COUNT(e.episode) > 0 AND COUNT(CASE WHEN e.dateadded IS NOT NULL AND e.dateadded != '' THEN 1 END) = 0")
|
||||
having_conditions.append("COUNT(e.episode) > 0 AND COUNT(CASE WHEN e.dateadded IS NOT NULL THEN 1 END) = 0")
|
||||
|
||||
where_clause = " AND ".join(where_conditions) if where_conditions else "1=1"
|
||||
having_clause = " AND ".join(having_conditions) if having_conditions else ""
|
||||
@@ -276,8 +276,8 @@ async def debug_series_date_distribution(dependencies: dict):
|
||||
s.imdb_id,
|
||||
s.path,
|
||||
COUNT(e.episode) as total_episodes,
|
||||
COUNT(CASE WHEN e.dateadded IS NOT NULL AND e.dateadded != '' THEN 1 END) as episodes_with_dates,
|
||||
COUNT(CASE WHEN e.dateadded IS NULL OR e.dateadded = '' THEN 1 END) as episodes_without_dates
|
||||
COUNT(CASE WHEN e.dateadded IS NOT NULL THEN 1 END) as episodes_with_dates,
|
||||
COUNT(CASE WHEN e.dateadded IS NULL THEN 1 END) as episodes_without_dates
|
||||
FROM series s
|
||||
LEFT JOIN episodes e ON s.imdb_id = e.imdb_id
|
||||
GROUP BY s.imdb_id, s.path
|
||||
|
||||
Reference in New Issue
Block a user