From 47389fb0a786fe03f9a1354d4c74a26d276baf1f Mon Sep 17 00:00:00 2001 From: Robin Schanbacher Date: Fri, 13 Nov 2026 12:59:53 +0100 Subject: [PATCH] feat: write bitrate and sampling rate into songs.json --- routes.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/routes.py b/routes.py index ea81ae7..4e09814 100644 --- a/routes.py +++ b/routes.py @@ -14,6 +14,7 @@ from functools import wraps from db import init_db, get_db, close_db, create_participant, now from datetime import datetime, timezone import threading +from mutagen import File bp = Blueprint("main", __name__) @@ -341,11 +342,19 @@ def api_admin_add(): BASE_MUSIC_DIR.mkdir(parents=True, exist_ok=True) file.save(BASE_MUSIC_DIR / filename_new) + # read bitrate and sampling rate + audio = File(BASE_MUSIC_DIR / filename_new) + print(audio.info.bitrate) + #stem = os.path.splitext(filename_new)[0] song = add_song({ "name": title, "artist": artist, - "original": {"filename": filename_new}, + "original": { + "filename": filename_new, + "sampling_rate": audio.info.sample_rate, + "bitrate": audio.info.bitrate + }, "edits": [], })