Modifications
This commit is contained in:
parent
23d5d0d20d
commit
d2397191a0
Binary file not shown.
28
app.py
28
app.py
@ -1,4 +1,5 @@
|
|||||||
from flask import Flask, request, redirect, url_for, send_file, render_template
|
from flask import Flask, request, redirect, url_for, send_file, render_template
|
||||||
|
from subprocess import run
|
||||||
import os
|
import os
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@ -9,17 +10,19 @@ def upload_form():
|
|||||||
|
|
||||||
def process_file(urls):
|
def process_file(urls):
|
||||||
# path = os.path.expanduser('~/musics/downloads')
|
# path = os.path.expanduser('~/musics/downloads')
|
||||||
path = './downloads'
|
#path = '/home/gu1ll4um3/github/SpotDL_Web/downloads'
|
||||||
download_param_album = '{artist}/{album}/{artist} - {title}'
|
#path = 'downloads/'
|
||||||
|
download_param_album = 'downloads/{artist}/{album}/{artist} - {title}'
|
||||||
download_param_playlist = '{playlist}/{artists}/{album} - {title} {artist}'
|
download_param_playlist = '{playlist}/{artists}/{album} - {title} {artist}'
|
||||||
|
|
||||||
os.chdir(f"{path}")
|
#os.chdir(f"{path}")
|
||||||
os.system(f'rm -rf *')
|
#os.system(f'rm -rf *')
|
||||||
|
|
||||||
for url in urls:
|
for url in urls:
|
||||||
if url:
|
if url:
|
||||||
if "album" in 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:
|
elif "playlist" in url:
|
||||||
os.system(f'python3 -m spotdl {url} --output "{download_param_playlist}"')
|
os.system(f'python3 -m spotdl {url} --output "{download_param_playlist}"')
|
||||||
|
|
||||||
@ -41,8 +44,12 @@ def index():
|
|||||||
return render_template('erreur.html')
|
return render_template('erreur.html')
|
||||||
|
|
||||||
urls = [url1, url2, url3, url4, url5]
|
urls = [url1, url2, url3, url4, url5]
|
||||||
result = process_file(urls)
|
process_file(urls)
|
||||||
return render_template('download_complete.html')
|
#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'])
|
@app.route('/download', methods=['GET'])
|
||||||
def download():
|
def download():
|
||||||
@ -50,5 +57,12 @@ def download():
|
|||||||
PATH='./downloads/musics.zip'
|
PATH='./downloads/musics.zip'
|
||||||
return send_file(PATH,as_attachment=True)
|
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__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True, port=3000)
|
app.run(debug=True, port=3000)
|
||||||
|
Binary file not shown.
3
logs/erreurs.log
Normal file
3
logs/erreurs.log
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Des erreurs se sont produites et la ou les piste(s) suivante(s) sont manquantes :
|
||||||
|
|
||||||
|
Aldebert - La danse[0m
|
@ -36,6 +36,12 @@ div {
|
|||||||
color: white
|
color: white
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.logs {
|
||||||
|
justify-content: center;
|
||||||
|
background-color: black;
|
||||||
|
color: white
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
input[type="submit"] {
|
input[type="submit"] {
|
||||||
display: block;
|
display: block;
|
||||||
|
@ -9,4 +9,17 @@
|
|||||||
<!-- <a class="btn btn-success" href="{{url_for('download')}}">Download</a> -->
|
<!-- <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 ='{{url_for('download')}}';">Download</button>
|
||||||
<button onclick="window.location.href = '/';">Télécharger à nouveau</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>
|
</body>
|
||||||
|
11
templates/logs.html
Normal file
11
templates/logs.html
Normal 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>
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<div style="margin-top: 10px;">
|
<div style="margin-top: 10px;">
|
||||||
<!-- <label for="url1">URL 1:</label> -->
|
<!-- <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>
|
||||||
|
|
||||||
<div style="margin-top: 10px;">
|
<div style="margin-top: 10px;">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user