Compare commits

...

2 commits

Author SHA1 Message Date
38995d2456 Listall 2026-06-07 08:50:31 -05:00
13f72c15db Empty query matches all 2026-06-07 08:50:24 -05:00
2 changed files with 21 additions and 3 deletions

View file

@ -76,7 +76,7 @@ smartplaylist:
forward_slash: no
playlists:
- name: "favorites.m3u"
query: ['label:favorites']
query: ['label:']
- name: "everyday.m3u"
query: ['sorted_playlist:everyday']
- name: "exercise.m3u"

View file

@ -62,7 +62,8 @@ action_map = {
"removeall": 2,
"show": 3,
"transfer": 4,
"edit": 5
"edit": 5,
"listall": 6,
}
def modify_labels(lib, opts, args):
@ -86,6 +87,10 @@ def modify_labels(lib, opts, args):
edit_labels(lib, opts, args[1:])
return
if actnum == 6: # listall
listall_labels(lib, opts, args[1:])
return
if actnum >= 2:
label = None
query = args[1:]
@ -104,6 +109,15 @@ def modify_labels(lib, opts, args):
else:
do_modify_labels(lib, items, label, actnum)
def listall_labels(lib, opts, args):
"""Print every distinct label key used across all items."""
all_labels = set()
for item in lib.items():
if LABELS_FIELD_NAME in item and item[LABELS_FIELD_NAME]:
all_labels.update(item[LABELS_FIELD_NAME].keys())
for label in sorted(all_labels):
print_(label)
def transfer_labels(lib, opts, args):
source_query = args[0]
dest_query = args[1]
@ -343,7 +357,8 @@ Actions:
show [query] Display labels on items
transfer <src-query> <dst-query>
Copy labels from one item to another
edit [query] Open items' labels in a text editor"""
edit [query] Open items' labels in a text editor
listall List all label keys used in the library"""
labels_command.func = modify_labels
class HasLabelQuery(FieldQuery):
@ -355,6 +370,9 @@ class HasLabelQuery(FieldQuery):
if not labels:
return False
if not pattern:
return True
match = re.match(r'^([^.]+)(?:\.(gt|lt|eq)\.(\d+))?$', pattern)
if not match:
return False