Implemented export creation UI

This commit is contained in:
patben8 committed 2026-09-23 15:04:53 +02:00
1 parent 805b95fe5e
commit 7160fa3978
9 files changed
+787 -17

No files matched your search

+19
View File
@@ -463,6 +463,25 @@ def export_tracks(set_id: str) -> list[Track]:
return [t for t in (adapter.track(tid) for tid in resolved.track_ids) if t is not None]
@app.get("/api/exports/{set_id}/loose", response_model=list[Track])
def export_loose_tracks(set_id: str) -> list[Track]:
"""Only the LOOSE tracks — the ones added individually.
A separate route rather than a filter on the root view, because the two are
genuinely different questions: the root is everything this export would ship
(playlists included, deduped), and this is the "Other" bucket that becomes
its own playlist in the exported library. A track added loosely AND supplied
by a referenced playlist appears in both, which is honest — it is in the
loose list, and that is what the count beside "Other" reports.
"""
found = _require_set(set_id)
adapter = require_adapter()
resolved = exports.resolve(adapter, found)
return [
t for t in (adapter.track(tid) for tid in resolved.loose_track_ids) if t is not None
]
@app.get("/api/exports/{set_id}/playlists/{playlist_id}/tracks", response_model=list[Track])
def export_playlist_tracks(set_id: str, playlist_id: str) -> list[Track]:
"""One included playlist, as it stands now.
+13
View File
@@ -106,6 +106,19 @@ check("the total is the union, not the sum",
len(deduped) == len(set(deduped)) and len(deduped) >= len(playlist_tracks))
exports.remove(LIB, s1.id, track_ids=[playlist_tracks[0]])
# The bug this replaced: the "Other" row selected the export ROOT, so clicking
# it showed every track the export would ship instead of only the loose ones.
# Three views, three genuinely different questions.
loose_view = exports.resolve(adapter, exports.get(LIB, s1.id)).loose_track_ids
root_view = exports.resolve(adapter, exports.get(LIB, s1.id)).track_ids
check("Other holds only the individually-added tracks",
loose_view == exports.get(LIB, s1.id).track_ids, loose_view)
check("which is NOT the same as the root view",
loose_view != root_view and set(loose_view) < set(root_view),
f"{len(loose_view)} vs {len(root_view)}")
check("and the playlist's tracks are absent from it",
not (set(loose_view) & set(playlist_tracks)))
print("== what is gone is SURFACED, never silently dropped ==")
exports.add(LIB, s1.id, track_ids=["Macintosh HD/:nowhere/:ghost.mp3"])
gone = exports.resolve(adapter, exports.get(LIB, s1.id))