Files
linker/README.md
T
paulandClaude Opus 4.8 7c695be590 feat: direct Spotify/Bandcamp links via MusicBrainz url-relations (task/odesli-direct-links)
The Odesli/Songlink API rejects artist URLs (405 UNSUPPORTED_URL — it is song/album
only), so the planned Odesli hop is not viable for artist linking. Pivoted to
MusicBrainz `inc=url-rels`, which returns the artist's official Bandcamp + Spotify
URLs directly, zero-cred:
- service/lib.js: relUrls() extracts direct bandcamp/spotify from MB relations;
  mbResult() prefers them, falls back to search URLs per-platform (replaces searchResult).
- service/resolver.js: viaMusicBrainz now does search -> url-rels enrichment (both
  throttled through one gate); resolveOne calls it directly.
- service/lib.test.js: +3 tests (relUrls + mbResult); 9 total, green.
- README: document the direct-link behavior.

Verified zero-cred end to end: "Cattle Decapitation" -> open.spotify.com/artist/... +
cattledecapitation.bandcamp.com/ (both direct, not search); nonsense -> null.

Source: task/odesli-direct-links (objective/linker-improvements); approach changed from
Odesli to MB url-rels after the API probe; goal (direct Bandcamp) achieved.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 12:35:33 +00:00

4.8 KiB

Reddit → Spotify / Bandcamp linker

A Firefox extension that, while you browse a Reddit thread, finds artist / band names in the comments (and the post body) and turns them into inline links to Spotify and Bandcamp — so a recommendation thread like this one becomes a list of clickable artists instead of names you have to copy-paste into search.

The hard part is "which words are artists and which aren't?". Rather than guess with client-side rules, the extension hands candidate names to a tiny local resolver service that checks each one against a real music database and only links the names that actually match an artist.

 reddit page                 content script                 resolver service
 ───────────                 ──────────────                 ────────────────
 comment text  ──extract──>  candidate names  ──POST /resolve──>  Spotify API  (direct links)
                                                                     or
 <a> links     <──rewrite──  confirmed links  <─────────────────  MusicBrainz  (zero-setup)

Layout

service/      tiny Node.js resolver (one file, zero npm deps)
  resolver.js
  package.json
  .env.example
extension/    Firefox MV2 extension (content script only)
  manifest.json
  content.js
  styles.css

1. Run the resolver service

Requirements: Node 18+ (uses the built-in fetch). No npm install needed — there are no dependencies.

cd service
node resolver.js
# resolver listening on http://localhost:8787  (provider: musicbrainz)

That's it. With no configuration the resolver validates names against MusicBrainz (no account required). When MusicBrainz knows an artist's official links (its url-relations), you get direct Spotify and Bandcamp artist pages; otherwise it falls back to Spotify/Bandcamp search URLs.

For direct artist links (instead of Spotify search), give the service Spotify API credentials:

  1. Create a free app at https://developer.spotify.com/dashboard and copy its Client ID and Client Secret.

  2. cp .env.example .env and fill them in (the .env file is gitignored):

    SPOTIFY_CLIENT_ID=your_id
    SPOTIFY_CLIENT_SECRET=your_secret
    
  3. Restart the service. It will report provider: spotify on startup.

(Bandcamp has no public API; direct Bandcamp links come from MusicBrainz url-relations when present, else a Bandcamp search URL.)

Quick check that it works:

curl -s localhost:8787/resolve \
  -H 'content-type: application/json' \
  -d '{"candidates":["Cerebral Bore","Devourment","Notarealband Xyzzy"]}'
# {"Cerebral Bore":{...},"Devourment":{...},"Notarealband Xyzzy":null}

2. Install the extension in Firefox

The extension is unpacked / unsigned, so load it as a temporary add-on:

  1. Open about:debugging#/runtime/this-firefox.
  2. Load Temporary Add-on…
  3. Select extension/manifest.json.

It's now active until you restart Firefox. (To keep it permanently you'd sign it via AMO or use Firefox Developer/ESR with xpinstall.signatures.required = false.)

3. Use it

  1. Make sure the resolver service is running.
  2. Open any Reddit comments thread (a URL with /comments/ in it).
  3. Artist names in the comments become links: the name links to Spotify, with a small superscript bc link to Bandcamp beside it. New comments loaded as you scroll are linked automatically.

Configuration

The resolver URL is the constant RESOLVER_URL at the top of extension/content.js (default http://localhost:8787). If you change the host or port, update both that constant and the matching entry in extension/manifest.jsonpermissions (Firefox needs the host listed there to let the content script reach it).

Limitations (MVP)

  • Detection is capitalization-based. Names written in lowercase, or split across formatting (e.g. bold in the middle of a name), can be missed. The resolver's exact-name match keeps false positives low; the trade-off is some false negatives.
  • Links are direct when MusicBrainz has the artist's url-relations (official Bandcamp / Spotify pages); otherwise they fall back to a search URL. (Each confirmed artist costs one extra throttled MusicBrainz lookup, cached after.)
  • The resolver caches results in memory; it resets when you restart it.
  • Without Spotify credentials the MusicBrainz path is rate-limited to ~1 lookup/ second, so the first scan of a large thread fills in gradually (cached after).
  • Built and tested as a Firefox MV2 extension.

License

Personal project — do as you like.