From 4b4eb94ff7c64653d853aa471526d8134e267bd3 Mon Sep 17 00:00:00 2001 From: Grizouille Date: Mon, 10 Nov 2025 10:56:29 +0100 Subject: [PATCH] clean and add yt dl video --- deezer_downloader/requirements.txt | Bin 958 -> 928 bytes deezer_downloader/web/app.py | 11 +++------ deezer_downloader/web/music_backend.py | 5 ++-- deezer_downloader/web/static/js/custom.js | 15 +++++++++++- deezer_downloader/web/templates/index.html | 16 +++++++++++-- deezer_downloader/youtubedl.py | 26 ++++++++++++++------- 6 files changed, 51 insertions(+), 22 deletions(-) diff --git a/deezer_downloader/requirements.txt b/deezer_downloader/requirements.txt index 5c06a85bf2e2c2475ff8efa1c61750d4d6066966..19ff834758214baa61a6c07c6aad706ce7f3ff33 100644 GIT binary patch delta 12 TcmdnTzJPs$7vts(#xN!T9UKGP delta 38 pcmZ3$zK?x_7o%i4LncE3Lk2@7kjw{STOc%G&|@&(?8+F;1OT^72vPt5 diff --git a/deezer_downloader/web/app.py b/deezer_downloader/web/app.py index 6a9cc9a..7d7d24e 100644 --- a/deezer_downloader/web/app.py +++ b/deezer_downloader/web/app.py @@ -2,12 +2,9 @@ import os from subprocess import Popen, PIPE from functools import wraps -import requests import atexit from flask import Flask, render_template, request, jsonify, session from markupsafe import escape -import warnings -import giphypop from deezer_downloader.configuration import config from deezer_downloader.web.music_backend import sched @@ -17,9 +14,6 @@ from deezer_downloader.nextcloud import addJwtInUserSession app = Flask(__name__) app.secret_key = "vilvhmqerjgùqrgojpùqjgvnùzevoijrpùvqpzejgijzepgùg" -warnings.filterwarnings("ignore", message="You are using the giphy public api key") -giphy = giphypop.Giphy() - def init(): sched.run_workers(config.getint('threadpool', 'workers')) @@ -180,7 +174,7 @@ def deezer_download_song_or_album(): @app.route('/youtubedl', methods=['POST']) -@validate_schema("url", "add_to_playlist") +@validate_schema("url", "add_to_playlist", "getVideo") def youtubedl_download(): """ takes an url and tries to download it via youtuble-dl @@ -193,7 +187,8 @@ def youtubedl_download(): task = sched.enqueue_task(desc, "download_youtubedl_and_queue", video_url=user_input['url'], add_to_playlist=user_input['add_to_playlist'], - uid_user=session['user_uid']) + uid_user=session['user_uid'], + video=user_input['getVideo']) return jsonify({"task_id": id(task), }) diff --git a/deezer_downloader/web/music_backend.py b/deezer_downloader/web/music_backend.py index 419e2aa..211dd89 100644 --- a/deezer_downloader/web/music_backend.py +++ b/deezer_downloader/web/music_backend.py @@ -232,11 +232,12 @@ def download_spotify_playlist_and_queue_and_zip(playlist_name, playlist_id, add_ @sched.register_command() -def download_youtubedl_and_queue(video_url, add_to_playlist, uid_user): +def download_youtubedl_and_queue(video_url, add_to_playlist, uid_user, video=False): check_and_set_download_dirs_exist(uid_user) filename_absolute = youtubedl_download(video_url, config["download_dirs"]["youtubedl"], - config["proxy"]["server"]) + config["proxy"]["server"], + video) call_scan(filename_absolute) update_mpd_db(filename_absolute, add_to_playlist) return make_song_paths_relative_to_mpd_root([filename_absolute]) diff --git a/deezer_downloader/web/static/js/custom.js b/deezer_downloader/web/static/js/custom.js index ceec5d5..aa19ac2 100644 --- a/deezer_downloader/web/static/js/custom.js +++ b/deezer_downloader/web/static/js/custom.js @@ -41,7 +41,16 @@ $(document).ready(function() { function youtubedl_download(add_to_playlist) { $.post(deezer_downloader_api_root + '/youtubedl', - JSON.stringify({ url: $('#youtubedl-query').val(), add_to_playlist: add_to_playlist }), + JSON.stringify({ url: $('#youtubedl-query').val(), add_to_playlist: add_to_playlist, getVideo: false }), + function(data) { + console.log(data); + $.jGrowl("As you wish", { life: 4000 }); + }); + } + + function youtubedl_download_video(add_to_playlist) { + $.post(deezer_downloader_api_root + '/youtubedl', + JSON.stringify({ url: $('#youtubedl-query-video').val(), add_to_playlist: add_to_playlist, getVideo: true}), function(data) { console.log(data); $.jGrowl("As you wish", { life: 4000 }); @@ -238,6 +247,10 @@ $(document).ready(function() { youtubedl_download(false); }); + $("#yt_download_video").click(function() { + youtubedl_download_video(false); + }); + $("#yt_download_play").click(function() { youtubedl_download(true); }); diff --git a/deezer_downloader/web/templates/index.html b/deezer_downloader/web/templates/index.html index 9750e7d..6c8de6a 100644 --- a/deezer_downloader/web/templates/index.html +++ b/deezer_downloader/web/templates/index.html @@ -46,7 +46,7 @@ Songs/Albums (1)