feat: write bitrate and sampling rate into songs.json

This commit is contained in:
robin committed 2026-11-13 12:59:53 +01:00
1 parent ec510b5980
commit 47389fb0a7
1 file changed
+10 -1
+10 -1
View File
@@ -14,6 +14,7 @@ from functools import wraps
from db import init_db, get_db, close_db, create_participant, now from db import init_db, get_db, close_db, create_participant, now
from datetime import datetime, timezone from datetime import datetime, timezone
import threading import threading
from mutagen import File
bp = Blueprint("main", __name__) bp = Blueprint("main", __name__)
@@ -341,11 +342,19 @@ def api_admin_add():
BASE_MUSIC_DIR.mkdir(parents=True, exist_ok=True) BASE_MUSIC_DIR.mkdir(parents=True, exist_ok=True)
file.save(BASE_MUSIC_DIR / filename_new) 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] #stem = os.path.splitext(filename_new)[0]
song = add_song({ song = add_song({
"name": title, "name": title,
"artist": artist, "artist": artist,
"original": {"filename": filename_new}, "original": {
"filename": filename_new,
"sampling_rate": audio.info.sample_rate,
"bitrate": audio.info.bitrate
},
"edits": [], "edits": [],
}) })