update Beets

This commit is contained in:
AdeHub
2024-08-24 16:44:41 +12:00
parent a63098a919
commit 046d4d82b4
116 changed files with 17353 additions and 9964 deletions
+9 -7
View File
@@ -19,9 +19,8 @@ formats.
import re
from collections import defaultdict
from beets import library, ui
from beets.plugins import BeetsPlugin
from beets import ui
from beets import library
def rewriter(field, rules):
@@ -29,6 +28,7 @@ def rewriter(field, rules):
with the given rewriting rules. ``rules`` must be a list of
(pattern, replacement) pairs.
"""
def fieldfunc(item):
value = item._values_fixed[field]
for pattern, replacement in rules:
@@ -37,6 +37,7 @@ def rewriter(field, rules):
return replacement
# Not activated; return original value.
return value
return fieldfunc
@@ -55,15 +56,16 @@ class RewritePlugin(BeetsPlugin):
except ValueError:
raise ui.UserError("invalid rewrite specification")
if fieldname not in library.Item._fields:
raise ui.UserError("invalid field name (%s) in rewriter" %
fieldname)
self._log.debug('adding template field {0}', key)
raise ui.UserError(
"invalid field name (%s) in rewriter" % fieldname
)
self._log.debug("adding template field {0}", key)
pattern = re.compile(pattern.lower())
rules[fieldname].append((pattern, value))
if fieldname == 'artist':
if fieldname == "artist":
# Special case for the artist field: apply the same
# rewrite for "albumartist" as well.
rules['albumartist'].append((pattern, value))
rules["albumartist"].append((pattern, value))
# Replace each template field with the new rewriter function.
for fieldname, fieldrules in rules.items():