Skip to content

feat(ftintitle): hook metadata events, fixing mbsync#6726

Open
treyturner wants to merge 1 commit into
beetbox:masterfrom
treyturner:feat/ftintitle-hook-metadata-events
Open

feat(ftintitle): hook metadata events, fixing mbsync#6726
treyturner wants to merge 1 commit into
beetbox:masterfrom
treyturner:feat/ftintitle-hook-metadata-events

Conversation

@treyturner

@treyturner treyturner commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Depends on #6732.

Summary

This PR integrates ftintitle with metadata fetched through beets’ metadata-received events, so commands like mbsync apply already-normalized metadata when ftintitle is enabled.

Addresses #1153.

Changes

  • Register ftintitle listeners for trackinfo_received and albuminfo_received when ftintitle.auto is enabled.
  • Rewrite fetched TrackInfo metadata before mbsync applies it, avoiding unnecessary re-sync churn.
  • Preserve existing manual command and import behavior while sharing the same rewrite logic.
  • Handle artist_credit, cached Info properties, empty titles, and no-op configurations consistently.
  • Update ftintitle docs for the expanded auto behavior.

To Do

  • Documentation. (If you've added a new command-line flag, for example, find the appropriate page under docs/ to describe it.)
  • Changelog. (Add an entry to docs/changelog.rst to the bottom of one of the lists near the top of the document.)
  • Tests. (Very much encouraged but not strictly required.)

@github-actions github-actions Bot added ftintitle ftintitle plugin mbsync mbsync plugin labels Jun 10, 2026
@treyturner treyturner force-pushed the feat/ftintitle-hook-metadata-events branch from 38e0446 to 8839b95 Compare June 10, 2026 10:16
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.50549% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.62%. Comparing base (beff630) to head (7b4d06a).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beetsplug/ftintitle.py 94.11% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6726      +/-   ##
==========================================
+ Coverage   74.54%   74.62%   +0.07%     
==========================================
  Files         162      162              
  Lines       20832    20909      +77     
  Branches     3298     3313      +15     
==========================================
+ Hits        15529    15603      +74     
+ Misses       4548     4547       -1     
- Partials      755      759       +4     
Files with missing lines Coverage Δ
beets/autotag/hooks.py 99.09% <100.00%> (+0.02%) ⬆️
beetsplug/ftintitle.py 93.81% <94.11%> (+2.75%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@treyturner treyturner force-pushed the feat/ftintitle-hook-metadata-events branch 4 times, most recently from ff4a62f to 06da57e Compare June 10, 2026 11:20
@treyturner treyturner marked this pull request as ready for review June 10, 2026 11:32
@treyturner treyturner requested a review from a team as a code owner June 10, 2026 11:32
@treyturner treyturner force-pushed the feat/ftintitle-hook-metadata-events branch from 06da57e to 9e8f19c Compare June 11, 2026 21:55

@snejus snejus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's split the following into a separate PR:

Define each configuration option as a @cached_property to remove the need to send them through each function. See 34772d2 where I did the same for convert plugin.

This will remove a big chunk of the current PR diff and make it easier to review the functionality that you added.

Comment thread beetsplug/ftintitle.py Outdated
@treyturner treyturner force-pushed the feat/ftintitle-hook-metadata-events branch 3 times, most recently from 3719e23 to ff085e4 Compare June 12, 2026 17:11
@treyturner

Copy link
Copy Markdown
Contributor Author

The cached properties are now in #6732 on which this PR is based. The remaining changes can be seen in the single subsequent commit:

ff085e4 (this PR)

@treyturner treyturner requested a review from snejus June 12, 2026 17:35
@treyturner treyturner force-pushed the feat/ftintitle-hook-metadata-events branch from ff085e4 to 7bfb1a7 Compare June 13, 2026 01:18
snejus added a commit that referenced this pull request Jun 13, 2026
Pre-factor for #6726.

Make `ftintitle`'s config `@cached_property` attributes instead of
passing them through the call stack. Modeled after similar recent
changes in `convert`.

## Changes

- Add cached plugin properties for `auto`, `drop`, `format`,
`keep_in_artist`, `preserve_album_artist`, and `custom_words`, keeping
the existing cached `bracket_keywords` property I forgot I added a while
back.
- `commands()`, `imported()`, `ft_in_title()`, and `update_metadata()`
are cleaned up to read these directly.
- Don't read `auto` during plugin init; the import stage remains
registered and `imported()` checks `auto` when invoked.
@snejus

snejus commented Jun 13, 2026

Copy link
Copy Markdown
Member

Now rebase it on master and I'll review it again :)

@treyturner treyturner force-pushed the feat/ftintitle-hook-metadata-events branch from 7bfb1a7 to 7b4d06a Compare June 14, 2026 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ftintitle ftintitle plugin mbsync mbsync plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants