clean and add yt dl video
This commit is contained in:
@@ -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,14 +42,22 @@ 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 ""
|
||||
youtube_dl_cmd = config["youtubedl"]["command"] + \
|
||||
proxy_command + \
|
||||
" -x --audio-format mp3 " + \
|
||||
"--audio-quality 0 " + \
|
||||
f"-o '{destination_dir}/%(title)s.%(ext)s' " + \
|
||||
"--embed-metadata " + \
|
||||
"--no-embed-chapters " + \
|
||||
quote(url)
|
||||
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\" " + \
|
||||
"--embed-metadata " + \
|
||||
"--no-embed-chapters " + \
|
||||
quote(url)
|
||||
|
||||
filename_absolute = execute(youtube_dl_cmd)
|
||||
return filename_absolute
|
||||
|
||||
Reference in New Issue
Block a user