Feat/auto generate edited files #2

Merged
robin merged 16 commits from feat/auto-generate-edited-files into main 2026-11-13 16:12:02 +00:00
5 changed files with 21 additions and 15 deletions
Showing only changes of commit a9ccdca62c - Show all commits

No files matched your search

+6 -5
View File
@@ -338,7 +338,6 @@ def admin_add_task(songId):
@admin_required @admin_required
def api_admin_add(): def api_admin_add():
title = request.form.get("title", "").strip() title = request.form.get("title", "").strip()
artist = request.form.get("artist", "").strip()
file = request.files.get("file") file = request.files.get("file")
if not title: if not title:
@@ -352,19 +351,20 @@ def api_admin_add():
filename_new = uuid.uuid4().hex + ext filename_new = uuid.uuid4().hex + ext
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) path = BASE_MUSIC_DIR / filename_new
file.save(path)
# read bitrate and sampling rate # read bitrate and sampling rate
audio = File(BASE_MUSIC_DIR / filename_new) audio = File(path)
#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,
"original": { "original": {
"filename": filename_new, "filename": filename_new,
"sampling_rate": audio.info.sample_rate, "sampling_rate": audio.info.sample_rate,
"bitrate": audio.info.bitrate "bitrate": audio.info.bitrate,
"size": path.stat().st_size, # Bytes
}, },
"edits": [], "edits": [],
}) })
@@ -440,6 +440,7 @@ def api_admin_add_task(songId):
"quality": quality if mode == "vbr" else None, "quality": quality if mode == "vbr" else None,
"bitrate": actual_bitrate, "bitrate": actual_bitrate,
"sampling_rate": actual_rate, "sampling_rate": actual_rate,
"size": dst.stat().st_size, # Bytes
}) })
save_songs_list(songs) save_songs_list(songs)
+5
View File
@@ -176,3 +176,8 @@ td.toggle a {
td.toggle a:hover { td.toggle a:hover {
filter: brightness(1.1); /* optional: Hover-Effekt */ filter: brightness(1.1); /* optional: Hover-Effekt */
} }
.percentage {
color: var(--muted);
font-size: small;
}
-3
View File
@@ -7,9 +7,6 @@
<label for="titel">Titel</label> <label for="titel">Titel</label>
<input id="title" name="title" type="text" autocomplete="off" required autofocus> <input id="title" name="title" type="text" autocomplete="off" required autofocus>
<label for="artist">Artist</label>
<input id="artist" name="artist" type="text" autocomplete="off">
<label for="file">Datei</label> <label for="file">Datei</label>
<div class="file-upload"> <div class="file-upload">
<input id="file" name="file" type="file" accept="audio/*,.mp3,.wav,.flac,.ogg,.m4a" required> <input id="file" name="file" type="file" accept="audio/*,.mp3,.wav,.flac,.ogg,.m4a" required>
+5 -2
View File
@@ -47,19 +47,22 @@
<th>ID</th> <th>ID</th>
<th>Bitrate (bit/s)</th> <th>Bitrate (bit/s)</th>
<th>Abtastrate (Hz)</th> <th>Abtastrate (Hz)</th>
<th>Dateigröße (MB)</th>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>Original</td> <td>Original</td>
<td>{{ song.original.bitrate }}</td> <td>{{ song.original.bitrate }}</td>
<td>{{ song.original.sampling_rate }}</td> <td>{{ song.original.sampling_rate }}</td>
<td>{{ (song.original.size / 1000000) | round(2) }}</td>
</tr> </tr>
{% if song.edits %} {% if song.edits %}
{% for e in song.edits %} {% for e in song.edits %}
<tr> <tr>
<td>{{ e.id }}</td> <td>{{ e.id }}</td>
<td>{{ e.bitrate }} ({{ (e.bitrate / song.original.bitrate * 100) | round(1) }}%) {{ e.get("mode", "cbr") | upper }}</td> <td>{{ e.bitrate }} <span class="percentage">({{ (e.bitrate / song.original.bitrate * 100) | round(1) }}%) {{ e.get("mode", "cbr") | upper }}</span></td>
<td>{{ e.sampling_rate }} ({{ (e.sampling_rate / song.original.sampling_rate * 100) | round(1) }}%)</td> <td>{{ e.sampling_rate }} <span class="percentage">({{ (e.sampling_rate / song.original.sampling_rate * 100) | round(1) }}%)</span></td>
<td>{{ (e.size / 1000000) | round(2) }} <span class="percentage">({{ (e.size / song.original.size * 100) | round(1) }}%)</span></td>
</tr> </tr>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
+5 -5
View File
@@ -16,10 +16,10 @@
<thead> <thead>
<th></th> <th></th>
<th>Name</th> <th>Name</th>
<th>Artist</th>
<th>ID</th> <th>ID</th>
<th>Bitrate (bit/s)</th> <th>Bitrate (bit/s)</th>
<th>Abtastrate (Hz)</th> <th>Abtastrate (Hz)</th>
<th>Dateigröße (MB)</th>
</thead> </thead>
<tbody> <tbody>
{% for s in songs %} {% for s in songs %}
@@ -28,10 +28,10 @@
<a href="{{ url_for('main.admin_add_task', songId=s.id) }}">+</a> <a href="{{ url_for('main.admin_add_task', songId=s.id) }}">+</a>
</td> </td>
<td>{{ s.name }}</td> <td>{{ s.name }}</td>
<td>{{ s.artist }}</td>
<td>{{ s.id }}</td> <td>{{ s.id }}</td>
<td>{{ s.original.bitrate }}</td> <td>{{ s.original.bitrate }}</td>
<td>{{ s.original.sampling_rate }}</td> <td>{{ s.original.sampling_rate }}</td>
<td>{{ (s.original.size / 1000000) | round(2) }}</td>
</tr> </tr>
{% if s.edits %} {% if s.edits %}
{% for e in s.edits %} {% for e in s.edits %}
@@ -39,9 +39,9 @@
<td></td> <td></td>
<td></td> <td></td>
<td></td> <td></td>
<td></td> <td>{{ e.bitrate }} <span class="percentage">({{ (e.bitrate / s.original.bitrate * 100) | round(1) }}%)</span></td>
<td>{{ e.bitrate }} ({{ (e.bitrate / s.original.bitrate * 100) | round(1) }}%)</td> <td>{{ e.sampling_rate }} <span class="percentage">({{ (e.sampling_rate / s.original.sampling_rate * 100) | round(1) }}%)</span></td>
<td>{{ e.sampling_rate }} ({{ (e.sampling_rate / s.original.sampling_rate * 100) | round(1) }}%)</td> <td>{{ (e.size / 1000000) | round(2) }} <span class="percentage">({{ (e.size / s.original.size * 100) | round(1) }}%)</span></td>
</tr> </tr>
{% endfor %} {% endfor %}
{% endif %} {% endif %}