From ae7e236072bcc0fc7d7bd3ca58bc0ad5cff0fdd2 Mon Sep 17 00:00:00 2001 From: Benson Chu Date: Sat, 23 Aug 2025 10:13:49 -0500 Subject: [PATCH] Dictionary instead of list? --- plugins/beetslabels.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/beetslabels.py b/plugins/beetslabels.py index ce11a48..f6a7b34 100644 --- a/plugins/beetslabels.py +++ b/plugins/beetslabels.py @@ -14,16 +14,20 @@ def do_modify_labels(lib, objs, label, action): changed = [] for obj in objs: - labels = [] + labels = {} if action != 2: if "mylabels" in obj: labels = json.loads(obj["mylabels"]) + split = label.split(":") + if action == 0: - labels.append(label) - labels = sorted(set(labels)) + if len(split) == 1: + labels[label] = 0 + else: + labels[split[0]] = int(split[1]) elif label in labels: - labels.remove(label) + del labels[label] obj_mods = { "mylabels": json.dumps(labels)