From b0225778a1ca03a9984c4f952ed09f7ecb37568c Mon Sep 17 00:00:00 2001 From: Gu1llaum-3 Date: Thu, 29 Dec 2022 12:59:28 +0100 Subject: [PATCH] =?UTF-8?q?Compression=20des=20fichiers=20t=C3=A9l=C3=A9ch?= =?UTF-8?q?arg=C3=A9s=20dans=20downloads=20et=20possibilit=C3=A9=20de=20le?= =?UTF-8?q?s=20t=C3=A9l=C3=A9charger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 30 +++++++++--------------------- templates/download_complete.html | 2 ++ 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/app.py b/app.py index 66d2d84..de12c04 100644 --- a/app.py +++ b/app.py @@ -25,14 +25,15 @@ def index(): return render_template('download_complete.html') def process_file(url1, url2, url3, url4, url5): - path = os.path.expanduser('~/musics') + path = os.path.expanduser('~/musics/downloads') download_param_album = '{artist}/{album}/{artist} - {title}' download_param_playlist = '{playlist}/{artists}/{album} - {title} {artist}' # Télécharger chaque URL s'il n'est pas vide if url1: if "album" in url1: - os.chdir(f"{path}") + #os.makedirs(f'{path}/download-1', exist_ok=True) + os.chdir(f'{path}') os.system(f'python3 -m spotdl {url1} --output "{download_param_album}"') elif "playlist" in url1: os.chdir(f"{path}") @@ -69,27 +70,14 @@ def process_file(url1, url2, url3, url4, url5): elif "playlist" in url5: os.chdir(f"{path}") os.system(f'python3 -m spotdl {url5} --output "{download_param_playlist}"') - - -# def process_file(url): -# path = os.path.expanduser('~/musics') -# download_param_album = '{artist}/{album}/{artist} - {title}' -# download_param_playlist = '{playlist}/{artists}/{album} - {title} {artist}' - -# if "album" in url: -# #os.makedirs(f"{path}") -# os.chdir(f"{path}") -# print ("album found") -# os.system(f'python3 -m spotdl {url} --output "{download_param_album}"') -# elif "playlist" in url: -# os.chdir(f"{path}") -# print("playlist found") -# os.system(f'python3 -m spotdl {url} --output "{download_param_playlist}"') + os.chdir(f'{path}') + os.system(f'zip -r musics.zip ./') -# @app.route('/download/') -# def download_file(filename): -# return send_file(filename, attachment_filename=filename, as_attachment=True) +@app.route('/download', methods=['GET']) +def download(): + PATH='/home/gu1ll4um3/musics/downloads/musics.zip' + return send_file(PATH,as_attachment=True) if __name__ == '__main__': app.run(debug=True, port=3000) diff --git a/templates/download_complete.html b/templates/download_complete.html index 8641e78..4ed471f 100644 --- a/templates/download_complete.html +++ b/templates/download_complete.html @@ -6,5 +6,7 @@

SpotDL Web

Téléchargement Terminé

+ +