mirror of
https://github.com/beetbox/beets.git
synced 2026-01-30 12:02:41 +01:00
Added min_weight option to lastgenre, to provide for filtering out unpopulare genres.
This commit is contained in:
parent
9f87870a84
commit
eafceaa0ed
2 changed files with 19 additions and 0 deletions
|
|
@ -61,11 +61,20 @@ def _tags_for(obj):
|
|||
return []
|
||||
|
||||
tags = []
|
||||
discarded_tags = []
|
||||
min_weight = config['lastgenre']['min_weight'].get(int)
|
||||
for el in res:
|
||||
if isinstance(el, pylast.TopItem):
|
||||
if min_weight > -1:
|
||||
if len(tags) > 0 and min_weight > int(el.weight):
|
||||
discarded_tags.append(el.item.get_name())
|
||||
continue
|
||||
el = el.item
|
||||
tags.append(el.get_name())
|
||||
log.debug(u'last.fm tags: %s' % unicode(tags))
|
||||
if min_weight > -1:
|
||||
log.debug(u'last.fm tags (weight < {0}): {1}'.format(
|
||||
min_weight, unicode(discarded_tags)))
|
||||
return tags
|
||||
|
||||
def _is_allowed(genre):
|
||||
|
|
@ -205,6 +214,7 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
self.config.add({
|
||||
'whitelist': os.path.join(os.path.dirname(__file__), 'genres.txt'),
|
||||
'multiple': False,
|
||||
'min_weight': -1,
|
||||
'fallback': None,
|
||||
'canonical': None,
|
||||
'source': 'album',
|
||||
|
|
|
|||
|
|
@ -94,6 +94,15 @@ you prefer to use a list of *all available* genre tags, turn on the
|
|||
|
||||
Comma-separated lists of genres will then be used instead of single genres.
|
||||
|
||||
If you want to filter out less popular tags, you can set the ``min_weight``
|
||||
config option::
|
||||
|
||||
lastgenre:
|
||||
min_weight: 50
|
||||
|
||||
Only tags with a weight greater then ``min_weight`` will be used. The weight
|
||||
ranges from 0 (unpopular) to 100 (most popular).
|
||||
|
||||
|
||||
Running Manually
|
||||
----------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue