diff --git a/editor.py b/editor.py index f69d604..a6c6323 100644 --- a/editor.py +++ b/editor.py @@ -134,6 +134,40 @@ def rename_file(kind, old_filename, new_filename): return new_path +def write_metadata(path, metadata): + """Rewrite only the MP3 metadata without re-encoding the audio.""" + temp = path.with_name(f".{path.name}.metadata.mp3") + values = { + "date": str(metadata.get("date", "")).strip(), + "artist": str(metadata.get("artist", "")).strip(), + "title": str(metadata.get("title", "")).strip(), + "album": str(metadata.get("album", "")).strip(), + } + cmd = [ + "ffmpeg", "-hide_banner", "-loglevel", "error", "-y", + "-i", str(path), + "-map", "0", + "-c", "copy", + "-map_metadata", "-1", + ] + for key, value in values.items(): + cmd += ["-metadata", f"{key}={value}"] + cmd.append(str(temp)) + + try: + result = subprocess.run(cmd, capture_output=True, text=True, timeout=120) + if result.returncode != 0 or not temp.is_file() or temp.stat().st_size == 0: + temp.unlink(missing_ok=True) + raise ValueError("ID3-Tags konnten nicht gespeichert werden") + temp.replace(path) + except subprocess.TimeoutExpired: + temp.unlink(missing_ok=True) + raise ValueError("Speichern der ID3-Tags hat zu lange gedauert") + except OSError as exc: + temp.unlink(missing_ok=True) + raise ValueError(f"ID3-Tags konnten nicht gespeichert werden: {exc}") + + def delete_file(kind, filename): path = path_for_kind(kind, filename) if path is None or not path.is_file(): @@ -859,6 +893,14 @@ th { color:#aaa; font-weight:normal; } .button { display:inline-block; border:0; border-radius:6px; padding:9px 13px; background:#333; color:#fff; cursor:pointer; text-decoration:none; } .button:hover { background:#444; } .empty { color:#999; padding:15px 0; } +.meta-dialog { position:fixed; inset:0; background:rgba(0,0,0,.78); display:none; align-items:center; justify-content:center; z-index:900; padding:20px; } +.meta-dialog.active { display:flex; } +.meta-card { width:min(560px,100%); background:#202020; border:1px solid #444; border-radius:10px; padding:22px; box-shadow:0 10px 40px #000; } +.meta-card h2 { margin-top:0; } +.meta-card label { display:block; margin:14px 0; color:#ccc; } +.meta-card input { display:block; width:100%; margin-top:6px; padding:10px; background:#111; color:#eee; border:1px solid #555; border-radius:5px; font-size:16px; } +.meta-actions { display:flex; gap:10px; justify-content:flex-end; margin-top:20px; } +.meta-actions button { margin:0; } .loading-overlay { position:fixed; inset:0; background:rgba(0,0,0,.78); display:none; align-items:center; justify-content:center; z-index:1000; } .loading-overlay.active { display:flex; } .spinner { width:54px; height:54px; border:5px solid #444; border-top-color:#fff; border-radius:50%; animation:spin .8s linear infinite; } @@ -910,7 +952,7 @@ th { color:#aaa; font-weight:normal; } {{ item.duration }} ▶ Abspielen / Download - + @@ -920,7 +962,82 @@ th { color:#aaa; font-weight:normal; } {% else %}
Noch keine bearbeiteten Aufnahmen vorhanden.
{% endif %} +
+
+

Bearbeitete Aufnahme ändern

+ + + + + +
+ + +
+
+
+