mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-20 02:41:06 -05:00
loads of import fixes
This commit is contained in:
@@ -1,27 +1,27 @@
|
||||
"""Video processing module for VideoArchiver"""
|
||||
|
||||
from typing import Dict, Any, Optional, Union, List, Tuple
|
||||
import discord
|
||||
import discord # type: ignore
|
||||
|
||||
from .processor.core import VideoProcessor
|
||||
from .processor.constants import (
|
||||
from ..processor.core import VideoProcessor
|
||||
from ..processor.constants import (
|
||||
REACTIONS,
|
||||
ReactionType,
|
||||
ReactionEmojis,
|
||||
ProgressEmojis,
|
||||
get_reaction,
|
||||
get_progress_emoji
|
||||
get_progress_emoji,
|
||||
)
|
||||
from .processor.url_extractor import (
|
||||
from ..processor.url_extractor import (
|
||||
URLExtractor,
|
||||
URLMetadata,
|
||||
URLPattern,
|
||||
URLType,
|
||||
URLPatternManager,
|
||||
URLValidator,
|
||||
URLMetadataExtractor
|
||||
URLMetadataExtractor,
|
||||
)
|
||||
from .processor.message_validator import (
|
||||
from ..processor.message_validator import (
|
||||
MessageValidator,
|
||||
ValidationContext,
|
||||
ValidationRule,
|
||||
@@ -30,17 +30,17 @@ from .processor.message_validator import (
|
||||
ValidationCache,
|
||||
ValidationStats,
|
||||
ValidationCacheEntry,
|
||||
ValidationError
|
||||
ValidationError,
|
||||
)
|
||||
from .processor.message_handler import MessageHandler
|
||||
from .processor.queue_handler import QueueHandler
|
||||
from .processor.reactions import (
|
||||
from ..processor.message_handler import MessageHandler
|
||||
from ..processor.queue_handler import QueueHandler
|
||||
from ..processor.reactions import (
|
||||
handle_archived_reaction,
|
||||
update_queue_position_reaction,
|
||||
update_progress_reaction,
|
||||
update_download_progress_reaction
|
||||
update_download_progress_reaction,
|
||||
)
|
||||
from .utils import progress_tracker
|
||||
from ..utils import progress_tracker
|
||||
|
||||
# Export public classes and constants
|
||||
__all__ = [
|
||||
@@ -48,7 +48,6 @@ __all__ = [
|
||||
"VideoProcessor",
|
||||
"MessageHandler",
|
||||
"QueueHandler",
|
||||
|
||||
# URL Extraction
|
||||
"URLExtractor",
|
||||
"URLMetadata",
|
||||
@@ -57,7 +56,6 @@ __all__ = [
|
||||
"URLPatternManager",
|
||||
"URLValidator",
|
||||
"URLMetadataExtractor",
|
||||
|
||||
# Message Validation
|
||||
"MessageValidator",
|
||||
"ValidationContext",
|
||||
@@ -68,13 +66,11 @@ __all__ = [
|
||||
"ValidationStats",
|
||||
"ValidationCacheEntry",
|
||||
"ValidationError",
|
||||
|
||||
# Constants and enums
|
||||
"REACTIONS",
|
||||
"ReactionType",
|
||||
"ReactionEmojis",
|
||||
"ProgressEmojis",
|
||||
|
||||
# Helper functions
|
||||
"get_reaction",
|
||||
"get_progress_emoji",
|
||||
@@ -87,7 +83,6 @@ __all__ = [
|
||||
"get_active_operations",
|
||||
"get_validation_stats",
|
||||
"clear_caches",
|
||||
|
||||
# Reaction handlers
|
||||
"handle_archived_reaction",
|
||||
"update_queue_position_reaction",
|
||||
@@ -104,105 +99,114 @@ __description__ = "Video processing module for archiving Discord videos"
|
||||
url_extractor = URLExtractor()
|
||||
message_validator = MessageValidator()
|
||||
|
||||
|
||||
# URL extraction helper functions
|
||||
async def extract_urls(
|
||||
message: discord.Message,
|
||||
enabled_sites: Optional[List[str]] = None
|
||||
message: discord.Message, enabled_sites: Optional[List[str]] = None
|
||||
) -> List[URLMetadata]:
|
||||
"""
|
||||
Extract video URLs from a Discord message.
|
||||
|
||||
|
||||
Args:
|
||||
message: Discord message to extract URLs from
|
||||
enabled_sites: Optional list of enabled site identifiers
|
||||
|
||||
|
||||
Returns:
|
||||
List of URLMetadata objects for extracted URLs
|
||||
"""
|
||||
return await url_extractor.extract_urls(message, enabled_sites)
|
||||
|
||||
|
||||
async def validate_message(
|
||||
message: discord.Message,
|
||||
settings: Dict[str, Any]
|
||||
message: discord.Message, settings: Dict[str, Any]
|
||||
) -> Tuple[bool, Optional[str]]:
|
||||
"""
|
||||
Validate a Discord message.
|
||||
|
||||
|
||||
Args:
|
||||
message: Discord message to validate
|
||||
settings: Guild settings dictionary
|
||||
|
||||
|
||||
Returns:
|
||||
Tuple of (is_valid, reason)
|
||||
|
||||
|
||||
Raises:
|
||||
ValidationError: If validation fails unexpectedly
|
||||
"""
|
||||
return await message_validator.validate_message(message, settings)
|
||||
|
||||
|
||||
# Progress tracking helper functions
|
||||
def update_download_progress(url: str, progress_data: Dict[str, Any]) -> None:
|
||||
"""
|
||||
Update download progress for a specific URL.
|
||||
|
||||
|
||||
Args:
|
||||
url: The URL being downloaded
|
||||
progress_data: Dictionary containing progress information
|
||||
"""
|
||||
progress_tracker.update_download_progress(url, progress_data)
|
||||
|
||||
|
||||
def complete_download(url: str) -> None:
|
||||
"""
|
||||
Mark a download as complete.
|
||||
|
||||
|
||||
Args:
|
||||
url: The URL that completed downloading
|
||||
"""
|
||||
progress_tracker.complete_download(url)
|
||||
|
||||
|
||||
def increment_download_retries(url: str) -> None:
|
||||
"""
|
||||
Increment retry count for a download.
|
||||
|
||||
|
||||
Args:
|
||||
url: The URL being retried
|
||||
"""
|
||||
progress_tracker.increment_download_retries(url)
|
||||
|
||||
def get_download_progress(url: Optional[str] = None) -> Union[Dict[str, Any], Dict[str, Dict[str, Any]]]:
|
||||
|
||||
def get_download_progress(
|
||||
url: Optional[str] = None,
|
||||
) -> Union[Dict[str, Any], Dict[str, Dict[str, Any]]]:
|
||||
"""
|
||||
Get download progress for a specific URL or all downloads.
|
||||
|
||||
|
||||
Args:
|
||||
url: Optional URL to get progress for. If None, returns all download progress.
|
||||
|
||||
|
||||
Returns:
|
||||
Dictionary containing progress information for one or all downloads
|
||||
"""
|
||||
return progress_tracker.get_download_progress(url)
|
||||
|
||||
|
||||
def get_active_operations() -> Dict[str, Dict[str, Any]]:
|
||||
"""
|
||||
Get all active operations.
|
||||
|
||||
|
||||
Returns:
|
||||
Dictionary containing information about all active operations
|
||||
"""
|
||||
return progress_tracker.get_active_operations()
|
||||
|
||||
|
||||
def get_validation_stats() -> ValidationStats:
|
||||
"""
|
||||
Get message validation statistics.
|
||||
|
||||
|
||||
Returns:
|
||||
Dictionary containing validation statistics and rule information
|
||||
"""
|
||||
return message_validator.get_stats()
|
||||
|
||||
|
||||
def clear_caches(message_id: Optional[int] = None) -> None:
|
||||
"""
|
||||
Clear URL and validation caches.
|
||||
|
||||
|
||||
Args:
|
||||
message_id: Optional message ID to clear caches for. If None, clears all caches.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user