Compare commits

..

2 Commits
main ... ddl

Author SHA1 Message Date
2924550be6 Mise à jour de 'app.py'
Correction d'un problème suite au retrait de deux champs d'entrées sur index.html
2023-06-05 22:30:23 +02:00
9b04348b32 On branch ddl
Changes to be committed:
	modified:   app.py
	modified:   templates/finish.html
	modified:   templates/index.html
Téléchargement direct d'un fichier zip puis supprime le dossier.
2023-05-29 12:31:01 +02:00
11 changed files with 20 additions and 233 deletions

View File

@ -1,93 +0,0 @@
kind: pipeline
name: default
steps:
- name: docker_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:
- latest
- v1.0.1
when:
branch: main
- name: docker_hub
image: plugins/docker
settings:
username:
from_secret: dockerhub_username
password:
from_secret: dockerhub_password
repo: gu1llaum3/spotdlweb
# auto_tag: true
tags:
- latest
- v2.0.0
when:
branch: main
- name: notify_success
image: curlimages/curl
environment:
NOTIFY_URL:
from_secret: ntfy_url
commands:
- curl -d "La pipeline a réussi" $NOTIFY_URL
when:
branch: main
status: [ success ]
- name: notify_failure
image: curlimages/curl
environment:
NOTIFY_URL:
from_secret: ntfy_url
commands:
- curl -d "La pipeline a échoué" $NOTIFY_URL
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]

3
.gitignore vendored
View File

@ -1,3 +1,2 @@
__pycache__
downloads/
temp/
downloads/

View File

@ -1,19 +0,0 @@
# SpotDLWeb
SpotDLWeb est une interface graphique pour Spotdl et qui à l'aide de Python via Flask.
Il permet de récupérer les métadonnées à l'aide de Spotify puis de télécharger la musique via Youtube Music. La musique peut-être téléchargée directement sur un serveur connecté à Navidrone ou encore Jellyfin ou, télécharger la musique directement en local.
**docker-compose.yaml :**
```yaml
version: '3.3'
services:
spotdlweb:
image: gu1llaum3/spotdlweb:latest
container_name: spotdlweb
hostname: spotdlweb
ports:
- 3000:3000
volumes:
- ./path/to/musics:/app/downloads
restart: unless-stopped
```

Binary file not shown.

56
app.py
View File

@ -1,8 +1,6 @@
from flask import Flask, request, redirect, url_for, send_file, render_template, send_from_directory
from subprocess import run
from datetime import datetime
import os
import logging
app = Flask(__name__)
@ -13,27 +11,6 @@ def process_file(urls):
download_param_track = '{artist}/{album}/{artist} - {title}'
os.chdir('downloads')
# 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])
# os.system(f'zip -r musics.zip ./downloads')
# run(['zip', '-r', 'musics.zip', '.'])
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:
@ -44,7 +21,6 @@ def process_file_local(urls):
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('../')
@ -53,17 +29,10 @@ def process_file_local(urls):
def upload_form():
return render_template('index.html')
# Fonctionne
# @app.route('/download/<filename>')
# def download_file(filename):
# PATH='file.txt'
# return send_file(PATH, as_attachment=True)
@app.route('/download', methods=['POST'])
def download_file():
if request.method == 'POST':
action = request.form.get('action')
url1 = request.form['url1']
url2 = request.form['url2']
url3 = request.form['url3']
@ -74,30 +43,19 @@ def download_file():
if not url1 and not url2 and not url3 :
return render_template('erreur.html')
if action == 'download':
# Créer le dossier 'downloads' s'il n'existe pas
if not os.path.exists('downloads'):
os.makedirs('downloads')
if not os.path.exists('downloads'):
os.makedirs('downloads')
process_file(urls)
process_file(urls)
# path = "downloads/musics.zip"
# return send_file(path, as_attachment=True)
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')
# path = "downloads/musics.zip"
# return send_file(path, as_attachment=True)
return render_template('finish.html')
@app.route('/zip', methods=['GET', 'POST'])
def zip():
path = "temp/musics.zip"
path = "downloads/musics.zip"
return send_file(path, as_attachment=True)
@app.errorhandler(404)

View File

@ -1,11 +0,0 @@
version: '3.3'
services:
spotdlweb:
image: gu1llaum3/spotdlweb:latest
container_name: spotdlweb
hostname: spotdlweb
ports:
- 3000:3000
volumes:
- ./musics:/app/downloads
restart: unless-stopped

View File

@ -15,8 +15,8 @@ body {
.bordered {
border: 1px solid rgb(24,216,96);
border-radius: 5px;
padding: 10px;
margin-bottom: 15px;
padding: 20px;
margin-bottom: 20px;
}
li {
@ -66,14 +66,14 @@ body {
background-color: rgb(24,216,96);
border: none;
border-radius: 5px;
padding: 10px 10px;
padding: 10px 20px;
color: #131313;
font-weight: bold;
cursor: pointer;
text-decoration:none
}
/* .btn2 {
.btn2 {
margin-top: 10px;
background-color: rgb(24,216,96);
border: none;
@ -83,7 +83,7 @@ body {
font-weight: bold;
cursor: pointer;
text-decoration:none
} */
}
.btn:hover {
background-color: rgb(24,216,96);
@ -97,5 +97,4 @@ body {
@media (max-width: 600px) {
.container {
padding: 10px;
}
}
}

View File

@ -1,33 +1,6 @@
function startDownload() {
var downloadButton = document.getElementById('download-button');
var downloadLocalButton = document.getElementById('downloadlocal-button');
if (downloadButton.style.display !== 'none') {
downloadButton.style.display = 'none';
downloadLocalButton.style.display = 'block';
} else {
downloadButton.style.display = 'block';
downloadLocalButton.style.display = 'none';
document.getElementById('download-button').innerHTML = 'Téléchargement en cours...';
}
downloadLocalButton.innerHTML = 'Téléchargement en cours...';
}
function startLocalDownload() {
var downloadButton = document.getElementById('download-button');
var downloadLocalButton = document.getElementById('downloadlocal-button');
if (downloadLocalButton.style.display !== 'none') {
downloadLocalButton.style.display = 'none';
downloadButton.style.display = 'block';
} else {
downloadLocalButton.style.display = 'block';
downloadButton.style.display = 'none';
}
downloadButton.innerHTML = 'Téléchargement en cours...';
}
function refreshPage() {
window.location.reload();
}

View File

@ -1,18 +0,0 @@
{% extends 'layout.html' %}
{% block body %}
<body>
<div class="container">
<h1 class="title"> SpotDL Web </h1>
<h2> Téléchargement terminé </h2>
<button class="btn" onclick="window.location.href = '/';">Accueil</button>
{% if message %}
<p>{{ message }}</p>
{% endif %}
</div>
</body>
{% endblock body %}

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8">
<link rel="stylesheet" href="static/css/style.css" , filename= 'style.css'>
<script src="/static/js/script.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SpotDL Web</title>
</head>
@ -32,15 +32,14 @@
<div class="form-group">
<input type="text" class="form-control" name="url3" id="url3" 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 class="form-group">
<div class="form-group">
<input type="text" class="form-control" name="url4" id="url4" 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 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">
</div> -->
<button type="submit" class="btn" id="download-button" onclick="startDownload()" name="action" value="download">Télécharger sur le serveur</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> -->
</div>
<button type="submit" class="btn" id="download-button" onclick="startDownload()">Démarrer</button>
<button type="reset" class="btn" id="refresh-button" onclick="refreshPage()">Rafraîchir</button>
</form>
</div>