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