Modifications

This commit is contained in:
Gu1llaum-3 2022-12-31 11:33:44 +01:00
parent 23d5d0d20d
commit d2397191a0
8 changed files with 55 additions and 8 deletions

Binary file not shown.

28
app.py
View File

@ -1,4 +1,5 @@
from flask import Flask, request, redirect, url_for, send_file, render_template
from subprocess import run
import os
app = Flask(__name__)
@ -9,17 +10,19 @@ def upload_form():
def process_file(urls):
# path = os.path.expanduser('~/musics/downloads')
path = './downloads'
download_param_album = '{artist}/{album}/{artist} - {title}'
#path = '/home/gu1ll4um3/github/SpotDL_Web/downloads'
#path = 'downloads/'
download_param_album = 'downloads/{artist}/{album}/{artist} - {title}'
download_param_playlist = '{playlist}/{artists}/{album} - {title} {artist}'
os.chdir(f"{path}")
os.system(f'rm -rf *')
#os.chdir(f"{path}")
#os.system(f'rm -rf *')
for url in urls:
if url:
if "album" in url:
os.system(f'python3 -m spotdl {url} --output "{download_param_album}"')
#os.system(f'python3 -m spotdl {url} --output "{download_param_album}"')
run(['python3', '-m', 'spotdl', url, '--output', download_param_album])
elif "playlist" in url:
os.system(f'python3 -m spotdl {url} --output "{download_param_playlist}"')
@ -41,8 +44,12 @@ def index():
return render_template('erreur.html')
urls = [url1, url2, url3, url4, url5]
result = process_file(urls)
return render_template('download_complete.html')
process_file(urls)
#print(resultProcessFile)
with open('/home/gu1ll4um3/github/SpotDL_Web/erreurs.txt', 'r') as f:
result2 = f.readlines()
return render_template('download_complete.html', result2=result2)
@app.route('/download', methods=['GET'])
def download():
@ -50,5 +57,12 @@ def download():
PATH='./downloads/musics.zip'
return send_file(PATH,as_attachment=True)
# @app.route('/errors')
# def errors():
# with open('erreurs.txt', 'r') as f:
# lines = f.readlines()
# return render_template('logs.html', lines=lines)
if __name__ == '__main__':
app.run(debug=True, port=3000)

3
logs/erreurs.log Normal file
View File

@ -0,0 +1,3 @@
Des erreurs se sont produites et la ou les piste(s) suivante(s) sont manquantes :
Aldebert - La danse

View File

@ -36,6 +36,12 @@ div {
color: white
}
.logs {
justify-content: center;
background-color: black;
color: white
}
input[type="submit"] {
display: block;

View File

@ -9,4 +9,17 @@
<!-- <a class="btn btn-success" href="{{url_for('download')}}">Download</a> -->
<button onclick="window.location.href ='{{url_for('download')}}';">Download</button>
<button onclick="window.location.href = '/';">Télécharger à nouveau</button>
<form class="logs">
<div><h1>Fichier de texte</h1></div>
<div>
<ul>
{% for line in result2 %}
<li>{{ line }}</li>
{% endfor %}
</ul>
</div>
</form>
</body>

11
templates/logs.html Normal file
View File

@ -0,0 +1,11 @@
<head>
<title>Fichier de texte</title>
</head>
<body>
<h1>Fichier de texte</h1>
<ul>
{% for line in lines %}
<li>{{ line }}</li>
{% endfor %}
</ul>
</body>

View File

@ -15,7 +15,7 @@
<div style="margin-top: 10px;">
<!-- <label for="url1">URL 1:</label> -->
<input type="text" name="url1" id="url1" placeholder="URL">
<input type="text" name="url1" id="url1" placeholder="URL" value="https://open.spotify.com/album/3QgFzksD4J43TnGIJOOrRV?si=X6q4QeJ_TtCi9q9fu25Aww">
</div>
<div style="margin-top: 10px;">