mirror of
https://github.com/beetbox/beets.git
synced 2026-02-21 23:03:26 +01:00
smartplaylist: Respect sort terms in queries.
This commit is contained in:
parent
165ee80f81
commit
11c60ce101
1 changed files with 11 additions and 13 deletions
|
|
@ -36,23 +36,21 @@ def _items_for_query(lib, playlist, album=False):
|
|||
if key not in playlist:
|
||||
return []
|
||||
|
||||
# Parse quer(ies). If it's a list, join the queries with OR.
|
||||
# Parse quer(ies). If it's a list, perform the queries and manually
|
||||
# concatenate the results
|
||||
query_strings = playlist[key]
|
||||
if not isinstance(query_strings, (list, tuple)):
|
||||
query_strings = [query_strings]
|
||||
model = library.Album if album else library.Item
|
||||
query = dbcore.OrQuery(
|
||||
[library.parse_query_string(q, model)[0] for q in query_strings]
|
||||
)
|
||||
|
||||
# Execute query, depending on type.
|
||||
if album:
|
||||
result = []
|
||||
for album in lib.albums(query):
|
||||
result.extend(album.items())
|
||||
return result
|
||||
else:
|
||||
return lib.items(query)
|
||||
results = []
|
||||
for q in query_strings:
|
||||
querystr, sort = library.parse_query_string(q, model)
|
||||
if album:
|
||||
new = lib.albums(querystr, sort)
|
||||
else:
|
||||
new = lib.items(querystr, sort)
|
||||
results.extend(new)
|
||||
return results
|
||||
|
||||
|
||||
def update_playlists(lib):
|
||||
|
|
|
|||
Loading…
Reference in a new issue