sorting music dirs

This commit is contained in:
Rudis Muiznieks 2022-12-28 10:40:20 -06:00
parent 558d0a275b
commit 685be38c83
Signed by: rudism
GPG key ID: CABF2F86EF7884F9

View file

@ -12,11 +12,14 @@ def execute(cinput: ControlInput, graphics: Graphics, directory: str):
def create_directory_menu(directory: str, dirname: str):
sub_menu = list()
for fname in listdir(directory):
for fname in sorted(listdir(directory)):
new_path = path.join(directory, fname)
if path.isdir(new_path):
sub_menu.append(create_directory_menu(new_path, fname))
if len(sub_menu) > 0:
return MenuItem(dirname, MenuType.SUB_MENU, {"sub_menu": sub_menu})
else:
return MenuItem(dirname, MenuType.CMD, {"directory": directory})
if dirname.startswith("_"):
return MenuItem(dirname.lstrip("_"), MenuType.CMD, {"random": directory})
else:
return MenuItem(dirname, MenuType.CMD, {"album": directory})