This commit is contained in:
+41
-9
@@ -72,9 +72,9 @@ def register_routes(
|
||||
_log("WARNING", "No series data in Sonarr webhook")
|
||||
return {"status": "error", "message": "No series data"}
|
||||
|
||||
# Process the webhook (implementation would continue from original file)
|
||||
# This is a placeholder - full implementation needs to be copied from nfoguard.py
|
||||
return {"status": "queued", "message": "Sonarr webhook queued for processing"}
|
||||
# Process the webhook using the batcher
|
||||
await batcher.queue_sonarr_webhook(payload)
|
||||
return {"status": "queued", "message": f"Sonarr {webhook.eventType} webhook queued for processing"}
|
||||
|
||||
except Exception as e:
|
||||
_log("ERROR", f"Sonarr webhook error: {e}")
|
||||
@@ -98,9 +98,9 @@ def register_routes(
|
||||
_log("WARNING", "No movie data in Radarr webhook")
|
||||
return {"status": "error", "message": "No movie data"}
|
||||
|
||||
# Process the webhook (implementation would continue from original file)
|
||||
# This is a placeholder - full implementation needs to be copied from nfoguard.py
|
||||
return {"status": "queued", "message": "Radarr webhook queued for processing"}
|
||||
# Process the webhook using the batcher
|
||||
await batcher.queue_radarr_webhook(payload)
|
||||
return {"status": "queued", "message": f"Radarr {webhook.eventType} webhook queued for processing"}
|
||||
|
||||
except Exception as e:
|
||||
_log("ERROR", f"Radarr webhook error: {e}")
|
||||
@@ -158,16 +158,48 @@ def register_routes(
|
||||
async def batch_status():
|
||||
"""Get current batch processing status"""
|
||||
return {
|
||||
"message": "Batch status endpoint - implementation needed",
|
||||
"pending_items": len(getattr(batcher, 'pending', {}))
|
||||
"pending_items": batcher.get_pending_count(),
|
||||
"processing_items": batcher.get_processing_count(),
|
||||
"total_queued": batcher.get_pending_count() + batcher.get_processing_count()
|
||||
}
|
||||
|
||||
@app.post("/manual/scan")
|
||||
async def manual_scan(background_tasks: BackgroundTasks):
|
||||
"""Trigger manual library scan"""
|
||||
try:
|
||||
# Add the actual manual scan logic here
|
||||
_log("INFO", "Manual scan triggered via API")
|
||||
|
||||
# Add background task to scan all libraries
|
||||
def scan_libraries():
|
||||
total_processed = 0
|
||||
|
||||
# Scan TV libraries
|
||||
for tv_path in config.tv_paths:
|
||||
if tv_path.exists():
|
||||
_log("INFO", f"Scanning TV library: {tv_path}")
|
||||
for series_dir in tv_path.iterdir():
|
||||
if series_dir.is_dir() and "[imdb-" in series_dir.name:
|
||||
try:
|
||||
tv_processor.process_series(series_dir)
|
||||
total_processed += 1
|
||||
except Exception as e:
|
||||
_log("ERROR", f"Error processing series {series_dir.name}: {e}")
|
||||
|
||||
# Scan Movie libraries
|
||||
for movie_path in config.movie_paths:
|
||||
if movie_path.exists():
|
||||
_log("INFO", f"Scanning movie library: {movie_path}")
|
||||
for movie_dir in movie_path.iterdir():
|
||||
if movie_dir.is_dir():
|
||||
try:
|
||||
movie_processor.process_movie(movie_dir)
|
||||
total_processed += 1
|
||||
except Exception as e:
|
||||
_log("ERROR", f"Error processing movie {movie_dir.name}: {e}")
|
||||
|
||||
_log("INFO", f"Manual scan completed: {total_processed} items processed")
|
||||
|
||||
background_tasks.add_task(scan_libraries)
|
||||
return {"status": "started", "message": "Manual scan initiated"}
|
||||
except Exception as e:
|
||||
_log("ERROR", f"Manual scan failed: {e}")
|
||||
|
||||
Reference in New Issue
Block a user