diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py index 52d8a53e7..f6c1ab1c8 100644 --- a/beetsplug/lastgenre/__init__.py +++ b/beetsplug/lastgenre/__init__.py @@ -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)]) diff --git a/docs/changelog.rst b/docs/changelog.rst index 112eee7b7..e311096c8 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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