From 45b442efcd149b8b83f61c23cd436e2d89063ed2 Mon Sep 17 00:00:00 2001 From: Grizouille Date: Sat, 8 Nov 2025 17:43:18 +0100 Subject: [PATCH 1/6] page parametres --- README.md | 15 +++----- deezer_downloader/web/app.py | 26 +++++--------- deezer_downloader/web/static/css/custom.css | 12 +++++++ deezer_downloader/web/static/js/custom.js | 19 ++++++++++ deezer_downloader/web/templates/index.html | 40 +++++++++++++++++---- 5 files changed, 77 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 2b9dd5f..46f0f38 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,17 @@ -# đŸŽ” Deezer Downloader for Nextcloud +# đŸŽ” Deezer Downloader for Nextcloud WebDav ## đŸ§© Description Ce projet a pour objectif d’évoluer en une **application Nextcloud**. -Pour l’instant, il s’agit d’une **application externe**. +Pour l’instant, il s’agit d’une **application externe utilasant WEBDAV **. Le projet est basĂ© sur le dĂ©pĂŽt GitHub de [deezer-downloader](https://github.com/kmille/deezer-downloader). Un grand merci aux auteurs pour leur excellent travail ! ## ❓ Pourquoi -Je souhaitais intĂ©grer Ă  **Nextcloud** un **raccourci** permettant aux utilisateurs de **tĂ©lĂ©charger leur musique, playlists, albums**, etc., directement depuis **Deezer**. +Je souhaitais intĂ©grer Ă  **Nextcloud** un **raccourci** permettant aux utilisateurs de **tĂ©lĂ©charger leur musique, playlists, albums**, etc., directement depuis **Nextcloud**. +Les tĂ©lĂ©chargement sont directement accessible des **Fichiers** de Nextcloud. Vous pouvez aussi choisir un rĂ©pertoire situĂ© dans le dossier de syncronisation de l'application interne **Musique** pour profiter directement du tĂ©lĂ©chargement sur une appli de streaming style subsonic... ## 🔧 Modifications apportĂ©es par rapport au dĂ©pĂŽt original @@ -19,14 +20,6 @@ Je souhaitais intĂ©grer Ă  **Nextcloud** un **raccourci** permettant aux utilisa * đŸȘ Utilisation d’un **cookie** pour sauvegarder le rĂ©pertoire de destination choisi par l’utilisateur. * đŸš« VĂ©rification de la **connexion Ă  Nextcloud** : si non connectĂ© → retour **403 Forbidden**. -## ⚠ Limites actuelles - -* 💡 Fonctionne uniquement avec le plugin **AppExterne**. -* đŸ‘„ Pas de gestion de **sessions utilisateurs sĂ©parĂ©es** : - il est possible que le rĂ©pertoire de destination ne soit pas correct si deux utilisateurs tĂ©lĂ©chargent simultanĂ©ment. - Cependant, chaque utilisateur ayant son propre cookie, cela **devrait fonctionner correctement** dans la plupart des cas. - - ## Dev sous windows (vsCode): Pour que powershell accepte d'exĂ©cuter des scripts: diff --git a/deezer_downloader/web/app.py b/deezer_downloader/web/app.py index 62967a0..6a9cc9a 100644 --- a/deezer_downloader/web/app.py +++ b/deezer_downloader/web/app.py @@ -6,7 +6,6 @@ import requests import atexit from flask import Flask, render_template, request, jsonify, session from markupsafe import escape -from flask_autoindex import AutoIndex import warnings import giphypop @@ -17,8 +16,6 @@ from deezer_downloader.nextcloud import addJwtInUserSession app = Flask(__name__) app.secret_key = "vilvhmqerjgĂčqrgojpĂčqjgvnĂčzevoijrpĂčvqpzejgijzepgĂčg" -auto_index = AutoIndex(app, config["download_dirs"]["base"], add_url_rules=False) -auto_index.add_icon_rule('music.png', ext='m3u8') warnings.filterwarnings("ignore", message="You are using the giphy public api key") giphy = giphypop.Giphy() @@ -95,6 +92,14 @@ def index(): static_root=config["http"]["static_root"], use_mpd=str(config['mpd'].getboolean('use_mpd')).lower()) +@app.route("/save_config", methods=['POST']) +@validate_schema("login", "password", "dirPath") +def parameters(): + user_input = request.get_json(force=True) + dir = user_input['dirPath'] + + #return jsonify({'error': 'Champs requis manquants'}), 400 + return jsonify() @app.route("/debug") def show_debug(): @@ -110,21 +115,6 @@ def show_debug(): return jsonify({'debug_msg': stdout.decode()}) -@app.route("/downloads/") -@app.route("/downloads/") -def autoindex(path="."): - # directory index - flask version (let the user download mp3/zip in the browser) - try: - gif = giphy.random_gif(tag="cat") - media_url = gif.media_url - except requests.exceptions.HTTPError: - # the api is rate-limited. Fallback: - media_url = "https://cataas.com/cat" - - template_context = {'gif_url': media_url} - return auto_index.render_autoindex(path=session['user_base_dir'], template_context=template_context) - - @app.route('/queue', methods=['GET']) def show_queue(): """ diff --git a/deezer_downloader/web/static/css/custom.css b/deezer_downloader/web/static/css/custom.css index 86a62a4..e72e2e3 100644 --- a/deezer_downloader/web/static/css/custom.css +++ b/deezer_downloader/web/static/css/custom.css @@ -83,4 +83,16 @@ h3, th, td { .btn { color: white !important; +} + +form { + background-color: #292929; + border-radius: 8px; + padding: 30px; + max-width: 500px; + margin: 60px auto; + box-shadow: 0 0 15px rgba(0,0,0,0.5); +} +form label { + color: white; } \ No newline at end of file diff --git a/deezer_downloader/web/static/js/custom.js b/deezer_downloader/web/static/js/custom.js index 2a849ed..ceec5d5 100644 --- a/deezer_downloader/web/static/js/custom.js +++ b/deezer_downloader/web/static/js/custom.js @@ -293,6 +293,25 @@ $(document).ready(function() { }); // END DEEZER FAVORITE SONGS + $('#paramters').on('submit', function(e) { + e.preventDefault(); + $.ajax({ + url: deezer_downloader_api_root + '/save_config', + type: 'POST', + contentType: 'application/json', // essentiel pour Flask.get_json() + data: JSON.stringify({ dirPath: $('#param-directry-path').val(), + login: $('#param-login').val(), + password: $('#param-password').val()}), + success: function(response) { + $.jGrowl("Sauvegarder avec succĂšs", { life: 4000 }); + }, + error: function(xhr) { + const err = xhr.responseJSON?.error || 'Erreur inconnue'; + $('#result').css('color', 'red').text(err); + } + }); + }); + function show_tab(id_nav, id_content) { // nav diff --git a/deezer_downloader/web/templates/index.html b/deezer_downloader/web/templates/index.html index 705bfd2..9750e7d 100644 --- a/deezer_downloader/web/templates/index.html +++ b/deezer_downloader/web/templates/index.html @@ -57,6 +57,9 @@ + @@ -105,15 +108,15 @@

Download stuff via youtube-dl

- +  

- - - - - + + + + +
@@ -188,6 +191,31 @@
+
+
+

Configuration

+ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+ + +