Skip to content

v0.5.0 — share a track: the file and its metadata

Choose a tag to compare

@PortableDiag PortableDiag released this 13 Sep 18:41
· 8 commits to main since this release

Share

A Share button under the song title, beside the star strip — and the same three actions on a right-click of any row in the list.

Copy file the audio file itself on the clipboard, and the metadata as text, from the same copy
Copy details just the metadata, as text
Save a copy… the audio file into a folder you choose, with a readable .txt of the details beside it

One clipboard, several representations — that is the part that makes the button useful rather than decorative. Paste into Telegram, Discord or a file manager and it takes text/uri-list: you get the actual audio file. Paste into a text field and it takes text/plain: you get the metadata. Offering only one of those makes the button work in half the places somebody would press it.

The third payload, x-special/gnome-copied-files, is what GTK and Nautilus-derived file managers look for, and its copy prefix is what distinguishes a copy from a cut — without it, a paste can move your music out of your library.

Save a copy never overwrites. A clashing name gets (2), (3) and so on, and the audio and its metadata take the same suffix so the pair cannot be split up.

The metadata is plain text with aligned labels rather than JSON — a person is meant to read it — and empty fields are left out rather than printed as blank headings, so sharing an untagged file is not a column of empty labels.

POST /api/share — and it shares fully

The clipboard belongs to the running application, so an API caller gets the same clipboard the button would have set, not a lesser version of the feature.

curl -s -X POST -H "Authorization: Bearer $KEY" \
     -d '{"index":6,"mode":"clipboard"}' "$BASE/api/share"

mode: clipboard for the file and its details · mode: details for the text · dest for a copy on disk · neither for a description of what you would be sharing. An unknown mode is a 400, not a guess.

The first draft of this endpoint left the clipboard out because it was awkward to express over HTTP — which is exactly the reasoning that hollows an API out. The API does everything the window does is an invariant here.

Verification

verify-api.sh 44 → 55 and verify-input.sh 9 → 13, both reading the clipboard back off the X server rather than trusting that the call returned.

cargo test 40/40 · verify.sh 6/6 · verify-resume.sh 4/4 · verify-mpris-modes.sh 4/4 · verify-api.sh 55/55 · verify-input.sh 13/13