Add manual fix / manual import services and routers
library_edit.update_track_fields: single-track tag edits via `beet modify -y -m` (subprocess with an argument list, not beets.library.Library in-process -- an arg-list subprocess has no shell-injection surface to avoid in the first place, and correctly reuses beets' own configured path-format/move logic rather than reimplementing it against a hand-built Library object with guessed config). Every changed field gets a manual_fix_audit row with old/new values; triggers a Navidrome rescan afterward if anything changed. Uses "genres" (plural) as the field name, matching this deployment's actual beets column and every existing script's convention, not the generic beets docs' singular "genre". genre_fix.set_artist_genre and retag.retag_from_url wrap the existing fix-genre.sh and fix-track-metadata.py as callable services rather than reimplementing their per-format mutagen tag-writing logic. manual_import: ties pipeline_runner.run_import_track to the manual_imports table, mirrors import-track.sh's own argument-count-based disambiguation (0/1/2 args), plus import-me/ listing and upload-with-path-traversal-guard. routers/library.py + routers/import_.py: browsable library list, a track detail/edit page (tag edit, artist-wide genre override, retag-from-URL forms), and the import page (upload + trigger). Minimal templates for now, Task 9 covers full UI polish. Verified update_track_fields end-to-end against a REAL beets library (not mocked): generated a tagged FLAC with ffmpeg/metaflac, imported it via a real `beet import`, edited artist+title through the service, and confirmed the file was physically moved to the new path-template location, tags were rewritten on disk, the DB updated, and both changes landed correctly in manual_fix_audit. Also verified the full app boots with the new routers registered and all four new routes correctly redirect to login when unauthenticated.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Library — alembic{% endblock %}
|
||||
{% block content %}
|
||||
<h1>Library{% if grouping %} — {{ grouping }}{% endif %}</h1>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Artist</th><th>Title</th><th>Album</th><th>Format</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in items %}
|
||||
<tr>
|
||||
<td>{{ item.artist }}</td>
|
||||
<td>{{ item.title }}</td>
|
||||
<td>{{ item.albumartist }}</td>
|
||||
<td>{{ item.format }}</td>
|
||||
<td><a href="/library/track/{{ item.id }}">edit</a></td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr><td colspan="5" class="muted">No tracks found{% if grouping %} for grouping "{{ grouping }}"{% endif %}.</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,38 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}{{ item.artist }} — {{ item.title }} — alembic{% endblock %}
|
||||
{% block content %}
|
||||
<p><a href="/library">← back to library</a></p>
|
||||
<h1>{{ item.artist }} — {{ item.title }}</h1>
|
||||
<p class="muted">{{ item.path }}</p>
|
||||
|
||||
{% if request.query_params.get('changed') %}
|
||||
<p>Updated {{ request.query_params.get('changed') }} field(s).</p>
|
||||
{% endif %}
|
||||
|
||||
<h2>Edit tags</h2>
|
||||
<form method="post" action="/library/track/{{ item.id }}">
|
||||
{% for field in editable_fields %}
|
||||
<div>
|
||||
<label for="{{ field }}">{{ field }}</label>
|
||||
<input type="text" id="{{ field }}" name="{{ field }}" value="{{ item.get(field, '') or '' }}">
|
||||
</div>
|
||||
{% endfor %}
|
||||
<button type="submit">Save</button>
|
||||
</form>
|
||||
|
||||
<h2>Set genre for this artist (all their tracks)</h2>
|
||||
<form method="post" action="/library/track/{{ item.id }}/genre">
|
||||
<input type="hidden" name="artist" value="{{ item.artist }}">
|
||||
<label for="genre">Genre (e.g. "IDM; Electronic")</label>
|
||||
<input type="text" id="genre" name="genre" required>
|
||||
<button type="submit">Set genre</button>
|
||||
</form>
|
||||
|
||||
<h2>Re-fetch metadata from Spotify/iTunes URL</h2>
|
||||
<form method="post" action="/library/track/{{ item.id }}/retag">
|
||||
<label for="url">URL</label>
|
||||
<input type="text" id="url" name="url" required>
|
||||
<label><input type="checkbox" name="keep_genre" value="true"> keep existing genre</label>
|
||||
<button type="submit">Retag</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user