From 61c61d203b89cbdc9a0131bca62abace17a7b9eb Mon Sep 17 00:00:00 2001 From: Gu1llaum-3 Date: Wed, 28 Dec 2022 23:38:07 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20page=20erreur=20si=20toutes=20les=20url?= =?UTF-8?q?=20vident,=20cr=C3=A9ation=20du=20fichier=20css=20pour=20habill?= =?UTF-8?q?er=20la=20page.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __pycache__/app.cpython-310.pyc | Bin 0 -> 1323 bytes app.py | 95 +++++++++++++++++++++++-------- static/css/style.css | 40 +++++++++++++ templates/download_complete.html | 10 ++++ templates/erreur.html | 13 +++++ templates/index.html | 9 --- templates/upload.html | 45 +++++++++++++++ 7 files changed, 179 insertions(+), 33 deletions(-) create mode 100644 __pycache__/app.cpython-310.pyc create mode 100644 static/css/style.css create mode 100644 templates/download_complete.html create mode 100644 templates/erreur.html delete mode 100644 templates/index.html create mode 100644 templates/upload.html diff --git a/__pycache__/app.cpython-310.pyc b/__pycache__/app.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4ca34f03aedb657c62b426fbc1ff86797874c093 GIT binary patch literal 1323 zcmZWo&2HQ_5GE;UrTw#ABTbtk2O$ND=->!NdMuitzn8)-U;_bk5#$|uSBWU8B$dRn zw}(21Uh)J%0sB~>570xeeFMIy1njtsqxGo6}heOUUziFn^5yA0C{oCwMpOC-o z;p#vcd5BB>gaioCiU^uf!7?Vi%oBd*iy#ZcARAD7&#EvBIpxtQ&4zqt>m4*F%FUp zOz?G8s3#_r{D+P!Z6e8`lzgU5*vTqCY@`_~UPFFZR@`h#WVy^W7j0E&zI#E_nYDCv zFg$#LOGQXD=6Xu^NWymeao1K&0rwVKR0)+KUjItu5I09I?xu@I@O0jNTveZR;(j_W z^`bjS_u58(`ECA)AEZUw-fNG{8%s7kF|e+z&xpw}ZpQoOt9|2t|J~kxLQN>RUNoTo z6QzgGE~C7Q2Ovv~^f3jBHQPdt0lP((RC^~F{gP=PJeP&PE2qu}7N@@n&9mBOl+PNh z2iJU+S|F_hGg!GczKzmMTG`CFQm&9L_r$Z&DOJq5+;j?(tFF>-D&M76B zU~p=8au&egguEgUo-m}*FM+)Wg1{L%z0a@djsBw zHi-#ZS=QPN)RDr5NPPE;@&hcpxp4`NwvdI$T}i^?jnJCXiQPz3BU;d8hPnZdSA9Qn!x{*5BG{K>5aB1Q0U@0v|WMGNy z9EU`C3ps15E(FhW<6)bbKw^=&Ybgh`l|N5*^_6g4^E#A9pNa;$ihpMDsBR*O34)YG Q2-htS0UJg)wyFQ`Yvepo - - - - - ''' + return render_template('upload.html') @app.route('/', methods=['GET', 'POST']) def index(): message = None if request.method == 'POST': - url = request.form['url'] - result = process_file(url) - return ''' -

Téléchargement terminé

- - ''' + url1 = request.form['url1'] + url2 = request.form['url2'] + url3 = request.form['url3'] + url4 = request.form['url4'] + url5 = request.form['url5'] -def process_file(url): + # Vérifier si au moins un champ est vide + if not url1 and not url2 and not url3 and not url4 and not url5: + return render_template('erreur.html') + + result = process_file(url1, url2, url3, url4, url5) + return render_template('download_complete.html') + +def process_file(url1, url2, url3, url4, url5): 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}"') + # Télécharger chaque URL s'il n'est pas vide + if url1: + if "album" in url1: + os.chdir(f"{path}") + os.system(f'python3 -m spotdl {url1} --output "{download_param_album}"') + elif "playlist" in url1: + os.chdir(f"{path}") + os.system(f'python3 -m spotdl {url1} --output "{download_param_playlist}"') + + if url2: + if "album" in url2: + os.chdir(f"{path}") + os.system(f'python3 -m spotdl {url2} --output "{download_param_album}"') + elif "playlist" in url2: + os.chdir(f"{path}") + os.system(f'python3 -m spotdl {url2} --output "{download_param_playlist}"') + + if url3: + if "album" in url3: + os.chdir(f"{path}") + os.system(f'python3 -m spotdl {url3} --output "{download_param_album}"') + elif "playlist" in url3: + os.chdir(f"{path}") + os.system(f'python3 -m spotdl {url3} --output "{download_param_playlist}"') + + if url4: + if "album" in url4: + os.chdir(f"{path}") + os.system(f'python3 -m spotdl {url4} --output "{download_param_album}"') + elif "playlist" in url4: + os.chdir(f"{path}") + os.system(f'python3 -m spotdl {url4} --output "{download_param_playlist}"') + + if url5: + if "album" in url5: + os.chdir(f"{path}") + os.system(f'python3 -m spotdl {url5} --output "{download_param_album}"') + 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}"') # @app.route('/download/') diff --git a/static/css/style.css b/static/css/style.css new file mode 100644 index 0000000..4e8fcd1 --- /dev/null +++ b/static/css/style.css @@ -0,0 +1,40 @@ + +body { + background-color: black; +} + +h1 { + /* border: 2px #eee solid; */ + color: rgb(24,216,96); + background-color: black; + text-align: center; + padding: 10px; +} + +h2 { + text-align: center; + margin: auto; + padding: 10px; + color: white; +} + +.url { + display: flex; + justify-content: center; + align-items: center; + /* min-height:100%; */ + background-color: black; + color: white +} + + +input[type="submit"] { + display: block; + margin: auto; +} + +button { + display: block; + margin: 10px auto; + } + diff --git a/templates/download_complete.html b/templates/download_complete.html new file mode 100644 index 0000000..8641e78 --- /dev/null +++ b/templates/download_complete.html @@ -0,0 +1,10 @@ + + + + SpotDL Web + + +

SpotDL Web

+

Téléchargement Terminé

+ + diff --git a/templates/erreur.html b/templates/erreur.html new file mode 100644 index 0000000..f1ac2d1 --- /dev/null +++ b/templates/erreur.html @@ -0,0 +1,13 @@ + + + + SpotDL Web + + +

SpotDL Web

+

Veuillez entrer au moins une URL !

+ + +{% if message %} +

{{ message }}

+{% endif %} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html deleted file mode 100644 index 117a177..0000000 --- a/templates/index.html +++ /dev/null @@ -1,9 +0,0 @@ -
- - - -
- -{% if message %} -

{{ message }}

-{% endif %} diff --git a/templates/upload.html b/templates/upload.html new file mode 100644 index 0000000..307753a --- /dev/null +++ b/templates/upload.html @@ -0,0 +1,45 @@ + + + + SpotDL Web + + +

SpotDL Web

+
+
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ +
+
+ +