clean and add yt dl video
This commit is contained in:
Binary file not shown.
@@ -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), })
|
||||
|
||||
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<a class="nav-link active" id="nav-songs-albums" data-toggle="tab" href="#songs_albums">Songs/Albums (1)</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="nav-youtubedl" data-toggle="tab" href="#youtubedl">Youtube-dl (2)</a>
|
||||
<a class="nav-link" id="nav-youtubedl" data-toggle="tab" href="#youtubedl">Audio/Video downloader (2)</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="nav-spotify-playlists" data-toggle="tab" href="#spotify-playlists">Spotify Playlists (3)</a>
|
||||
@@ -106,7 +106,7 @@
|
||||
|
||||
<div id="youtubedl" class="container tab-pane fade">
|
||||
<br>
|
||||
<h3>Download stuff via youtube-dl</h3>
|
||||
<h3>Download audio files via youtube-dl</h3>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="youtubedl-query" placeholder="Download audio from YouTube, Invidious, Vimeo, Soundcloud, ... " />
|
||||
|
||||
@@ -117,6 +117,18 @@
|
||||
<button type="button" class="btn btn-info" id="yt_download">Download</button>
|
||||
<button type="button" class="btn btn-info" onclick="$('#youtubedl-query').val('')" >Clear</button>
|
||||
</span>
|
||||
<br/>
|
||||
<br/>
|
||||
<h3>Download video files via youtube-dl</h3>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="youtubedl-query-video" placeholder="Download video from YouTube, Invidious, Vimeo, Soundcloud, ... " />
|
||||
|
||||
</div>
|
||||
<br>
|
||||
<span class="input-group-btn">
|
||||
<button type="button" class="btn btn-info" id="yt_download_video">Download</button>
|
||||
<button type="button" class="btn btn-info" onclick="$('#youtubedl-query-video').val('')" >Clear</button>
|
||||
</span>
|
||||
</div> <!-- end div tab youtube-dl -->
|
||||
|
||||
<div id="spotify-playlists" class="container tab-pane fade">
|
||||
|
||||
@@ -32,7 +32,7 @@ def get_absolute_filename(stdout, stderr):
|
||||
return regex_foo.group(1)
|
||||
|
||||
|
||||
def youtubedl_download(url, destination_dir, proxy=None):
|
||||
def youtubedl_download(url, destination_dir, proxy=None, video=False):
|
||||
# url, e.g. https://www.youtube.com/watch?v=ZbZSe6N_BXs
|
||||
# destination_dir: /tmp/
|
||||
# proxy: https/socks5 proxy (e. g. socks5://user:pass@127.0.0.1:1080/)
|
||||
@@ -42,11 +42,19 @@ def youtubedl_download(url, destination_dir, proxy=None):
|
||||
# DownloadedFileNotFoundException if we cannot get the converted output file from youtube-dl with a regex
|
||||
|
||||
proxy_command = f" --proxy {proxy}" if proxy else ""
|
||||
if video:
|
||||
youtube_dl_cmd = config["youtubedl"]["command"] + \
|
||||
proxy_command + \
|
||||
" -f \"best\" " + \
|
||||
"--merge-output-format mp4 " + \
|
||||
f"-o \"{destination_dir}/%(title)s.%(ext)s\" " + \
|
||||
quote(url)
|
||||
else:
|
||||
youtube_dl_cmd = config["youtubedl"]["command"] + \
|
||||
proxy_command + \
|
||||
" -x --audio-format mp3 " + \
|
||||
"--audio-quality 0 " + \
|
||||
f"-o '{destination_dir}/%(title)s.%(ext)s' " + \
|
||||
f"-o \"{destination_dir}/%(title)s.%(ext)s\" " + \
|
||||
"--embed-metadata " + \
|
||||
"--no-embed-chapters " + \
|
||||
quote(url)
|
||||
|
||||
Reference in New Issue
Block a user