-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New Plugin: Titlecase #6133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
New Plugin: Titlecase #6133
Conversation
… for pre or post import
|
Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry. |
| super().__init__() | ||
|
|
||
| # Register template function | ||
| self.template_funcs["titlecase"] = self.titlecase # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could not get mypy to play nice with this type here - any suggestions appreciated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue is that the type is
# plugins.py
template_funcs: TFuncMap[str] | None = None
# and should be
template_funcs: ClassVar[TFuncMap[str]] = {}Notice the union with None. Should be fine here as this is more of an issue with the plugin implementation.
| """ | ||
| auto - Automatically apply titlecase to new import metadata. | ||
| preserve - Provide a list of words/acronyms with specific case requirements. | ||
| fields - Fields to apply titlecase to, default is all. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't seem to find the default is all case. Where is this handled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! This is a holdover from my previous version where I initially just had it do all fields by default. Thanks for catching it. Now it only does fields as specified, which I think can play into a solution to your other comment!
| # These fields are excluded to avoid modifying anything | ||
| # that may be case sensistive, or important to database | ||
| # function | ||
| EXCLUDED_INFO_FIELDS: set[str] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list seems a bit like a potential footgun to me:
- How can we be sure these are all available sensitive fields?
- How do we make sure this is maintained?
- What about plugins that add field?
Maybe we should turn this around? Could we have a list with default fields and let the user add more if needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point - I was a little worried about the maintenance of it. Thinking on it, since the fields to tag have to be manually specified, we could remove this and let users apply titlecase to any field they please. We can then rely on re-importing / re-tagging to fix any issues if a user, for some reason, chooses to titlecase a musicbrainz id.
semohr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation is lovely! Added some small comments but looks good overall.
This plugin aims to address the shortcomings of the %title function, as brought up in issues #152, #3298 and an initial look to improvement with #3411. It supplies a new string format command,
%titlecasewhich doesn't interfere with any prior expected behavior of the%titleformat command.It also adds the ability to apply titlecase logic to metadata fields that a user selects, which is useful if you, like me, are looking for stylistic consistency and the minor stylistic differences between Musizbrainz, Discogs, Deezer etc, with title case are slightly infuriating.
This will add an optional dependency of titlecase, which allows the titlecase core logic to be externally maintained.
If there's not enough draw to have this as a core plugin, I can also spin this into an independent one, but it seemed like a recurring theme that the %title string format didn't really behave as expected, and I wanted my metadata to match too.
docs/to describe it.)docs/changelog.rstto the bottom of one of the lists near the top of the document.)