Skip to content

Extract filename ID tokens into tags and backfill missing per-platform custom config#3

Merged
TX-RX merged 2 commits into
mainfrom
fix-beatport-filename-id
Jul 8, 2026
Merged

Extract filename ID tokens into tags and backfill missing per-platform custom config#3
TX-RX merged 2 commits into
mainfrom
fix-beatport-filename-id

Conversation

@TX-RX

@TX-RX TX-RX commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Two small changes that together let filename-encoded platform IDs (e.g. Beatport track ID as a trailing filename segment) actually flow through to the platform matchers.

1. + 'parse_template' + promotes arbitrary + '%name%' + placeholders

Before: + 'parse_template' + only recognized + '%title%' + , + '%artist%' + , and + '%artists%' + . Every other placeholder got replaced by an unnamed + '(.+)' + catch-all, so + 'load_file' + never saw a named capture for it and couldn't populate anything in + 'info.tags' + .

After: identifier-safe placeholders become named captures. Legacy templates with spaces in placeholder names still fall through to the old catch-all path unchanged.

2. + 'load_file' + always runs the filename regex and merges extras into tags

Before: filename parsing only ran when the file was missing a title or artist tag.

After: the regex always runs when a template is configured. Title/artist behavior is unchanged (still only overridden when missing). Any other named captures — + 'beatport_track_id' + , + 'beatsource_track_id' + , etc. — get uppercased and merged into + 'info.tags' + via + 'entry().or_insert()' + , so existing ID3 tags still win on collision.

Beatport's + 'match_track' + already checks + 'info.tags.get("BEATPORT_TRACK_ID")' + in its "Fetch by ID" path, so this immediately gives us direct-ID lookup for any filename that encodes the ID.

3. + 'Tagger::tag_files' + backfills missing per-platform custom configs

Runtime logs show that the frontend sometimes ships a + 'TaggerConfig' + with an empty + 'custom' + map even when + 'settings.json' + has the platform blocks populated. That trips + 'get_custom("beatport")?' + with "Missing beatport custom config!" before anything can happen. This fills in defaults from + 'TaggerConfig::custom_default()' + at the top of + 'tag_files' + — existing per-platform values are preserved via + 'HashMap::entry' + . Not a fix for the underlying client-side bug (that lives in + 'client/src/scripts/onetagger.ts' + ), but a hard guard so the backend stays usable regardless.

Test evidence

Regex validated against real filenames — 23/23 test files parse correctly with the template + '%artists%-%title%-%version%-%beatport_track_id%' + (validation script tested standalone).

Ordering

This can merge before or after #1 (PR 523 backport) — they touch different files.

TX-RX and others added 2 commits July 8, 2026 12:49
…ames

parse_template previously only recognized %title%, %artist%, %artists%,
and stripped every other placeholder into an unnamed catch-all. That
meant templates like `%artists%-%title%-%version%-%beatport_track_id%`
could never populate a Beatport track ID tag that platform matchers
could pick up.

- parse_template now promotes any identifier-safe %name% into a named
  capture, so downstream code sees them in `Regex::captures`.
- load_file always runs the filename regex when a template is provided
  (not only when title/artist are missing) and merges every named capture
  other than title/artists into `info.tags` under the uppercased key. ID3
  tags on the file still win over filename-derived tags.

With this, files whose names encode the Beatport track ID in the tail
segment land BEATPORT_TRACK_ID in info.tags, which beatport.rs already
checks in its "Fetch by ID" path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When the frontend hands us a TaggerConfig with an empty `custom` map,
every platform's match_track fails immediately on `get_custom("beatport")?`
with "Missing beatport custom config!" — before any actual tagging can
start. Runtime logs confirm this happens even when settings.json has the
custom map populated (the frontend isn't shipping it on tag start).

Fill in defaults from custom_default() at the top of Tagger::tag_files so
platforms stay functional regardless of what the frontend sends. Existing
per-platform values in `custom` are preserved via HashMap::entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@TX-RX
TX-RX force-pushed the fix-beatport-filename-id branch from 374a837 to 09c50a5 Compare July 8, 2026 17:49
@TX-RX
TX-RX merged commit 7f91382 into main Jul 8, 2026
4 checks passed
@TX-RX
TX-RX deleted the fix-beatport-filename-id branch July 8, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant