Compare commits
4 Commits
007416f1a9
...
bc4780190b
Author | SHA1 | Date | |
---|---|---|---|
bc4780190b | |||
8010de522d | |||
9c831ce473 | |||
74e936c0f8 |
41
.drone.yml
41
.drone.yml
@ -29,7 +29,7 @@ steps:
|
|||||||
# auto_tag: true
|
# auto_tag: true
|
||||||
tags:
|
tags:
|
||||||
- latest
|
- latest
|
||||||
- v1.0.1
|
- v2.0.0
|
||||||
when:
|
when:
|
||||||
branch: main
|
branch: main
|
||||||
|
|
||||||
@ -41,6 +41,7 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- curl -d "La pipeline a réussi" $NOTIFY_URL
|
- curl -d "La pipeline a réussi" $NOTIFY_URL
|
||||||
when:
|
when:
|
||||||
|
branch: main
|
||||||
status: [ success ]
|
status: [ success ]
|
||||||
|
|
||||||
- name: notify_failure
|
- name: notify_failure
|
||||||
@ -51,4 +52,42 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- curl -d "La pipeline a échoué" $NOTIFY_URL
|
- curl -d "La pipeline a échoué" $NOTIFY_URL
|
||||||
when:
|
when:
|
||||||
|
branch: main
|
||||||
|
status: [failure]
|
||||||
|
|
||||||
|
- name: docker_dev_gitea
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
repo: git.netpowa.fr/guillaume/spotdlweb
|
||||||
|
# auto_tag: true
|
||||||
|
registry: git.netpowa.fr
|
||||||
|
tags:
|
||||||
|
- beta
|
||||||
|
when:
|
||||||
|
branch: dev
|
||||||
|
|
||||||
|
- name: notify_dev_success
|
||||||
|
image: curlimages/curl
|
||||||
|
environment:
|
||||||
|
NOTIFY_URL:
|
||||||
|
from_secret: ntfy_url
|
||||||
|
commands:
|
||||||
|
- curl -d "La pipeline dev a réussi" $NOTIFY_URL
|
||||||
|
when:
|
||||||
|
branch: dev
|
||||||
|
status: [ success ]
|
||||||
|
|
||||||
|
- name: notify_dev_failure
|
||||||
|
image: curlimages/curl
|
||||||
|
environment:
|
||||||
|
NOTIFY_URL:
|
||||||
|
from_secret: ntfy_url
|
||||||
|
commands:
|
||||||
|
- curl -d "La pipeline dev a échoué" $NOTIFY_URL
|
||||||
|
when:
|
||||||
|
branch: dev
|
||||||
status: [failure]
|
status: [failure]
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
__pycache__
|
__pycache__
|
||||||
downloads/
|
downloads/
|
||||||
|
temp/
|
54
app.py
54
app.py
@ -28,6 +28,27 @@ def process_file(urls):
|
|||||||
os.chdir('../')
|
os.chdir('../')
|
||||||
|
|
||||||
|
|
||||||
|
def process_file_local(urls):
|
||||||
|
download_param_album = '{artist}/{album}/{artist} - {title}'
|
||||||
|
download_param_playlist = '{playlist}/{artists}/{album} - {title} {artist}'
|
||||||
|
download_param_track = '{artist}/{album}/{artist} - {title}'
|
||||||
|
|
||||||
|
os.chdir('temp')
|
||||||
|
os.system(f'rm -rf *')
|
||||||
|
|
||||||
|
for url in urls:
|
||||||
|
if url:
|
||||||
|
if "album" in url:
|
||||||
|
run(['python3', '-m', 'spotdl', url, '--output', download_param_album])
|
||||||
|
elif "playlist" in url:
|
||||||
|
run(['python3', '-m', 'spotdl', url, '--output', download_param_playlist])
|
||||||
|
elif "track" in url:
|
||||||
|
run(['python3', '-m', 'spotdl', url, '--output', download_param_track])
|
||||||
|
|
||||||
|
run(['zip', '-r', 'musics.zip', '.'])
|
||||||
|
os.chdir('../')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/', methods=['GET', 'POST'])
|
@app.route('/', methods=['GET', 'POST'])
|
||||||
def upload_form():
|
def upload_form():
|
||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
@ -41,12 +62,8 @@ def upload_form():
|
|||||||
|
|
||||||
@app.route('/download', methods=['POST'])
|
@app.route('/download', methods=['POST'])
|
||||||
def download_file():
|
def download_file():
|
||||||
# votre code de téléchargement ici
|
|
||||||
# now = datetime.now()
|
|
||||||
# date_time = now.strftime("%Y-%m-%d %H-%M-%S")
|
|
||||||
# with open(f"file.txt", "w") as file:
|
|
||||||
# file.write(date_time)
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
action = request.form.get('action')
|
||||||
url1 = request.form['url1']
|
url1 = request.form['url1']
|
||||||
url2 = request.form['url2']
|
url2 = request.form['url2']
|
||||||
url3 = request.form['url3']
|
url3 = request.form['url3']
|
||||||
@ -57,16 +74,31 @@ def download_file():
|
|||||||
if not url1 and not url2 and not url3 :
|
if not url1 and not url2 and not url3 :
|
||||||
return render_template('erreur.html')
|
return render_template('erreur.html')
|
||||||
|
|
||||||
|
if action == 'download':
|
||||||
# Créer le dossier 'downloads' s'il n'existe pas
|
# Créer le dossier 'downloads' s'il n'existe pas
|
||||||
if not os.path.exists('downloads'):
|
if not os.path.exists('downloads'):
|
||||||
os.makedirs('downloads')
|
os.makedirs('downloads')
|
||||||
|
|
||||||
process_file(urls)
|
process_file(urls)
|
||||||
|
|
||||||
# path = "downloads/musics.zip"
|
# path = "downloads/musics.zip"
|
||||||
# return send_file(path, as_attachment=True)
|
# return send_file(path, as_attachment=True)
|
||||||
return render_template('finish.html')
|
return render_template('finish_server.html')
|
||||||
|
|
||||||
|
if action == 'downloadlocal':
|
||||||
|
|
||||||
|
# Créer le dossier 'downloads' s'il n'existe pas
|
||||||
|
if not os.path.exists('temp'):
|
||||||
|
os.makedirs('temp')
|
||||||
|
|
||||||
|
process_file_local(urls)
|
||||||
|
|
||||||
|
return render_template('finish_local.html')
|
||||||
|
|
||||||
|
@app.route('/zip', methods=['GET', 'POST'])
|
||||||
|
def zip():
|
||||||
|
path = "temp/musics.zip"
|
||||||
|
return send_file(path, as_attachment=True)
|
||||||
|
|
||||||
@app.errorhandler(404)
|
@app.errorhandler(404)
|
||||||
def page_not_found(error): # error est necessaire
|
def page_not_found(error): # error est necessaire
|
||||||
|
11
docker-compose.yaml
Normal file
11
docker-compose.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
version: '3.3'
|
||||||
|
services:
|
||||||
|
spotdlweb:
|
||||||
|
image: gu1llaum3/spotdlweb:latest
|
||||||
|
container_name: spotdlweb
|
||||||
|
hostname: spotdlweb
|
||||||
|
ports:
|
||||||
|
- 3000:3000
|
||||||
|
volumes:
|
||||||
|
- ./musics:/app/downloads
|
||||||
|
restart: unless-stopped
|
@ -1,6 +1,9 @@
|
|||||||
function startDownload() {
|
function startDownload() {
|
||||||
document.getElementById('download-button').innerHTML = 'Téléchargement en cours...';
|
document.getElementById('download-button').innerHTML = 'Téléchargement en cours...';
|
||||||
}
|
}
|
||||||
|
function startLocalDownload() {
|
||||||
|
document.getElementById('downloadlocal-button').innerHTML = 'Téléchargement en cours...';
|
||||||
|
}
|
||||||
function refreshPage() {
|
function refreshPage() {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
19
templates/finish_local.html
Normal file
19
templates/finish_local.html
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{% extends 'layout.html' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1 class="title"> SpotDL Web </h1>
|
||||||
|
<h2>Votre musique est prête à être téléchargée</h2>
|
||||||
|
<button class="btn" onclick="window.location.href = '/zip';">Télécharger</button>
|
||||||
|
<button class="btn" onclick="window.location.href = '/';">Accueil</button>
|
||||||
|
|
||||||
|
{% if message %}
|
||||||
|
<p>{{ message }}</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
{% endblock body %}
|
@ -38,8 +38,9 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" class="form-control" name="url5" id="url5" pattern="^https://open\.spotify\.com/(?:album|playlist|track)/[\w-]+(?:\?si=[\w-]+)?$" placeholder="Entrez l'URL d'une Piste, d'un Album ou d'une Playlist">
|
<input type="text" class="form-control" name="url5" id="url5" pattern="^https://open\.spotify\.com/(?:album|playlist|track)/[\w-]+(?:\?si=[\w-]+)?$" placeholder="Entrez l'URL d'une Piste, d'un Album ou d'une Playlist">
|
||||||
</div> -->
|
</div> -->
|
||||||
<button type="submit" class="btn" id="download-button" onclick="startDownload()">Télécharger</button>
|
<button type="submit" class="btn" id="download-button" onclick="startDownload()" name="action" value="download">Télécharger sur le serveur</button>
|
||||||
<button type="reset" class="btn" id="refresh-button" onclick="refreshPage()">Rafraîchir</button>
|
<button type="submit" class="btn" id="downloadlocal-button" onclick="startLocalDownload()" name="action" value="downloadlocal">Télécharger en local</button>
|
||||||
|
<!-- <button type="reset" class="btn" id="refresh-button" onclick="refreshPage()">Rafraîchir</button> -->
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user