mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
lastgenre: Make TitleCasing optional
This commit is contained in:
parent
8645f56512
commit
95677c8626
3 changed files with 10 additions and 1 deletions
|
|
@ -111,6 +111,7 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
||||||
'auto': True,
|
'auto': True,
|
||||||
'separator': u', ',
|
'separator': u', ',
|
||||||
'prefer_specific': False,
|
'prefer_specific': False,
|
||||||
|
'title_case': True,
|
||||||
})
|
})
|
||||||
|
|
||||||
self.setup()
|
self.setup()
|
||||||
|
|
@ -224,12 +225,17 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
||||||
|
|
||||||
# c14n only adds allowed genres but we may have had forbidden genres in
|
# c14n only adds allowed genres but we may have had forbidden genres in
|
||||||
# the original tags list
|
# the original tags list
|
||||||
tags = [x.title() for x in tags if self._is_allowed(x)]
|
tags = [self._format_tag(x) for x in tags if self._is_allowed(x)]
|
||||||
|
|
||||||
return self.config['separator'].as_str().join(
|
return self.config['separator'].as_str().join(
|
||||||
tags[:self.config['count'].get(int)]
|
tags[:self.config['count'].get(int)]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _format_tag(self, tag):
|
||||||
|
if self.config["title_case"]:
|
||||||
|
return tag.title()
|
||||||
|
return tag
|
||||||
|
|
||||||
def fetch_genre(self, lastfm_obj):
|
def fetch_genre(self, lastfm_obj):
|
||||||
"""Return the genre for a pylast entity or None if no suitable genre
|
"""Return the genre for a pylast entity or None if no suitable genre
|
||||||
can be found. Ex. 'Electronic, House, Dance'
|
can be found. Ex. 'Electronic, House, Dance'
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ Changelog
|
||||||
|
|
||||||
New features:
|
New features:
|
||||||
|
|
||||||
|
* Add ``title_case`` config option to lastgenre to make TitleCasing optional.
|
||||||
* When config is printed with no available configuration a new message is printed.
|
* When config is printed with no available configuration a new message is printed.
|
||||||
:bug:`3779`
|
:bug:`3779`
|
||||||
* When importing a duplicate album it ask if it should "Keep all" instead of "Keep both".
|
* When importing a duplicate album it ask if it should "Keep all" instead of "Keep both".
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,8 @@ configuration file. The available options are:
|
||||||
- **whitelist**: The filename of a custom genre list, ``yes`` to use
|
- **whitelist**: The filename of a custom genre list, ``yes`` to use
|
||||||
the internal whitelist, or ``no`` to consider all genres valid.
|
the internal whitelist, or ``no`` to consider all genres valid.
|
||||||
Default: ``yes``.
|
Default: ``yes``.
|
||||||
|
- **title_case**: Convert the new tags to TitleCase before saving.
|
||||||
|
Default: ``yes``.
|
||||||
|
|
||||||
Running Manually
|
Running Manually
|
||||||
----------------
|
----------------
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue