This commit is contained in:
pacnpal
2024-11-18 00:51:55 +00:00
parent afe0e96b14
commit 7276e37cab
5 changed files with 14 additions and 8 deletions

View File

@@ -49,7 +49,7 @@ from .reactions import (
) )
# Import progress tracking # Import progress tracking
from ..utils.progress_tracker import progress_tracker from ..utils.progress_tracker import ProgressTracker
# Import handlers after other dependencies are loaded # Import handlers after other dependencies are loaded
from .message_handler import MessageHandler from .message_handler import MessageHandler
@@ -113,6 +113,7 @@ __description__ = "Video processing module for archiving Discord videos"
# Create shared instances for module-level access # Create shared instances for module-level access
url_extractor = URLExtractor() url_extractor = URLExtractor()
message_validator = MessageValidator() message_validator = MessageValidator()
progress_tracker = ProgressTracker() # Create singleton instance
# URL extraction helper functions # URL extraction helper functions

View File

@@ -10,7 +10,7 @@ from discord.ext import commands # type: ignore
from videoarchiver.core.types import ComponentState, ProcessorState, ComponentStatus, IComponent, IConfigManager, IQueueManager from videoarchiver.core.types import ComponentState, ProcessorState, ComponentStatus, IComponent, IConfigManager, IQueueManager
from videoarchiver.processor.constants import REACTIONS from videoarchiver.processor.constants import REACTIONS
from videoarchiver.utils import progress_tracker from videoarchiver.utils.progress_tracker import ProgressTracker
from videoarchiver.utils.exceptions import ProcessorError from videoarchiver.utils.exceptions import ProcessorError
logger = logging.getLogger("VideoArchiver") logger = logging.getLogger("VideoArchiver")
@@ -90,6 +90,7 @@ class HealthMonitor:
self.last_check: Optional[datetime] = None self.last_check: Optional[datetime] = None
self.health_status: Dict[str, bool] = {} self.health_status: Dict[str, bool] = {}
self._monitor_task: Optional[asyncio.Task] = None self._monitor_task: Optional[asyncio.Task] = None
self.progress_tracker = ProgressTracker() # Initialize ProgressTracker instance
async def start_monitoring(self) -> None: async def start_monitoring(self) -> None:
"""Start health monitoring""" """Start health monitoring"""
@@ -116,7 +117,7 @@ class HealthMonitor:
self.health_status.update({ self.health_status.update({
"queue_handler": self.processor.queue_handler.is_healthy(), "queue_handler": self.processor.queue_handler.is_healthy(),
"message_handler": self.processor.message_handler.is_healthy(), "message_handler": self.processor.message_handler.is_healthy(),
"progress_tracker": progress_tracker.is_healthy(), "progress_tracker": self.progress_tracker.is_healthy(),
}) })
# Check operation health # Check operation health

View File

@@ -17,6 +17,7 @@ try:
from ..utils.exceptions import QueueHandlerError from ..utils.exceptions import QueueHandlerError
from ..queue.models import QueueItem from ..queue.models import QueueItem
from ..config_manager import ConfigManager from ..config_manager import ConfigManager
from . import progress_tracker # Import from processor package
from .constants import REACTIONS from .constants import REACTIONS
except ImportError: except ImportError:
# Fall back to absolute imports if relative imports fail # Fall back to absolute imports if relative imports fail
@@ -27,6 +28,7 @@ except ImportError:
from videoarchiver.utils.exceptions import QueueHandlerError from videoarchiver.utils.exceptions import QueueHandlerError
from videoarchiver.queue.models import QueueItem from videoarchiver.queue.models import QueueItem
from videoarchiver.config_manager import ConfigManager from videoarchiver.config_manager import ConfigManager
from videoarchiver.processor import progress_tracker # Import from processor package
from videoarchiver.processor.constants import REACTIONS from videoarchiver.processor.constants import REACTIONS
logger = logging.getLogger("VideoArchiver") logger = logging.getLogger("VideoArchiver")
@@ -390,7 +392,7 @@ class QueueHandler:
return return
# Update progress tracking # Update progress tracking
utils.progress_tracker.update_download_progress( progress_tracker.update_download_progress(
url, url,
{ {
"percent": progress, "percent": progress,
@@ -437,9 +439,9 @@ class QueueHandler:
download_task, timeout=self.DOWNLOAD_TIMEOUT download_task, timeout=self.DOWNLOAD_TIMEOUT
) )
if success: if success:
utils.progress_tracker.complete_download(url) progress_tracker.complete_download(url)
else: else:
utils.progress_tracker.increment_download_retries(url) progress_tracker.increment_download_retries(url)
return success, file_path, error return success, file_path, error
except asyncio.TimeoutError: except asyncio.TimeoutError:

View File

@@ -85,6 +85,9 @@ from .exceptions import (
TrackingError TrackingError
) )
# Import progress_tracker from processor
from ..processor import progress_tracker
__all__ = [ __all__ = [
# File Operations # File Operations
'cleanup_downloads', 'cleanup_downloads',
@@ -186,7 +189,6 @@ directory_manager = DirectoryManager()
permission_manager = PermissionManager() permission_manager = PermissionManager()
download_manager = DownloadManager() download_manager = DownloadManager()
compression_manager = CompressionManager() compression_manager = CompressionManager()
progress_tracker = ProgressTracker()
path_manager = PathManager() path_manager = PathManager()
# Progress tracking helper functions # Progress tracking helper functions

View File

@@ -11,7 +11,7 @@ from pathlib import Path
from ..ffmpeg.verification_manager import VerificationManager from ..ffmpeg.verification_manager import VerificationManager
from ..utils.compression_manager import CompressionManager from ..utils.compression_manager import CompressionManager
from ..utils import progress_tracker from ..processor import progress_tracker # Import from processor instead of utils
logger = logging.getLogger("DownloadManager") logger = logging.getLogger("DownloadManager")