feat: detect & link album mentions, not just artists (closes task/album-detection)
Source: task/album-detection (objective/linker-improvements) — project brief asks for artist OR album linking; MVP linked artists only.
- service/lib.js: pickAlbum (the exact-name gate, named for the album path) + linkResult now carries kind:"artist"|"album" (additive; defaults to artist so older clients keep working).
- service/resolver.js: one Spotify type=artist,album search per candidate, exact-match against either; returns {url,kind}; cache key includes the kind hint. resolveOne/resolveAll thread the LLM kind hint through.
- service/llm.js: parseClassification now returns Map(name -> "artist"|"album") so album-kind candidates route to the album path (.has() still works like the old Set).
- extension/extract.js: albumMatchesIn over two precise signals (quoted strings + album cue phrases "the album X", "X LP/EP"), folded into allMatchesIn.
- extension/content.js + styles.css: album links render italicised (.rsl-album) with an album tooltip; artist behavior unchanged.
- Tests: new pure-logic coverage in lib.test.js / llm.test.js / extract.test.cjs (album shaping, Map-kind routing, album candidate extraction). scripts/check.sh green.
- README.md + AGENTS.md: document album linking.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,19 +1,22 @@
|
||||
# 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
|
||||
names and album titles** in the comments (and the post body) and turns them into
|
||||
inline links to **Spotify** and **Bandcamp** — so a recommendation thread like
|
||||
[this one](https://www.reddit.com/r/SlamDeathMetal/comments/1txh2r1/) becomes a
|
||||
list of clickable artists instead of names you have to copy-paste into search.
|
||||
list of clickable artists and albums 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
|
||||
The hard part is *"which words are artists/albums and which aren't?"*. Rather than
|
||||
guess with client-side rules, the extension hands candidate names to a tiny local
|
||||
**resolver service** that confirms each one and only links the names that are
|
||||
really artists. The resolver confirms names two ways (you enable either or both):
|
||||
**Spotify** (exact-name match → direct artist pages) and an optional **local LLM**
|
||||
via ollama (classifies which candidates are artists/albums). A confirmed name
|
||||
links to its Spotify artist page when available, otherwise to a Google search for
|
||||
"<name> bandcamp".
|
||||
really artists or albums. The resolver confirms names two ways (you enable either
|
||||
or both): **Spotify** (exact-name match across artists **and** albums → direct
|
||||
Spotify pages) and an optional **local LLM** via ollama (classifies which
|
||||
candidates are artists/albums). A confirmed name links to its Spotify
|
||||
artist/album page when available, otherwise to a Google search for
|
||||
"<name> bandcamp". Album links are italicised so you can tell an album from an
|
||||
artist at a glance.
|
||||
|
||||
```
|
||||
reddit page content script resolver service
|
||||
@@ -56,8 +59,9 @@ warns at startup and nothing links.
|
||||
### Spotify credentials (one of the two gates)
|
||||
|
||||
Spotify does two jobs: it **gates** a name (a candidate links only when Spotify has
|
||||
that artist by exact name match) and supplies the **direct** artist-page link. To
|
||||
enable it:
|
||||
that **artist or album** by exact name match) and supplies the **direct** Spotify
|
||||
page link. A single search call covers both types, so albums confirm and link with
|
||||
no extra setup. To enable it:
|
||||
|
||||
1. Create a free app at <https://developer.spotify.com/dashboard> and copy its
|
||||
**Client ID** and **Client Secret**.
|
||||
@@ -129,8 +133,9 @@ with `xpinstall.signatures.required = false`.)
|
||||
|
||||
1. Make sure the resolver service is running.
|
||||
2. Open any Reddit comments thread (a URL with `/comments/` in it).
|
||||
3. Artist names become a single link — to **Spotify** if the artist is on Spotify,
|
||||
otherwise to **Bandcamp** — colour-coded (green = Spotify, teal = Bandcamp). New
|
||||
3. Artist names and album titles become a single link — to **Spotify** if it's on
|
||||
Spotify, otherwise to **Bandcamp** — colour-coded (green = Spotify, blue =
|
||||
Google/Bandcamp); album links are italicised so they read as albums. New
|
||||
comments loaded as you scroll are linked automatically.
|
||||
4. The toolbar icon shows the extension is active; its badge shows how many links were
|
||||
added on the current page.
|
||||
@@ -162,13 +167,17 @@ let the content script reach it).
|
||||
|
||||
## Limitations (MVP)
|
||||
|
||||
- **Detection is mostly capitalization-based**, with a cue-phrase pass that also catches
|
||||
lowercase names right after "check out / by / fan of / recommend …". Names split across
|
||||
inline formatting (e.g. **bold** mid-name) can still be missed. The resolver's
|
||||
- **Artist detection is mostly capitalization-based**, with a cue-phrase pass that also
|
||||
catches lowercase names right after "check out / by / fan of / recommend …". Names split
|
||||
across inline formatting (e.g. **bold** mid-name) can still be missed. The resolver's
|
||||
exact-name match keeps false *positives* low; the trade-off is some false *negatives*.
|
||||
- **Links are direct to Spotify when Spotify has the artist**; otherwise a confirmed
|
||||
name links to a Google search for "<name> bandcamp" (which surfaces the artist's
|
||||
Bandcamp page).
|
||||
- **Album detection leans on two precise signals** — quoted titles (`"Reek of Putrefaction"`)
|
||||
and album cue phrases ("the album X", "X LP/EP"). Album free-text is noisier than artist
|
||||
names, so it deliberately over-generates only from these cues and lets the Spotify
|
||||
exact-album match (and/or the LLM) be the precision filter. A bare album title written with
|
||||
no quotes or cue may be missed.
|
||||
- **Links are direct to Spotify when Spotify has the artist/album**; otherwise a confirmed
|
||||
name links to a Google search for "<name> bandcamp" (which surfaces the Bandcamp page).
|
||||
- **Without Spotify creds or the LLM, nothing links** — at least one gate must be
|
||||
configured.
|
||||
- The optional LLM adds a little latency on the **first** call (ollama warms the
|
||||
|
||||
Reference in New Issue
Block a user