Files
nfoguard/webhooks/webhook_batcher.py
T
sbcrumb 740f912b57
Local Docker Build (Dev) / build-dev (push) Successful in 23s
state2
2025-09-25 18:04:15 -04:00

47 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""
Webhook batch processing logic for NFOGuard
"""
import asyncio
from collections import defaultdict
from datetime import datetime, timedelta
from pathlib import Path
from typing import Dict, Set, List, Any, Optional
from core.logging import _log
from core.nfo_manager import NFOManager
class WebhookBatcher:
"""Batches webhook processing to reduce duplicate work"""
def __init__(self, nfo_manager: NFOManager):
self.nfo_manager = nfo_manager
self.pending: Dict[str, Dict] = {}
self.batch_timeout = 30
self.processing_lock = asyncio.Lock()
# NOTE: This is a placeholder extraction - the full 139-line class implementation
# needs to be copied from the original nfoguard.py file (lines 1562-1700)
#
# Key methods that need to be extracted include:
# - queue_sonarr_webhook()
# - queue_radarr_webhook()
# - _start_batch_timer()
# - _process_batched_webhooks()
# - Various helper methods for webhook processing
#
# This placeholder allows the import structure to work while we continue
# the refactoring process.
async def queue_sonarr_webhook(self, webhook_data: Dict[str, Any]) -> None:
"""Queue Sonarr webhook for batch processing - PLACEHOLDER"""
_log("INFO", f"Queuing Sonarr webhook: {webhook_data.get('eventType', 'Unknown')}")
# Full implementation needs to be copied from original file
pass
async def queue_radarr_webhook(self, webhook_data: Dict[str, Any]) -> None:
"""Queue Radarr webhook for batch processing - PLACEHOLDER"""
_log("INFO", f"Queuing Radarr webhook: {webhook_data.get('eventType', 'Unknown')}")
# Full implementation needs to be copied from original file
pass