Commit Graph

416 Commits

Author SHA1 Message Date
pacnpal
45492d7ee4 fixes 2024-11-15 17:59:26 +00:00
pacnpal
2bf85b532b Adding robust datetime handling in _periodic_cleanup:
Added try-except blocks around individual item processing
Added proper string to datetime conversion with fallbacks
Added cleanup of problematic items that can't be processed
Improved error handling:

Added specific error logging for individual item failures
Added graceful removal of problematic items
Ensured cleanup continues even if some items fail
Added fallback mechanisms:

Uses current_time as fallback for invalid datetime values
Removes items that can't be properly processed
Prevents single item failures from breaking the entire cleanup process
2024-11-15 17:35:14 +00:00
pacnpal
39169b3edb Fixed the TypeError in _periodic_cleanup by adding runtime type checking and conversion:
Added checks to ensure added_at is always a datetime object before comparison
Converts string timestamps to datetime objects when needed
Implemented proper datetime serialization/deserialization in QueueItem:

to_dict method properly converts datetime objects to ISO format strings
from_dict method properly converts ISO format strings back to datetime objects
Added datetime handling for all datetime fields:

added_at
last_retry
last_error_time
2024-11-15 17:32:12 +00:00
pacnpal
285e64db21 The "AttributeError: 'VideoProcessor' object has no attribute 'process_message'" error has been fixed by implementing the process_message method in the VideoProcessor class. This method now properly handles video processing requests from Discord messages.
The "TypeError: '<' not supported between instances of 'str' and 'datetime.datetime'" error has been fixed by implementing proper datetime handling in the QueueItem class. The added to_dict and from_dict methods ensure that datetime objects are correctly serialized and deserialized when saving and loading queue state.
2024-11-15 17:25:45 +00:00
pacnpal
56b4711661 fixes 2024-11-15 16:51:12 +00:00
pacnpal
e66af6e844 Added timeout handling and force cleanup in VideoArchiver cog
Added proper cancellation and requeuing of downloads in VideoProcessor
Added cancellable logger and process cleanup in VideoDownloader
Added shutdown flag and force_stop capability in EnhancedQueueManager
Added process tracking and kill_all_processes method in FFmpegManager
The changes ensure that:

Active downloads are paused and requeued when unload is called
If cleanup takes too long, force cleanup kicks in
All resources are properly cleaned up, even in case of timeout
Downloads can be safely cancelled and resumed later
No processes are left hanging during unload
2024-11-15 15:48:03 +00:00
pacnpal
74bd55c3e9 Enhanced Download Progress Tracking:
Track download speed, ETA, and bytes downloaded/total
Monitor fragment downloads and retry counts
Track video metadata (title, format, resolution, FPS)
Store extractor information and video details
Add timestamps for all progress updates
Detailed Compression Progress:
Track input/output file sizes and compression ratio
Monitor codec usage and hardware acceleration status
Track compression parameters (preset, CRF, bitrates)
Monitor elapsed time and estimated completion
Track audio codec and bitrate information
Queue Management Improvements:
Added global progress tracking dictionaries
Maintain active status of downloads and compressions
Track start times and last update timestamps
Store detailed error information when failures occur
Command Access:
Added queuedetails command for bot owners
Display comprehensive progress information
Show active downloads and compressions
Display detailed error statistics
Show hardware acceleration usage
2024-11-15 14:58:44 +00:00
pacnpal
cc3fa06d00 Add detailed progress tracking for downloads and compression:
- Add detailed download progress hook with extensive metadata
- Add comprehensive compression progress tracking
- Track download speed, ETA, file sizes, and formats
- Track compression codec, hardware acceleration, and bitrates
- Add timestamps for all progress updates
2024-11-15 14:58:30 +00:00
pacnpal
b8d6eb957c Improve queue persistence across cog reloads:
- Add global queue manager instance
- Modify initialization to use existing queue manager
- Add get_queue_manager() class method
- Prevent queue manager cleanup during reloads
2024-11-15 14:46:55 +00:00
pacnpal
90a3090379 Improve video download stability and progress tracking:
- Increase retries and retry delay
- Reduce concurrent downloads for better stability
- Add exponential backoff with jitter
- Improve progress logging and error handling
- Add file size limits and timeouts
- Optimize chunk size and socket timeout
2024-11-15 14:44:21 +00:00
pacnpal
245710e4d4 Added explicit import of CommandAlreadyRegistered exception
Wrapped the command registration in a try-except block
Silently continues if the command is already registered
Maintains all other functionality including cog loading and task initialization
2024-11-15 14:32:33 +00:00
pacnpal
172fe83288 Added a command existence check using discord.utils.get()
Only register the command if it's not already present
Maintained all other functionality including cog loading and task initialization
2024-11-15 14:30:50 +00:00
pacnpal
23fac11cfd Initial state: 📹 (video camera) when video is queued
Queue position: 1️⃣-5️⃣ showing position in queue
Download progress: 0️⃣2️⃣4️⃣6️⃣8️⃣🔟 showing download percentage (0%, 20%, 40%, 60%, 80%, 100%)
Processing state: ⚙️ when video is being processed
Compression progress: 🟨🟩 showing FFmpeg progress (0%, 50%, 100%)
Final state:  for success or  for failure
All status changes are now logged with message IDs for better tracking:

Queue position updates
Download progress at 20% intervals
Processing state changes
Compression progress
Success/failure states
Error conditions with detailed messages
2024-11-15 14:27:20 +00:00
pacnpal
c46e967378 Appears in the context menu when right-clicking a user
Checks for proper permissions
Removes the birthday role if present
Cancels any scheduled role removal tasks
Provides appropriate feedback and error handling
Logs all actions for debugging purposes
2024-11-15 14:19:30 +00:00
pacnpal
807422e160 Added proper exception handling for all try blocks that were missing except/finally clauses
Fixed the unclosed parenthesis in the format_message() call
Completed the message formatting section with proper parameters
Reorganized the code structure for better maintainability
Ensured proper error handling and cleanup throughout
2024-11-15 14:14:57 +00:00
pacnpal
f8d383a55a 📥 Pending: Shows items waiting to be processed
⚙️ Processing: Shows items currently being processed
 Completed: Shows successfully processed items
 Failed: Shows failed items
2024-11-15 14:12:43 +00:00
pacnpal
0d7b1d449f Made secure_delete_file and cleanup_downloads async in file_ops.py
Added chunked file processing and size limits to prevent blocking
Updated video_downloader.py to properly await secure_delete_file
Updated video_archiver.py to properly await cleanup_downloads
Simplified the secure deletion process while maintaining security
Added proper error handling and logging throughout
2024-11-15 13:47:28 +00:00
pacnpal
0194142c56 New Command:
Added /removebirthday command to manually remove birthday roles from users
Includes permission checks and proper error handling
Cleans up any scheduled tasks for the user
Enhanced Error Handling:

Added comprehensive try/except blocks throughout the cog
Added detailed logging for all operations and errors
Better handling of Discord API errors
Improved error messages for users
Improved Role Removal:

Added hourly cleanup task to ensure role removals are processed
Better handling of timezone issues
Proper cleanup of tasks when cog is unloaded
Improved task management to prevent memory leaks
Better Logging:

Added detailed logging for all operations
Logs include guild IDs, member IDs, and error details
Helps track issues and debug problems
2024-11-15 13:40:28 +00:00
pacnpal
b4479c951b Fixed Discord Integration:
Added missing discord import
Added proper error handling for all discord operations
Improved error reporting for discord-specific failures
Enhanced Error Handling:
Added try/except blocks around all major operations
Implemented proper cleanup in finally blocks
Added more specific error messages for debugging
Queue Processing Improvements:
Ensured the queue continues processing even if individual items fail
Added better file cleanup to prevent resource leaks
Improved error reporting to help diagnose issues
Resource Management:
Added proper cleanup of downloaded files
Improved handling of missing discord resources
Better management of failed downloads
2024-11-15 13:36:26 +00:00
pacnpal
887547473c Added proper physical GPU detection on Linux/Windows/macOS
Separated physical GPU detection from FFmpeg encoder support
Only enable GPU encoding when both physical GPU and FFmpeg support exist
Added multiple detection methods for better reliability
2024-11-15 05:26:10 +00:00
pacnpal
8e581d660e Fixed NVENC preset compatibility
Added proper NVENC preset validation
Separated CPU and GPU presets
Added preset conversion logic for GPU encoding
2024-11-15 05:22:38 +00:00
pacnpal
f8fe409cdd Architecture Changes:
Moved FFmpeg manager to cog level instead of per-guild
Created single shared FFmpeg manager instance in VideoArchiver class
Passed shared FFmpeg manager to VideoProcessor and VideoDownloader
Removed redundant FFmpeg downloads for each guild
Component Management:

Updated VideoArchiver to initialize one FFmpeg manager
Modified guild components to remove FFmpeg manager
Updated component cleanup to handle shared resources
Improved resource initialization order
Resource Efficiency:

Eliminated duplicate FFmpeg binary downloads
Reduced disk space usage
Improved initialization time
Better resource sharing across guilds
Error Handling:

Added proper cleanup for shared resources
Improved error propagation
Enhanced initialization error handling
Better component lifecycle management
2024-11-15 05:17:21 +00:00
pacnpal
06fcf55d90 Encoding Parameters:
Added minimum video bitrate (500 Kbps) to prevent quality degradation
Fixed audio bitrate calculation with proper min/max per channel
Added standard audio sample rate (48 kHz)
Improved bitrate allocation between video and audio
2024-11-15 05:10:59 +00:00
pacnpal
5e8f3c8b98 fix urls 2024-11-15 05:03:24 +00:00
pacnpal
2d92a3dca0 FFmpeg Binary Management:
Fixed tar.xz extraction by separating decompression and extraction steps
Added proper error handling for archive operations
Improved binary verification process
Enhanced cleanup of temporary files
Exception Handling:

Added missing exceptions to utils/exceptions.py
Fixed exception imports in exceptions.py
Added proper error types for all operations
Improved error messages and context
URL Processing:

Added pre-filtering for URLs before yt-dlp checks
Added common video platform patterns
Reduced error logging noise
Improved URL validation efficiency
Code Organization:

Centralized exceptions in utils/exceptions.py
Proper re-exports in exceptions.py
Consistent error handling across components
Better file operation handling
2024-11-15 05:00:47 +00:00
pacnpal
4e8eb38ab7 Exception Hierarchy:
Added missing exceptions to utils/exceptions.py:
ResourceExhaustedError
ProcessingError
CleanupError
FileOperationError
Fixed exception imports in exceptions.py
Added proper re-exports of all exceptions
Maintained backward compatibility aliases
URL Processing:

Added pre-filtering for URLs before yt-dlp checks
Added common video platform patterns
Reduced error logging noise
Improved URL validation efficiency
Error Handling:

Added proper error types for all operations
Enhanced error messages with context
Added resource exhaustion checks
Improved error propagation
Code Organization:

Centralized exceptions in utils/exceptions.py
Proper re-exports in exceptions.py
Consistent error handling across components
Better error type hierarchy
2024-11-15 04:57:19 +00:00
pacnpal
074b6b246b Exception Handling:
Added DiscordAPIError to utils/exceptions.py
Fixed exception imports in config_manager.py
Ensured consistent exception hierarchy
Improved error messages and context
URL Processing:

Added pre-filtering for URLs before yt-dlp checks
Added common video platform patterns
Reduced error logging noise
Improved URL validation efficiency
FFmpeg Management:

Enhanced FFmpeg binary verification
Added robust subprocess handling
Improved cleanup of failed operations
Added detailed logging
Configuration:

Fixed ConfigurationError import
Improved error handling in config operations
Enhanced channel validation
Better error propagation
2024-11-15 04:54:35 +00:00
pacnpal
7e9e193178 URL Processing:
Added URL pre-filtering to avoid unnecessary yt-dlp checks
Added common video platform patterns for quick filtering
Reduced error logging noise from non-URL words
Improved URL validation efficiency
FFmpeg Management:

Enhanced FFmpeg binary verification
Added robust error handling for subprocess calls
Improved cleanup of failed operations
Added detailed logging for binary operations
Error Handling:

Fixed exception hierarchy in utils/exceptions.py
Added proper error types for different failure scenarios
Enhanced error messages with more context
Improved error propagation through the system
Process Flow:

Added proper timeout handling for subprocess calls
Enhanced environment variable handling
Better cleanup after failures
Added retry mechanisms for failed operations
2024-11-15 04:51:17 +00:00
pacnpal
9dc3ef247c Exception Hierarchy:
Created proper exception hierarchy in utils/exceptions.py
Fixed circular imports in utils/init.py
Ensured consistent exception imports across all files
Properly aliased FFmpeg exceptions to avoid naming conflicts
Import Fixes:

Updated processor.py to use VerificationError from ffmpeg.exceptions
Fixed video_downloader.py to use correct exception imports
Created root exceptions.py for better organization
Ensured consistent exception usage across the codebase
Error Handling:

Improved error propagation through the system
Better error messages for different failure types
Enhanced cleanup on errors
More detailed logging of error conditions
FFmpeg Integration:

Fixed FFmpeg binary verification
Better error handling for FFmpeg operations
Improved cleanup of failed operations
Enhanced logging of FFmpeg-related errors
2024-11-15 04:39:58 +00:00
pacnpal
e4429a9d9e Fixed Exception Structure:
Added FileCleanupError to utils/exceptions.py
Created root exceptions.py for better organization
Fixed circular imports in utils/init.py
Updated imports in video_archiver.py and update_checker.py
Fixed FFmpeg Management:

Updated extraction logic for BtbN's new archive structure
Added fallback for backward compatibility
Better binary verification and permissions handling
Improved Error Handling:

Proper exception hierarchy
Better error propagation
More detailed error messages
Enhanced cleanup on errors
2024-11-15 04:34:35 +00:00
pacnpal
767f1140d1 Fixed FFmpeg Management:
Updated extraction logic to handle BtbN's new archive structure with binaries in bin directory
Added fallback to old structure for backward compatibility
Improved binary verification and permissions handling
Enhanced error handling during extraction and verification
Fixed Exception Handling:

Added missing FileCleanupError exception
Updated file operations to use proper exceptions
Improved error propagation and logging
Better cleanup error handling
Improved Resource Management:

Better cleanup of failed downloads
Proper handling of temporary files
Enhanced queue management
Improved file deletion with retries
Enhanced Error Reporting:

More detailed error messages
Better logging of cleanup operations
Proper error propagation through the system
Improved user feedback
The system now:

Properly handles FFmpeg's new archive structure
Better manages file operations and cleanup
Provides more detailed error messages
Cleans up resources properly
Shows appropriate error messages for different failure types
2024-11-15 04:30:03 +00:00
pacnpal
9824469984 FFmpeg Management:
Updated extraction logic to handle BtbN's new archive structure with binaries in the bin directory
Added fallback to old structure for backward compatibility
Improved binary verification and permissions handling
Enhanced error handling during extraction and verification
Error Handling:

Added specific exception types for different errors
Better error propagation through the system
Improved error logging and user feedback
Enhanced cleanup on errors
Resource Management:

Better cleanup of failed downloads
Proper handling of temporary files
Enhanced queue management
Improved file deletion with retries
Verification:

FFmpeg binary verification with version checks
Video file integrity verification
Compression result verification
Archive structure verification
The system now:

Properly handles FFmpeg's new archive structure
Better manages binary downloads and verification
Provides more detailed error messages
Cleans up resources properly
Shows appropriate reactions for different error types
2024-11-15 04:20:17 +00:00
pacnpal
c144fb35ba The video downloading issues have been resolved by implementing comprehensive error handling and resource management:
FFmpeg is now properly managed:

Binaries are downloaded and verified on startup
Permissions are properly set
Hardware acceleration is detected and used when available
Resources are cleaned up properly
Error handling has been improved:

Specific exception types for different errors
Better error messages and logging
Appropriate reaction indicators
Enhanced component error handling
Resource management has been enhanced:

Failed downloads are tracked and cleaned up
Temporary files are handled properly
Queue management is more robust
Concurrent downloads are better managed
Verification has been strengthened:

FFmpeg binaries are verified
Video files are validated
Compression results are checked
Component initialization is verified
2024-11-15 04:18:57 +00:00
pacnpal
02966f1a66 Fixed FFmpeg/FFprobe Integration:
Added proper ffprobe binary download alongside FFmpeg
Added proper path handling for both binaries
Added verification of both binaries
Fixed FFmpeg compression by using subprocess directly instead of ffmpeg-python
Improved URL Detection:

Switched from regex patterns to yt-dlp simulation for URL detection
Added better error handling for URL checking
Added detailed logging of URL detection results
Reduced Logging Noise:

Only log when a message contains a video URL
Only log URL check errors for actual URLs (containing http://, https://, or www.)
Removed unnecessary debug logging
2024-11-15 03:54:42 +00:00
pacnpal
46af1a31b7 Enhanced FFmpeg Integration:
Added robust error handling and logging
Improved binary verification and initialization
Added proper GPU detection and hardware acceleration
Optimized encoding parameters for different content types
Improved File Operations:

Added retry mechanisms for file operations
Enhanced temporary directory management
Improved cleanup of failed downloads
Added proper permission handling
Enhanced Queue Management:

Fixed queue manager initialization
Added better error recovery
Improved status tracking and logging
Enhanced cleanup of failed items
Better Error Handling:

Added comprehensive exception hierarchy
Improved error logging and reporting
Added fallback mechanisms for failures
Enhanced error recovery strategies
2024-11-15 03:48:56 +00:00
pacnpal
3e50faec75 Switching from regex patterns to yt-dlp simulation for URL detection:
Removed the regex-based URL detection
Added proper yt-dlp simulation to check if URLs are supported
Added better error handling for URL checking
Added detailed logging of URL detection results
Improving FFmpeg integration:

Added proper ffprobe binary download alongside FFmpeg
Added better verification of both binaries
Added retry mechanisms for binary downloads
Added proper cleanup of failed downloads
Enhancing error handling and logging:

Added detailed logging throughout the system
Added better error recovery mechanisms
Added proper cleanup of temporary files
Added better tracking of failed operations
2024-11-15 03:40:53 +00:00
pacnpal
8503fc6fdd Enhanced FFmpeg Integration:
Added robust error handling and logging
Improved binary verification and initialization
Added proper GPU detection and hardware acceleration
Optimized encoding parameters for different content types
Improved File Operations:

Added retry mechanisms for file operations
Enhanced temporary directory management
Improved cleanup of failed downloads
Added proper permission handling
Enhanced Queue Management:

Fixed queue manager initialization
Added better error recovery
Improved status tracking and logging
Enhanced cleanup of failed items
Better Error Handling:

Added comprehensive exception hierarchy
Improved error logging and reporting
Added fallback mechanisms for failures
Enhanced error recovery strategies
2024-11-15 03:21:25 +00:00
pacnpal
a04c576e0a logging 2024-11-15 02:59:16 +00:00
pacnpal
5a356f4824 logging 2024-11-15 02:54:09 +00:00
pacnpal
f943503f54 logging 2024-11-15 02:51:20 +00:00
pacnpal
8fcdec7550 lol 2024-11-15 02:48:05 +00:00
pacnpal
6f0f31944f enhanced 2024-11-15 02:38:22 +00:00
pacnpal
49c844a422 changes config settings for defaults 2024-11-15 02:26:51 +00:00
pacnpal
a72e4118e3 l 2024-11-15 02:22:29 +00:00
pacnpal
403b208abd what 2024-11-15 02:18:49 +00:00
pacnpal
a16b1ea7a4 fix: Change URL extraction in processor to use regex
- Replaced extractor.suitable() with direct regex pattern matching
- Added check for _VALID_URL attribute
- Improved error handling in URL extraction
- Maintains compatibility with video_downloader.py changes
2024-11-15 02:13:37 +00:00
pacnpal
1b64991041 fix: Change URL extraction in processor to use regex
- Replaced extractor.suitable() with direct regex pattern matching
- Added check for _VALID_URL attribute
- Improved error handling in URL extraction
- Maintains compatibility with video_downloader.py changes
2024-11-15 02:03:23 +00:00
pacnpal
0a46cee479 fix: Change URL validation to use regex patterns
- Replaced extractor.suitable() with direct regex pattern matching
- Store both pattern and site name for better debugging
- Added debug logging for URL matching
- Improved error handling
2024-11-15 01:59:03 +00:00
pacnpal
63664e3c94 fix: URL extraction error in is_supported_url method
- Fixed 'str' object has no attribute 'suitable' error
- Now properly instantiating extractors before calling suitable()
- Improved error handling in URL validation
2024-11-15 01:50:19 +00:00
pacnpal
7e4b33dd55 refactor: Convert commands to unique hybrid commands
- Reorganized commands into logical groups with unique prefixes:
  - va_: Core video archiver commands
  - vaq_: Queue management commands
  - vac_: Channel configuration commands
  - var_: Role management commands
  - vas_: Site management commands
- Updated all commands to be hybrid commands
- Updated README to reflect new command structure
- Maintained all existing functionality and parameters
2024-11-15 01:47:57 +00:00