From d45d666b4e3c4b68d0eabf5efe11c16edde62a89 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sun, 23 Nov 2025 18:13:29 -0500 Subject: [PATCH] Minor fixes to greet sounds. --- bragi.py | 14 ++++++++++---- media/url.py | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/bragi.py b/bragi.py index 4e80cef..ab9dd85 100755 --- a/bragi.py +++ b/bragi.py @@ -404,7 +404,7 @@ class MumbleBot: def _play_join_sound(self, username): """Play a configured join sound for a user if bot is idle""" - self.log.debug(f"bot: _play_join_sound called for username: {username}") + self.log.info(f"bot: _play_join_sound called for username: '{username}'") # Only play if bot is idle (not currently playing music) if self.thread is not None: @@ -413,13 +413,13 @@ class MumbleBot: # Check if user has a configured join sound if not var.config.has_option('user_join_sounds', username): - self.log.debug(f"bot: No join sound configured for {username}") + self.log.info(f"bot: No join sound configured for '{username}' (available: {list(var.config.options('user_join_sounds'))})") return sound_config = var.config.get('user_join_sounds', username).strip() - self.log.debug(f"bot: Found join sound config for {username}: {sound_config}") + self.log.info(f"bot: Found join sound config for '{username}': {sound_config}") if not sound_config: - self.log.debug(f"bot: Join sound config for {username} is empty") + self.log.warning(f"bot: Join sound config for {username} is empty") return try: @@ -428,6 +428,7 @@ class MumbleBot: # It's a URL self.log.info(f'bot: Playing join sound URL for {username}: {sound_config}') music_wrapper = get_cached_wrapper_from_scrap(type='url', url=sound_config, user='system') + self.log.info(f'bot: Successfully created music wrapper for {username}') else: # It's a file path - search database for first match matches = var.music_db.query_music(Condition() @@ -440,12 +441,17 @@ class MumbleBot: # Use first match self.log.info(f'bot: Playing join sound file for {username}: {matches[0]["path"]}') music_wrapper = get_cached_wrapper_from_dict(matches[0], 'system') + self.log.info(f'bot: Successfully created music wrapper for {username}') # Add to playlist + self.log.info(f'bot: Adding join sound to playlist for {username}, playlist length before: {len(var.playlist)}') var.playlist.append(music_wrapper) + self.log.info(f'bot: Join sound added to playlist for {username}, playlist length after: {len(var.playlist)}') except Exception as e: self.log.error(f'bot: Error playing join sound for {username}: {e}') + import traceback + self.log.error(f'bot: Traceback: {traceback.format_exc()}') def users_changed(self, user, message): self.log.info(f"bot: users_changed called - user: {user.get('name', 'unknown')}, message type: {type(message)}, message: {message}") diff --git a/media/url.py b/media/url.py index 69bd45b..384b554 100644 --- a/media/url.py +++ b/media/url.py @@ -130,6 +130,21 @@ class URLItem(BaseItem): return True def _get_info_from_url(self): + # Check if it's a direct audio file URL (common extensions) + direct_audio_extensions = ('.mp3', '.wav', '.ogg', '.opus', '.flac', '.m4a', '.aac') + url_lower = self.url.lower() + is_direct_audio = any(url_lower.endswith(ext) for ext in direct_audio_extensions) + + if is_direct_audio: + # For direct audio files, set minimal metadata and skip yt-dlp + self.log.info("url: detected direct audio file, skipping metadata fetch: %s" % self.url) + self.duration = 0 # Unknown duration for direct files + # Extract filename from URL for title + filename = self.url.split('/')[-1].split('?')[0] # Remove query params + self.title = filename + self.keywords = filename + return True + self.log.info("url: fetching metadata of url %s " % self.url) ydl_opts = { 'noplaylist': True