mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
LastGenre: allow prefer_specific without canonical
This improves lastgenre's behaviour when the configuration option `prefer_specific` is set but `canonical` is not. Previously it would not set any tags. Now it does apply tags, sorted using the canonicalization tree, but not canonicalized. For this the default tree is loaded even when `canonical` is not set. An extra check is added to only use it for canonicalization when `canonical` is set.
This commit is contained in:
parent
0c033bdaf1
commit
cef9a3311c
1 changed files with 11 additions and 2 deletions
|
|
@ -138,9 +138,18 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
# Read the genres tree for canonicalization if enabled.
|
||||
self.c14n_branches = []
|
||||
c14n_filename = self.config['canonical'].get()
|
||||
if c14n_filename in (True, ''): # Default tree.
|
||||
self.canonicalize = c14n_filename is not False
|
||||
|
||||
# Default tree
|
||||
if c14n_filename in (True, ''):
|
||||
c14n_filename = C14N_TREE
|
||||
elif not self.canonicalize and self.config['prefer_specific'].get():
|
||||
# prefer_specific requires a tree, load default tree
|
||||
c14n_filename = C14N_TREE
|
||||
|
||||
# Read the tree
|
||||
if c14n_filename:
|
||||
self._log.debug('Loading canonicalization tree {0}', c14n_filename)
|
||||
c14n_filename = normpath(c14n_filename)
|
||||
with codecs.open(c14n_filename, 'r', encoding='utf-8') as f:
|
||||
genres_tree = yaml.load(f)
|
||||
|
|
@ -186,7 +195,7 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
return None
|
||||
|
||||
count = self.config['count'].get(int)
|
||||
if self.c14n_branches:
|
||||
if self.c14n_branches and self.canonicalize:
|
||||
# Extend the list to consider tags parents in the c14n tree
|
||||
tags_all = []
|
||||
for tag in tags:
|
||||
|
|
|
|||
Loading…
Reference in a new issue