Restructure Settings nav, modernize import page, dedup/genres UX polish

Settings is now one top-nav entry with Credentials and Jobs as sidebar
sub-pages (jobs moved from /jobs to /settings/jobs). Manual import page
replaces the bare file input and free-text filename field with a drag-drop
dropzone and a proper file-picker table. Genres page drops the "force"
checkbox for two explicit buttons (Preview / Fix genres now). Dedup's
"Scan now" runs both the file-naming and acoustic passes together, and the
table labels which pass caught each candidate instead of showing the raw
pass name. .btn-ghost gets a visible border so it reads as a real button
next to Delete/Danger actions instead of looking unaligned. Job names
throughout the UI are now human-readable instead of raw job_key strings.

Also includes the fpcalc exit-code fix from earlier (fingerprint index
was discarding valid fingerprints on files with a benign decode warning).
This commit is contained in:
andrew
2026-07-09 10:26:40 -06:00
parent 1f733d6e91
commit b4dd2286a9
18 changed files with 315 additions and 108 deletions
+2 -1
View File
@@ -7,7 +7,7 @@ from sqlalchemy import select
from app.db import get_db
from app.models import JobRun
from app.security.deps import require_auth
from app.services import beets_service, credential_service, playlist_service
from app.services import beets_service, credential_service, playlist_service, scheduler_service
router = APIRouter(tags=["dashboard"])
templates = Jinja2Templates(directory="app/templates")
@@ -44,5 +44,6 @@ async def dashboard(request: Request, user: dict = Depends(require_auth), db=Dep
"recent_runs": recent_runs,
"recent_tracks": recent_tracks,
"auth_states": credential_service.auth_states(db),
"humanize_job_key": scheduler_service.humanize_job_key,
},
)
+16 -7
View File
@@ -14,6 +14,17 @@ templates = Jinja2Templates(directory="app/templates")
# path is still available in the title attribute on hover).
_LIBRARY_PREFIX = str(settings.music_data_dir / "Library") + "/"
# dedup-library.sh's four tag-based passes (numbered_sibling, case_insensitive,
# normalized, cross_album_fuzzy) all match on filenames/tags; find-fuzzy-dupes.py's
# one pass (fuzzy_audio) matches on acoustic fingerprint. The specific pass
# name is an implementation detail -- the table just needs to say which of
# the two matching methods caught it.
_ACOUSTIC_PASS = "fuzzy_audio"
def _pass_label(pass_name: str) -> str:
return "Acoustically Similar" if pass_name == _ACOUSTIC_PASS else "File Naming"
def _display_path(path: str) -> str:
return path[len(_LIBRARY_PREFIX):] if path.startswith(_LIBRARY_PREFIX) else path
@@ -23,6 +34,7 @@ def _to_row(c) -> dict:
return {
"id": c.id,
"pass_name": c.pass_name,
"pass_label": _pass_label(c.pass_name),
"keep_path": c.keep_path,
"delete_path": c.delete_path,
"keep_display": _display_path(c.keep_path),
@@ -42,13 +54,10 @@ async def dedup_index(request: Request, user: dict = Depends(require_auth)):
@router.post("/scan")
async def scan(user: dict = Depends(require_auth)):
await dedup_review_service.scan(triggered_by="manual")
return RedirectResponse(url="/dedup", status_code=303)
@router.post("/scan-fuzzy")
async def scan_fuzzy(user: dict = Depends(require_auth)):
await dedup_review_service.scan_fuzzy(triggered_by="manual")
# Runs both the file-naming and acoustic passes -- see
# dedup_review_service.scan_all(). The candidates table shows which
# pass caught each one instead of needing two separate buttons.
await dedup_review_service.scan_all(triggered_by="manual")
return RedirectResponse(url="/dedup", status_code=303)
+11 -2
View File
@@ -28,8 +28,17 @@ async def genres_index(request: Request, user: dict = Depends(require_auth), db=
@router.post("/scan")
async def scan(force: bool = Form(False), user: dict = Depends(require_auth)):
await genre_review_service.run(apply=False, force=force, triggered_by="manual")
async def scan(user: dict = Depends(require_auth)):
# Always force=True: matches the weekly scheduled run's own behavior
# (see genre_review_service.run's docstring), so a preview accurately
# shows what "Fix genres now" would actually do.
await genre_review_service.run(apply=False, force=True, triggered_by="manual")
return RedirectResponse(url="/genres", status_code=303)
@router.post("/apply")
async def apply(user: dict = Depends(require_auth)):
await genre_review_service.run(apply=True, force=True, triggered_by="manual")
return RedirectResponse(url="/genres", status_code=303)
+9 -4
View File
@@ -8,7 +8,7 @@ from app.models import JobRun, ScheduledJob
from app.security.deps import require_auth
from app.services import scheduler_service
router = APIRouter(prefix="/jobs", tags=["jobs"])
router = APIRouter(prefix="/settings/jobs", tags=["jobs"])
templates = Jinja2Templates(directory="app/templates")
@@ -38,6 +38,7 @@ def _job_list_context(db):
maintenance_jobs.append(
{
"job_key": job_key,
"label": scheduler_service.humanize_job_key(job_key),
"description": scheduler_service.MAINTENANCE_JOB_DESCRIPTIONS.get(job_key, ""),
"next_run": _format_next_run(next_run),
"enabled": enabled_by_key.get(job_key, True),
@@ -46,7 +47,11 @@ def _job_list_context(db):
recent_runs = list(
db.execute(select(JobRun).order_by(JobRun.started_at.desc()).limit(50)).scalars()
)
return {"maintenance_jobs": maintenance_jobs, "recent_runs": recent_runs}
return {
"maintenance_jobs": maintenance_jobs,
"recent_runs": recent_runs,
"humanize_job_key": scheduler_service.humanize_job_key,
}
@router.get("")
@@ -70,7 +75,7 @@ async def run_now(job_key: str, user: dict = Depends(require_auth)):
await scheduler_service.trigger_now(scheduler, job_key)
except ValueError as exc:
raise HTTPException(404, str(exc))
return RedirectResponse(url="/jobs", status_code=303)
return RedirectResponse(url="/settings/jobs", status_code=303)
@router.post("/{job_key:path}/toggle")
@@ -81,7 +86,7 @@ async def toggle_enabled(job_key: str, user: dict = Depends(require_auth), db=De
row = db.execute(select(ScheduledJob).where(ScheduledJob.job_key == job_key)).scalar_one_or_none()
currently_enabled = row.enabled if row else True
scheduler_service.set_maintenance_enabled(scheduler, job_key, not currently_enabled)
return RedirectResponse(url="/jobs", status_code=303)
return RedirectResponse(url="/settings/jobs", status_code=303)
@router.get("/runs/{run_id}/log", response_class=PlainTextResponse)
+9
View File
@@ -119,6 +119,15 @@ async def scan_fuzzy(triggered_by: str = "manual") -> DedupRun:
return await _run_scan("dedup:scan_fuzzy", _FUZZY_SCRIPT, triggered_by)
async def scan_all(triggered_by: str = "manual") -> tuple[DedupRun, DedupRun]:
"""Run both passes back to back for a single "Scan now" click -- each
call acquires and releases the shared pipeline lock on its own, so
running them sequentially here is safe, just one after the other."""
tag_run = await scan(triggered_by=triggered_by)
fuzzy_run = await scan_fuzzy(triggered_by=triggered_by)
return tag_run, fuzzy_run
def _write_apply_args(script_name: str, script: str, group: list[DedupCandidate], stamp: int) -> list[str]:
"""Build the --apply invocation for one pass's confirmed group.
+49
View File
@@ -178,6 +178,55 @@ MAINTENANCE_JOB_DESCRIPTIONS: dict[str, str] = {
"maintenance:upgrade_mp3_to_flac": "Look for FLAC replacements for MP3 tracks (monthly).",
}
# Display-only friendly names -- never used as the actual scheduler/DB
# identifier (job_key stays as-is everywhere else), just what the UI shows
# instead of a raw "maintenance:snake_case_key". Every job_key not listed
# here (e.g. playlist:<name>, one per playlist) falls back to
# humanize_job_key()'s generic cleanup below.
JOB_LABELS: dict[str, str] = {
"maintenance:sync_bandcamp": "Sync Bandcamp",
"maintenance:normalize_casing": "Normalize artist casing",
"maintenance:dedup": "Dedup scan",
"maintenance:gen_djmix_playlist": "Rebuild DJ-mix playlist",
"maintenance:gen_vgm_playlist": "Rebuild game-soundtrack playlist",
"maintenance:navidrome_scan": "Navidrome rescan",
"maintenance:export_laptop_playlists": "Export laptop playlists",
"maintenance:enrich_buy_url": "Look up buy links",
"maintenance:build_fingerprint_index": "Rebuild fingerprint index",
"maintenance:pipeline_status_report": "Daily status report",
"maintenance:log_rotation": "Rotate old logs",
"maintenance:strip_mb_tags": "Strip MusicBrainz tags",
"maintenance:strip_watermark_art": "Remove watermark art",
"maintenance:scrub_watermark_text": "Remove watermark text",
"maintenance:clean_sldl_index": "Clean download index",
"maintenance:clear_bad_genres": "Clear bad genre tags",
"maintenance:spotify_genre": "Refill genres from Spotify",
"maintenance:beets_update_sync": "Sync library tags",
"maintenance:upgrade_mp3_to_flac": "Upgrade MP3s to FLAC",
"dedup:scan": "Dedup scan (file naming)",
"dedup:scan_fuzzy": "Dedup scan (audio)",
"dedup:apply": "Dedup: delete confirmed",
"genre:run": "Genre refresh",
"manual:import": "Manual import",
"manual:fix_genre": "Fix genre",
"manual:navidrome_scan_after_edit": "Navidrome rescan (after edit)",
"manual:retag_from_url": "Retag from URL",
}
def humanize_job_key(job_key: str) -> str:
"""Friendly label for a job_key, for display only. Falls back to a
cleaned-up version of the key for anything not in JOB_LABELS -- covers
playlist:<name>, one per playlist, and anything added later without
needing a JOB_LABELS entry."""
if job_key in JOB_LABELS:
return JOB_LABELS[job_key]
if job_key.startswith("playlist:"):
return f"Playlist sync: {job_key.split(':', 1)[1]}"
_prefix, _, rest = job_key.partition(":")
rest = rest.replace("_", " ").strip()
return (rest[:1].upper() + rest[1:]) if rest else job_key
# Module-level singleton so other services (playlist_service, future
# routers) can reach the live scheduler without main.py threading it through
+97 -2
View File
@@ -342,8 +342,13 @@ main {
.btn-danger:hover { background: rgba(251, 113, 133, 0.18); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.78rem; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel); color: var(--fg); }
/* A fully transparent border left the pill outline invisible, so a ghost
button sitting next to a filled one (Keep both / Delete, Edit / Delete)
read as unaligned text rather than a matching pair of buttons. A
visible-but-quiet border keeps the lower-emphasis look while still
giving it the same pill shape as everything else. */
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { background: var(--panel); color: var(--fg); border-color: var(--border-strong); }
form.inline { display: inline-block; }
.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
@@ -390,6 +395,14 @@ select {
background-size: 0.85rem 0.85rem;
padding-right: 2.25rem;
}
/* The closed <select> box uses a translucent background (fine, since it
sits on top of the page). The open option list is a separate native
popup with no dark surface behind it, so that same translucent value
renders as plain white -- it needs an explicit opaque background. */
select option {
background: var(--bg-soft);
color: var(--fg);
}
.checkbox-field {
display: flex;
@@ -559,6 +572,88 @@ tbody td.actions-cell { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.cred-grid { grid-template-columns: 1fr; }
}
/* ---- settings layout (sidebar sub-nav) ---- */
.settings-layout {
display: flex;
align-items: flex-start;
gap: 2.25rem;
}
.settings-nav {
flex: 0 0 180px;
display: flex;
flex-direction: column;
gap: 0.2rem;
position: sticky;
top: 5.5rem;
}
.settings-nav a {
padding: 0.65rem 1rem;
border-radius: var(--radius-sm);
border-left: 2px solid transparent;
color: var(--muted);
font-weight: 600;
font-size: 0.9rem;
text-decoration: none !important;
transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.settings-nav a:hover { color: var(--fg); background: var(--panel); }
.settings-nav a.active {
color: var(--fg);
background: var(--panel-strong);
border-left-color: var(--iris-violet);
}
.settings-content { flex: 1; min-width: 0; }
@media (max-width: 780px) {
.settings-layout { flex-direction: column; gap: 1.25rem; }
.settings-nav {
position: static;
flex-direction: row;
flex-wrap: wrap;
width: 100%;
gap: 0.4rem;
}
.settings-nav a { border-left: none; border-radius: 999px; }
.settings-nav a.active { background: var(--gradient-holo); color: #08090d; }
}
/* ---- import dropzone ---- */
.dropzone-panel { padding: 0; overflow: hidden; }
.dropzone {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 3rem 1.5rem;
border: 1.5px dashed var(--border-strong);
border-radius: var(--radius);
margin: 0;
cursor: pointer;
text-align: center;
transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone.dragover {
border-color: var(--iris-violet);
background: rgba(167, 139, 250, 0.06);
}
.dropzone .dropzone-icon { color: var(--iris-violet); filter: drop-shadow(0 0 10px rgba(167, 139, 250, 0.4)); }
.dropzone-title { font-weight: 700; font-size: 0.98rem; color: var(--fg); }
.dropzone-hint { font-size: 0.8rem; color: var(--muted); }
.dropzone input[type="file"] {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
padding: 0;
border: none;
}
@media (max-width: 1040px) {
.topbar-inner { flex-wrap: wrap; }
.nav-pills { order: 3; width: 100%; flex-wrap: wrap; overflow: visible; row-gap: 0.3rem; }
+1 -2
View File
@@ -42,11 +42,10 @@
<a href="/" class="{{ 'active' if request.url.path == '/' else '' }}">Dashboard</a>
<a href="/playlists" class="{{ 'active' if request.url.path.startswith('/playlists') else '' }}">Playlists</a>
<a href="/library" class="{{ 'active' if request.url.path.startswith('/library') else '' }}">Library</a>
<a href="/jobs" class="{{ 'active' if request.url.path.startswith('/jobs') else '' }}">Jobs</a>
<a href="/dedup" class="{{ 'active' if request.url.path.startswith('/dedup') else '' }}">Dedup</a>
<a href="/genres" class="{{ 'active' if request.url.path.startswith('/genres') else '' }}">Genres</a>
<a href="/import" class="{{ 'active' if request.url.path.startswith('/import') else '' }}">Import</a>
<a href="/settings/credentials" class="{{ 'active' if request.url.path.startswith('/settings/credentials') else '' }}">Credentials</a>
<a href="/settings/credentials" class="{{ 'active' if request.url.path.startswith('/settings') else '' }}">Settings</a>
</nav>
{% if user %}
<div class="user-chip">
+5 -9
View File
@@ -1,12 +1,8 @@
{% extends "base.html" %}
{% block title %}Credentials — alembic{% endblock %}
{% block content %}
<div class="page-header">
<div>
<h1>Credentials</h1>
<p class="subtitle muted">Write-only: values are encrypted at rest and never sent back to the browser. Leave a field blank to keep it unchanged.</p>
</div>
</div>
{% extends "settings/_layout.html" %}
{% block settings_title %}Credentials{% endblock %}
{% block settings_content %}
<h2 style="margin-top:0;">Credentials</h2>
<p class="muted" style="margin-top:-0.75rem;">Write-only: values are encrypted at rest and never sent back to the browser. Leave a field blank to keep it unchanged.</p>
<div class="cred-grid">
{% for scope, fields in scope_fields.items() %}
+2 -2
View File
@@ -76,7 +76,7 @@
{% set status_badge = {"running": "badge-info badge-pulse", "success": "badge-success", "failed": "badge-danger", "skipped_lock": "badge-muted"} %}
{% for run in recent_runs %}
<tr>
<td>{{ run.job_key }}</td>
<td>{{ humanize_job_key(run.job_key) }}</td>
<td><span class="badge {{ status_badge.get(run.status, 'badge-muted') }}">{{ run.status }}</span></td>
<td class="muted">{{ run.triggered_by }}</td>
<td>{{ run.summary or "—" }}</td>
@@ -87,5 +87,5 @@
</tbody>
</table>
</div>
<p><a href="/jobs">See all jobs &rarr;</a></p>
<p><a href="/settings/jobs">See all jobs &rarr;</a></p>
{% endblock %}
+10 -12
View File
@@ -8,10 +8,7 @@
</div>
<div class="actions">
<form method="post" action="/dedup/scan" class="inline">
<button type="submit" class="btn btn-primary" title="Tag-based: matches on artist/title/albumartist across 4 passes">Scan now</button>
</form>
<form method="post" action="/dedup/scan-fuzzy" class="inline">
<button type="submit" class="btn" title="Acoustic fingerprint match -- catches the same recording filed under different tags">Scan for audio duplicates</button>
<button type="submit" class="btn btn-primary" title="Checks both filenames/tags and acoustic fingerprints">Scan now</button>
</form>
</div>
</div>
@@ -22,17 +19,18 @@
<div class="table-wrap scroll">
<table class="dedup-table">
<colgroup>
<col style="width:2.2rem"><col style="width:7rem"><col style="width:30%">
<col style="width:30%"><col style="width:5rem"><col style="width:9rem">
<col style="width:2.2rem"><col style="width:9.5rem"><col style="width:28%">
<col style="width:28%"><col style="width:5rem"><col style="width:9rem">
</colgroup>
<thead>
<tr><th></th><th>Pass</th><th>Keep</th><th>Delete</th><th>Size</th><th>Action</th></tr>
<tr><th></th><th>Caught by</th><th>Keep</th><th>Delete</th><th>Size</th><th>Action</th></tr>
</thead>
<tbody>
{% set pass_badge = {"File Naming": "badge-info", "Acoustically Similar": "badge-warning"} %}
{% for c in candidates %}
<tr>
<td><input type="checkbox" name="candidate_id" value="{{ c.id }}" form="bulk-delete-form"></td>
<td><span class="badge badge-info">{{ c.pass_name }}</span></td>
<td><span class="badge {{ pass_badge.get(c.pass_label, 'badge-info') }}" title="{{ c.pass_name }}">{{ c.pass_label }}</span></td>
<td class="muted mono path-cell" title="{{ c.keep_path }}">{{ c.keep_display }}</td>
<td class="mono path-cell" title="{{ c.delete_path }}">{{ c.delete_display }}</td>
<td class="muted">{{ (c.delete_size_bytes / 1024 / 1024) | round(1) if c.delete_size_bytes else '?' }} MB</td>
@@ -68,16 +66,16 @@
<div class="table-wrap scroll">
<table class="dedup-table">
<colgroup>
<col style="width:7rem"><col style="width:34%">
<col style="width:34%"><col style="width:5rem"><col style="width:7rem">
<col style="width:9.5rem"><col style="width:33%">
<col style="width:33%"><col style="width:5rem"><col style="width:7rem">
</colgroup>
<thead>
<tr><th>Pass</th><th>Keep</th><th>Delete</th><th>Size</th><th></th></tr>
<tr><th>Caught by</th><th>Keep</th><th>Delete</th><th>Size</th><th></th></tr>
</thead>
<tbody>
{% for c in ignored %}
<tr>
<td><span class="badge badge-muted">{{ c.pass_name }}</span></td>
<td><span class="badge badge-muted" title="{{ c.pass_name }}">{{ c.pass_label }}</span></td>
<td class="muted mono path-cell" title="{{ c.keep_path }}">{{ c.keep_display }}</td>
<td class="muted mono path-cell" title="{{ c.delete_path }}">{{ c.delete_display }}</td>
<td class="muted">{{ (c.delete_size_bytes / 1024 / 1024) | round(1) if c.delete_size_bytes else '?' }} MB</td>
+9 -4
View File
@@ -9,10 +9,15 @@
</div>
<div class="panel" style="max-width:560px;">
<form method="post" action="/genres/scan">
<label class="checkbox-field"><input type="checkbox" name="force" value="true"> Force (overwrite existing genres)</label>
<button type="submit" class="btn btn-primary">Preview now (dry run)</button>
</form>
<p class="muted" style="margin-top:0;">Preview shows what would change, including overwriting existing genres. Fix writes those changes for real.</p>
<div class="btn-row">
<form method="post" action="/genres/scan" class="inline">
<button type="submit" class="btn btn-ghost">Preview changes</button>
</form>
<form method="post" action="/genres/apply" class="inline">
<button type="submit" class="btn btn-primary">Fix genres now</button>
</form>
</div>
</div>
<h2>Last run</h2>
+55 -41
View File
@@ -4,60 +4,74 @@
<div class="page-header">
<div>
<h1>Manual import</h1>
<p class="subtitle muted">Drop files into <span class="mono">import-me/</span> and run them through the pipeline.</p>
<p class="subtitle muted">For anything outside the normal playlist flow: a stray download, a one-off track, a Bandcamp leftover.</p>
</div>
</div>
{% if request.query_params.get('run_id') %}
<div class="notice success">Import job started (run id {{ request.query_params.get('run_id') }}). Check the Jobs page for progress.</div>
<div class="notice success">Import started (run #{{ request.query_params.get('run_id') }}). Check <a href="/settings/jobs">Jobs</a> for progress.</div>
{% endif %}
<h2>Upload a file into import-me/</h2>
<div class="panel" style="max-width:560px;">
<form method="post" action="/import/upload" enctype="multipart/form-data">
<div class="field wide">
<input type="file" name="file" required>
</div>
<button type="submit" class="btn">Upload</button>
<div class="panel dropzone-panel" x-data="{ over: false }">
<form method="post" action="/import/upload" enctype="multipart/form-data" x-ref="uploadForm">
<label class="dropzone" :class="{ dragover: over }"
@dragover.prevent="over = true"
@dragleave.prevent="over = false"
@drop.prevent="over = false">
<svg class="dropzone-icon" width="30" height="30" viewBox="0 0 24 24" fill="none">
<path d="M12 15V4M12 4l-4 4M12 4l4 4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M4 15v3a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span class="dropzone-title">Drop a file here, or click to browse</span>
<span class="dropzone-hint">Goes straight into import-me/</span>
<input type="file" name="file" required @change="$refs.uploadForm.submit()">
</label>
</form>
</div>
<h2>Contents of import-me/</h2>
{% if contents %}
<ul class="chip-list">
{% for name in contents %}
<li>{{ name }}</li>
{% endfor %}
</ul>
{% else %}
<p class="muted">(empty)</p>
{% endif %}
<h2>Run import</h2>
<div class="panel" style="max-width:560px;">
<form method="post" action="/import/run">
<div class="field">
<label for="source">File/subdir</label>
<input type="text" id="source" name="source" list="import-contents">
<span class="hint">Blank = import everything above.</span>
<datalist id="import-contents">
{% for name in contents %}
<option value="{{ name }}">
{% endfor %}
</datalist>
</div>
<div class="field">
<label for="playlist_name">Playlist tag (optional)</label>
<select id="playlist_name" name="playlist_name">
<option value="">(none)</option>
<div class="page-header" style="margin-top:2.5rem; margin-bottom:1rem;">
<div>
<h2 style="margin:0;">Waiting to import</h2>
<p class="subtitle muted">{{ contents | length }} item{{ "s" if contents | length != 1 else "" }} in import-me/.</p>
</div>
{% if contents %}
<div class="actions">
<form method="post" action="/import/run" class="inline" style="display:flex; gap:0.6rem; align-items:center;">
<select name="playlist_name" title="Playlist tag (optional)" style="width:auto;">
<option value="">No playlist tag</option>
{% for p in playlists %}
<option value="{{ p.name }}">{{ p.name }}</option>
{% endfor %}
</select>
</div>
<button type="submit" class="btn btn-primary">Import everything</button>
</form>
</div>
{% endif %}
</div>
<button type="submit" class="btn btn-primary">Import</button>
</form>
<div class="table-wrap scroll">
<table>
<thead><tr><th>Name</th><th></th></tr></thead>
<tbody>
{% for name in contents %}
<tr>
<td class="mono">{{ name }}</td>
<td class="actions-cell">
<form method="post" action="/import/run" class="inline">
<input type="hidden" name="source" value="{{ name }}">
<button type="submit" class="btn btn-sm btn-ghost">Import this</button>
</form>
</td>
</tr>
{% else %}
<tr class="empty-row"><td colspan="2">
<div class="empty-state">
<span class="sparkle" style="position:relative; display:inline-block; margin-bottom:0.5rem;"></span>
<p class="muted" style="margin:0;">Nothing waiting. Drop a file above to get started.</p>
</div>
</td></tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
+2 -2
View File
@@ -1,11 +1,11 @@
{% set status_badge = {"running": "badge-info badge-pulse", "success": "badge-success", "failed": "badge-danger", "skipped_lock": "badge-muted"} %}
{% for run in recent_runs %}
<tr>
<td>{{ run.job_key }}</td>
<td title="{{ run.job_key }}">{{ humanize_job_key(run.job_key) }}</td>
<td><span class="badge {{ status_badge.get(run.status, 'badge-muted') }}">{{ run.status }}</span></td>
<td class="muted">{{ run.triggered_by }}</td>
<td>{{ run.summary or "" }}</td>
<td>{% if run.log_path %}<a href="/jobs/runs/{{ run.id }}/log" target="_blank" class="btn btn-sm btn-ghost">Log</a>{% endif %}</td>
<td>{% if run.log_path %}<a href="/settings/jobs/runs/{{ run.id }}/log" target="_blank" class="btn btn-sm btn-ghost">Log</a>{% endif %}</td>
</tr>
{% else %}
<tr class="empty-row"><td colspan="5" class="muted">No job runs yet.</td></tr>
+9 -16
View File
@@ -1,14 +1,7 @@
{% extends "base.html" %}
{% block title %}Jobs — alembic{% endblock %}
{% block content %}
<div class="page-header">
<div>
<h1>Jobs</h1>
<p class="subtitle muted">Maintenance runs on their own schedule, or trigger them manually here.</p>
</div>
</div>
<h2>Maintenance jobs</h2>
{% extends "settings/_layout.html" %}
{% block settings_title %}Jobs{% endblock %}
{% block settings_content %}
<h2 style="margin-top:0;">Maintenance jobs</h2>
<div class="table-wrap scroll">
<table>
<thead><tr><th>Job</th><th>Status</th><th>Next run</th><th></th></tr></thead>
@@ -16,16 +9,16 @@
{% for job in maintenance_jobs %}
<tr>
<td>
<div class="mono">{{ job.job_key }}</div>
{% if job.description %}<div class="muted" style="font-size:0.8em; margin-top:0.15rem;" title="{{ job.description }}">{{ job.description }}</div>{% endif %}
<div title="{{ job.job_key }}">{{ job.label }}</div>
{% if job.description %}<div class="muted" style="font-size:0.8em; margin-top:0.15rem;">{{ job.description }}</div>{% endif %}
</td>
<td>{% if job.enabled %}<span class="badge badge-success">enabled</span>{% else %}<span class="badge badge-muted">disabled</span>{% endif %}</td>
<td class="muted mono">{{ job.next_run }}</td>
<td class="actions-cell">
<form method="post" action="/jobs/{{ job.job_key }}/run" class="inline">
<form method="post" action="/settings/jobs/{{ job.job_key }}/run" class="inline">
<button type="submit" class="btn btn-sm">Run now</button>
</form>
<form method="post" action="/jobs/{{ job.job_key }}/toggle" class="inline">
<form method="post" action="/settings/jobs/{{ job.job_key }}/toggle" class="inline">
<button type="submit" class="btn btn-sm btn-ghost">{{ "Disable" if job.enabled else "Enable" }}</button>
</form>
</td>
@@ -40,7 +33,7 @@
<div class="table-wrap scroll">
<table>
<thead><tr><th>Job</th><th>Status</th><th>Triggered by</th><th>Summary</th><th></th></tr></thead>
<tbody id="runs-tbody" hx-get="/jobs/_runs_table" hx-trigger="every 5s" hx-swap="innerHTML">
<tbody id="runs-tbody" hx-get="/settings/jobs/_runs_table" hx-trigger="every 5s" hx-swap="innerHTML">
{% include "jobs/_runs_table.html" %}
</tbody>
</table>
+1 -1
View File
@@ -9,7 +9,7 @@
<p class="subtitle muted"><a href="{{ playlist.spotify_url }}">{{ playlist.spotify_url }}</a></p>
</div>
<div class="actions">
<form method="post" action="/jobs/playlist:{{ playlist.name }}/run" class="inline">
<form method="post" action="/settings/jobs/playlist:{{ playlist.name }}/run" class="inline">
<button type="submit" class="btn btn-primary">Run now</button>
</form>
</div>
+20
View File
@@ -0,0 +1,20 @@
{% extends "base.html" %}
{% block title %}{% block settings_title %}Settings{% endblock %} — alembic{% endblock %}
{% block content %}
<div class="page-header">
<div>
<h1>Settings</h1>
<p class="subtitle muted">Credentials and background jobs.</p>
</div>
</div>
<div class="settings-layout">
<nav class="settings-nav">
<a href="/settings/credentials" class="{{ 'active' if request.url.path.startswith('/settings/credentials') else '' }}">Credentials</a>
<a href="/settings/jobs" class="{{ 'active' if request.url.path.startswith('/settings/jobs') else '' }}">Jobs</a>
</nav>
<div class="settings-content">
{% block settings_content %}{% endblock %}
</div>
</div>
{% endblock %}
+8 -3
View File
@@ -65,7 +65,14 @@ def enumerate_library() -> list[tuple[int, str]]:
def fpcalc(host_path: str) -> tuple[int, str] | None:
"""Run fpcalc -raw on a file. Returns (duration_seconds, fingerprint_csv)."""
"""Run fpcalc -raw on a file. Returns (duration_seconds, fingerprint_csv).
fpcalc's exit code is not a reliable success signal: it exits non-zero
(commonly 3) on a benign trailing-frame decode warning -- seen a lot on
game-soundtrack rips with a slightly non-conformant tail -- while still
printing a perfectly usable FINGERPRINT line. Whether a fingerprint was
actually produced is the real signal, checked below; the exit code is
ignored entirely."""
try:
proc = subprocess.run(
["fpcalc", "-raw", host_path],
@@ -75,8 +82,6 @@ def fpcalc(host_path: str) -> tuple[int, str] | None:
)
except (subprocess.TimeoutExpired, FileNotFoundError):
return None
if proc.returncode != 0:
return None
duration = 0
fingerprint = ""
for line in proc.stdout.splitlines():