Minor fixes to greet sounds.
This commit is contained in:
14
bragi.py
14
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}")
|
||||
|
||||
15
media/url.py
15
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
|
||||
|
||||
Reference in New Issue
Block a user