B"H add diritem_sort_key()
This commit is contained in:
parent
e9c1fa1587
commit
49f69b0bba
1 changed files with 9 additions and 2 deletions
|
@ -18,6 +18,14 @@ ref_sort_key = lambda ref: ref.name
|
|||
|
||||
string_nums_nocase_sort_key = lambda s: [(int(i) if i.isdigit() else i.lower()) for i in re.split(r'(\d+)', s)]
|
||||
|
||||
def diritem_sort_key(item):
|
||||
isdir = item['isDir']
|
||||
if isdir:
|
||||
key = string_nums_nocase_sort_key(item['title'])
|
||||
else:
|
||||
key = int(item['track'])
|
||||
return (isdir, key)
|
||||
|
||||
class SubsonicApi():
|
||||
def __init__(self, url, username, password, legacy_auth):
|
||||
parsed = urlparse(url)
|
||||
|
@ -162,8 +170,7 @@ class SubsonicApi():
|
|||
directory = response.get('directory')
|
||||
if directory is not None:
|
||||
diritems = directory.get('child')
|
||||
sorted_diritems = sorted(diritems, key=lambda a: (a['isDir'], (string_nums_nocase_sort_key(a['title']) if a['isDir'] else int(a['track']))))
|
||||
return sorted_diritems
|
||||
return sorted(diritems, key=diritem_sort_key)
|
||||
return None
|
||||
|
||||
def get_raw_albums(self, artist_id):
|
||||
|
|
Loading…
Add table
Reference in a new issue