Compare commits
2 commits
57884aed69
...
38995d2456
| Author | SHA1 | Date | |
|---|---|---|---|
| 38995d2456 | |||
| 13f72c15db |
2 changed files with 21 additions and 3 deletions
|
|
@ -76,7 +76,7 @@ smartplaylist:
|
||||||
forward_slash: no
|
forward_slash: no
|
||||||
playlists:
|
playlists:
|
||||||
- name: "favorites.m3u"
|
- name: "favorites.m3u"
|
||||||
query: ['label:favorites']
|
query: ['label:']
|
||||||
- name: "everyday.m3u"
|
- name: "everyday.m3u"
|
||||||
query: ['sorted_playlist:everyday']
|
query: ['sorted_playlist:everyday']
|
||||||
- name: "exercise.m3u"
|
- name: "exercise.m3u"
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,8 @@ action_map = {
|
||||||
"removeall": 2,
|
"removeall": 2,
|
||||||
"show": 3,
|
"show": 3,
|
||||||
"transfer": 4,
|
"transfer": 4,
|
||||||
"edit": 5
|
"edit": 5,
|
||||||
|
"listall": 6,
|
||||||
}
|
}
|
||||||
|
|
||||||
def modify_labels(lib, opts, args):
|
def modify_labels(lib, opts, args):
|
||||||
|
|
@ -86,6 +87,10 @@ def modify_labels(lib, opts, args):
|
||||||
edit_labels(lib, opts, args[1:])
|
edit_labels(lib, opts, args[1:])
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if actnum == 6: # listall
|
||||||
|
listall_labels(lib, opts, args[1:])
|
||||||
|
return
|
||||||
|
|
||||||
if actnum >= 2:
|
if actnum >= 2:
|
||||||
label = None
|
label = None
|
||||||
query = args[1:]
|
query = args[1:]
|
||||||
|
|
@ -104,6 +109,15 @@ def modify_labels(lib, opts, args):
|
||||||
else:
|
else:
|
||||||
do_modify_labels(lib, items, label, actnum)
|
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):
|
def transfer_labels(lib, opts, args):
|
||||||
source_query = args[0]
|
source_query = args[0]
|
||||||
dest_query = args[1]
|
dest_query = args[1]
|
||||||
|
|
@ -343,7 +357,8 @@ Actions:
|
||||||
show [query] Display labels on items
|
show [query] Display labels on items
|
||||||
transfer <src-query> <dst-query>
|
transfer <src-query> <dst-query>
|
||||||
Copy labels from one item to another
|
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
|
labels_command.func = modify_labels
|
||||||
|
|
||||||
class HasLabelQuery(FieldQuery):
|
class HasLabelQuery(FieldQuery):
|
||||||
|
|
@ -355,6 +370,9 @@ class HasLabelQuery(FieldQuery):
|
||||||
if not labels:
|
if not labels:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if not pattern:
|
||||||
|
return True
|
||||||
|
|
||||||
match = re.match(r'^([^.]+)(?:\.(gt|lt|eq)\.(\d+))?$', pattern)
|
match = re.match(r'^([^.]+)(?:\.(gt|lt|eq)\.(\d+))?$', pattern)
|
||||||
if not match:
|
if not match:
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue