From 1e80ab2c0c2268602dcbdedc21c0198914941b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20W=C3=BCrfl?= Date: Sun, 20 May 2018 22:52:08 +0200 Subject: [PATCH] Add button to download entire music library --- interface.py | 7 +++++-- templates/index.html | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/interface.py b/interface.py index f79a083..28ae96a 100644 --- a/interface.py +++ b/interface.py @@ -169,8 +169,11 @@ def download(): folder_path = var.music_folder requested_dir_fullpath = os.path.abspath(os.path.join(folder_path, requested_dir)) + '/' if requested_dir_fullpath.startswith(folder_path): - prefix = secure_filename(os.path.relpath(requested_dir_fullpath, folder_path)) - zipfile = util.zipdir(requested_dir_fullpath, requested_dir) + if os.path.samefile(requested_dir_fullpath, folder_path): + prefix = 'all' + else: + prefix = secure_filename(os.path.relpath(requested_dir_fullpath, folder_path)) + zipfile = util.zipdir(requested_dir_fullpath, prefix) try: return send_file(zipfile, as_attachment=True) except Exception as e: diff --git a/templates/index.html b/templates/index.html index 75b9b0e..87e1b3d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -92,6 +92,11 @@ {% endfor %}

Music library:

+
+ + +
+
{{ dirlisting() }}