~ knotless Search/
↑↓ move↵ open⇧↵ all results

geesawra.industries/hydraulophone

An unofficial YouTube Music app for iPhone, iPad, and Mac.

0
0
main
60 lines · 3.6 KB Raw History

Last.fm sign-in and scrobbling

Last.fm support is available only in builds with both application credentials provided at project generation time. Set HYDRAULOPHONE_LASTFM_API_KEY and HYDRAULOPHONE_LASTFM_API_SECRET in the environment before running just generate, just build, or a Justfile build target. The generator writes .build/generated/LastFMBuildConfiguration.swift; .build/ is ignored by Git. If either variable is empty, the generated configuration exposes no credentials and the app integration hides Last.fm settings.

The app uses Last.fm's desktop/browser authorization flow. It requests a one-time token with auth.getToken, opens Last.fm's approval page, then calls auth.getSession only after the user returns and selects the explicit finish sign-in action. It does not ask for a Last.fm password. The short-lived request token exists only in the in-memory LastFMClient; the returned session key and username are stored in a dedicated Keychain item. Disconnect deletes that item.

Authenticated calls sign all supplied parameters by sorting names, joining each name and value, appending the shared secret, and hashing the UTF-8 bytes with MD5. The api_sig parameter itself is not signed. Calls use HTTPS POST with UTF-8 form encoding. API request data, session keys, auth tokens, shared secrets, response bodies, and authorization URLs must not be logged. Error values retain only safe status or API error codes. HTTP/API failures are not blindly retried. A scrobble rejected with Last.fm error 11 or 16 is retried once after a short delay, as those codes are explicitly documented as transient. Now-playing requests and ambiguous network failures are not retried. This foundation does not persist or replay failed scrobbles, so they may be lost. Automatic retry after an ambiguous network failure could duplicate a scrobble that Last.fm accepted before the connection dropped; durable replay needs a separate bounded cache and duplicate policy.

Playback integration should call track.updateNowPlaying when playback starts. It should call track.scrobble once playback meets Last.fm's eligibility rule: the track is longer than 30 seconds, and the listener has heard at least half its duration or four minutes, whichever occurs earlier. The timestamp sent with the scrobble is the actual track start time, not the time the threshold was reached. chosenByUser is omitted when the source cannot be classified confidently. Server-side filtered scrobbles can still return success; callers receive accepted/ignored counts and an optional ignored code.

Security and limitations

The API shared secret is embedded in the compiled application so it can sign requests. A secret in a distributed client binary cannot be kept confidential; build-time environment injection prevents accidental source control and build command logging, but it does not make the binary secret. Use credentials issued for this app, restrict their use where Last.fm allows it, and rotate them if exposed. No proxy/server is introduced by this implementation.

Official references