feat: Add VLC service for sound playback and management

- Implemented VLCService to handle sound playback using VLC.
- Added routes for soundboard management including play, stop, and status.
- Introduced admin routes for sound normalization and scanning.
- Updated user model and services to accommodate new functionalities.
- Enhanced error handling and logging throughout the application.
- Updated dependencies to include python-vlc for sound playback capabilities.
This commit is contained in:
JSC
2025-07-03 21:25:50 +02:00
parent 8f17dd730a
commit 7455811860
20 changed files with 760 additions and 91 deletions

View File

@@ -83,7 +83,9 @@ class SoundScannerService:
files_added += 1
logger.debug(f"Added sound: {filename}")
elif result.get("updated"):
files_added += 1 # Count updates as additions for reporting
files_added += (
1 # Count updates as additions for reporting
)
logger.debug(f"Updated sound: {filename}")
else:
files_skipped += 1
@@ -171,7 +173,7 @@ class SoundScannerService:
# Remove normalized files and clear normalized info
SoundScannerService._clear_normalized_files(existing_filename_sound)
existing_filename_sound.clear_normalized_info()
# Update existing sound with new file information
existing_filename_sound.update_file_info(
filename=str(relative_path),
@@ -179,7 +181,7 @@ class SoundScannerService:
size=metadata["size"],
hash_value=file_hash,
)
return {
"added": False,
"updated": True,
@@ -233,15 +235,22 @@ class SoundScannerService:
"""Remove normalized files for a sound if they exist."""
if sound.is_normalized and sound.normalized_filename:
# Import here to avoid circular imports
from app.services.sound_normalizer_service import SoundNormalizerService
normalized_path = Path(SoundNormalizerService.NORMALIZED_DIR) / sound.normalized_filename
from app.services.sound_normalizer_service import (
SoundNormalizerService,
)
normalized_path = (
Path(SoundNormalizerService.NORMALIZED_DIR)
/ sound.normalized_filename
)
if normalized_path.exists():
try:
normalized_path.unlink()
logger.info(f"Removed normalized file: {normalized_path}")
except Exception as e:
logger.warning(f"Could not remove normalized file {normalized_path}: {e}")
logger.warning(
f"Could not remove normalized file {normalized_path}: {e}"
)
@staticmethod
def _extract_audio_metadata(file_path: str) -> dict: