mirror of
https://github.com/beetbox/beets.git
synced 2025-12-28 11:32:30 +01:00
lastgenre: multiple + canonical genres (fix #478)
This commit is contained in:
parent
6ab0abfa90
commit
3338ef2ff2
2 changed files with 11 additions and 4 deletions
|
|
@ -97,16 +97,21 @@ def _is_allowed(genre):
|
|||
return False
|
||||
|
||||
def _strings_to_genre(tags):
|
||||
"""Given a list of strings, return a genre. Returns the first string
|
||||
that is present in the genre whitelist (or the canonicalization
|
||||
tree) or None if no tag is suitable.
|
||||
"""Given a list of strings, return a genre by joining them into a
|
||||
single string and (optionally) canonicalizing each.
|
||||
"""
|
||||
if not tags:
|
||||
return None
|
||||
|
||||
if options.get('c14n'):
|
||||
# Use the canonicalization tree.
|
||||
tags = find_parents(tags[0], options['branches'])
|
||||
out = []
|
||||
for tag in tags:
|
||||
for parent in find_parents(tag, options['branches']):
|
||||
if _is_allowed(tag):
|
||||
out.append(tag)
|
||||
break
|
||||
tags = out
|
||||
|
||||
tags = [t.title() for t in tags]
|
||||
return u', '.join(tags[:config['lastgenre']['count'].get(int)])
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ Little fixes:
|
|||
to a YAML list.
|
||||
* Values for the :ref:`replace` option can now be empty (i.e., null is
|
||||
equivalent to the empty string).
|
||||
* :doc:`/plugins/lastgenre`: Fix a conflict between canonicalization and
|
||||
multiple genres.
|
||||
|
||||
.. _Acoustic Attributes: http://developer.echonest.com/acoustic-attributes.html
|
||||
.. _MPD: http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki
|
||||
|
|
|
|||
Loading…
Reference in a new issue