Add debug logging for URL detection

- Added detailed logging in process_message method:
  - Log message content and attachments
  - Log guild settings and enabled sites
  - Log URL detection process for each word
  - Track queue additions and failures

This will help diagnose why URLs aren't being detected and added to the queue.
This commit is contained in:
pacnpal
2024-11-15 18:24:11 +00:00
parent 546ce5e66c
commit c012baef07

View File

@@ -181,6 +181,7 @@ class VideoProcessor:
try: try:
# Check if message contains any video URLs # Check if message contains any video URLs
if not message.content and not message.attachments: if not message.content and not message.attachments:
logger.debug(f"No content or attachments in message {message.id}")
return return
# Get guild settings # Get guild settings
@@ -189,30 +190,45 @@ class VideoProcessor:
logger.warning(f"No settings found for guild {message.guild.id}") logger.warning(f"No settings found for guild {message.guild.id}")
return return
# Log settings for debugging
logger.debug(f"Guild {message.guild.id} settings: {settings}")
# Check if channel is enabled # Check if channel is enabled
enabled_channels = settings.get("enabled_channels", []) enabled_channels = settings.get("enabled_channels", [])
if enabled_channels and message.channel.id not in enabled_channels: if enabled_channels and message.channel.id not in enabled_channels:
logger.debug(f"Channel {message.channel.id} not in enabled channels: {enabled_channels}")
return return
# Extract URLs from message content and attachments # Extract URLs from message content and attachments
urls = [] urls = []
if message.content: if message.content:
# Log message content for debugging
logger.debug(f"Processing message content: {message.content}")
logger.debug(f"Enabled sites: {settings.get('enabled_sites', [])}")
# Add URLs from message content # Add URLs from message content
for word in message.content.split(): for word in message.content.split():
if any(site in word.lower() for site in settings["enabled_sites"]): # Log each word being checked
logger.debug(f"Checking word: {word}")
if any(site in word.lower() for site in settings.get("enabled_sites", [])):
logger.debug(f"Found matching URL: {word}")
urls.append(word) urls.append(word)
# Add attachment URLs # Add attachment URLs
for attachment in message.attachments: for attachment in message.attachments:
logger.debug(f"Checking attachment: {attachment.filename}")
if any(attachment.filename.lower().endswith(ext) for ext in ['.mp4', '.mov', '.avi', '.webm']): if any(attachment.filename.lower().endswith(ext) for ext in ['.mp4', '.mov', '.avi', '.webm']):
logger.debug(f"Found video attachment: {attachment.url}")
urls.append(attachment.url) urls.append(attachment.url)
if not urls: if not urls:
logger.debug("No valid URLs found in message")
return return
# Add each URL to the queue # Add each URL to the queue
for url in urls: for url in urls:
try: try:
logger.info(f"Adding URL to queue: {url}")
await message.add_reaction(REACTIONS['queued']) await message.add_reaction(REACTIONS['queued'])
await self.queue_manager.add_to_queue( await self.queue_manager.add_to_queue(
url=url, url=url,
@@ -222,7 +238,7 @@ class VideoProcessor:
author_id=message.author.id, author_id=message.author.id,
priority=0 priority=0
) )
logger.info(f"Added video to queue: {url}") logger.info(f"Successfully added video to queue: {url}")
except QueueError as e: except QueueError as e:
logger.error(f"Failed to add video to queue: {str(e)}") logger.error(f"Failed to add video to queue: {str(e)}")
await message.add_reaction(REACTIONS['error']) await message.add_reaction(REACTIONS['error'])