feat: write bitrate and sampling rate into songs.json
This commit is contained in:
1 parent
ec510b5980
commit
47389fb0a7
1 file changed
+10
-1
@@ -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": [],
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user