3 Commits

Author SHA1 Message Date
007416f1a9 Mise à jour de 'app.py'
All checks were successful
continuous-integration/drone/push Build is passing
Correction d'une erreur suite au retrait de deux champs d'entrées dans index.html
2023-06-05 22:32:32 +02:00
0696c81a83 Changes to be committed:
All checks were successful
continuous-integration/drone/push Build is passing
deleted:    __pycache__/app.cpython-310.pyc
	modified:   templates/index.html

Suppresion de 2 entrées sur cinq au niveau de index.html
2023-06-04 21:13:51 +02:00
c5f736eddf Changes to be committed:
All checks were successful
continuous-integration/drone/push Build is passing
new file:   .drone.yml

Changes not staged for commit:
	deleted:    __pycache__/app.cpython-310.pyc
	modified:   templates/index.html

Suppression de deux entrées sur cinq au niveau de index.html
2023-06-04 20:54:48 +02:00
5 changed files with 74 additions and 11 deletions

54
.drone.yml Normal file
View File

@@ -0,0 +1,54 @@
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
- v1.0.1
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:
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:
status: [failure]

Binary file not shown.

22
app.py
View File

@@ -1,6 +1,8 @@
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__)
@@ -11,7 +13,7 @@ def process_file(urls):
download_param_track = '{artist}/{album}/{artist} - {title}'
os.chdir('downloads')
os.system(f'rm -rf *')
# os.system(f'rm -rf *')
for url in urls:
if url:
@@ -21,7 +23,8 @@ def process_file(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.system(f'zip -r musics.zip ./downloads')
# run(['zip', '-r', 'musics.zip', '.'])
os.chdir('../')
@@ -29,9 +32,20 @@ def process_file(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():
# 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':
url1 = request.form['url1']
url2 = request.form['url2']
@@ -53,10 +67,6 @@ def download_file():
# return send_file(path, as_attachment=True)
return render_template('finish.html')
@app.route('/zip', methods=['GET', 'POST'])
def zip():
path = "downloads/musics.zip"
return send_file(path, as_attachment=True)
@app.errorhandler(404)
def page_not_found(error): # error est necessaire

View File

@@ -5,8 +5,7 @@
<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>
<h2> Téléchargement terminé </h2>
<button class="btn" onclick="window.location.href = '/';">Accueil</button>
{% if message %}

View File

@@ -32,13 +32,13 @@
<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()">Démarrer</button>
</div> -->
<button type="submit" class="btn" id="download-button" onclick="startDownload()">Télécharger</button>
<button type="reset" class="btn" id="refresh-button" onclick="refreshPage()">Rafraîchir</button>
</form>
</div>