This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.config/bash/module/Vdl.sh

40 lines
1.2 KiB
Bash
Raw Normal View History

2023-12-07 05:23:53 +03:00
# Download video from URL. When no `[LINK]` specified, it tries to update previously downloaded link.
# Usage: vdl [LINK]
2023-12-07 01:44:42 +03:00
function vdl() {
2023-12-05 21:50:45 +03:00
# Check that ffmpeg and ffprobe are available.
if [[ "$(ffmpeg -version)" = "" ]] || [[ "$(ffprobe -version)" = "" ]]; then
_error "ffmpeg and ffprobe are required."
2023-12-05 21:50:45 +03:00
return 1
fi
2023-12-05 21:50:45 +03:00
local target="${@}" # What to download/update.
2023-08-08 16:24:15 +03:00
2023-12-30 22:21:42 +03:00
# If no [LINK] provided, try to read from `Src.txt`.
[[ "${target}" = "" ]] && target="$(cat Src.txt)"
2023-08-08 16:24:15 +03:00
2023-12-05 21:50:45 +03:00
# If could not get [LINK] eventually, show an error and exit.
if [[ "${target}" = "" ]]; then
_error "Could not determine [LINK] to download."
2023-12-07 04:02:47 +03:00
help vdl
2023-12-05 21:50:45 +03:00
return 2
fi
2023-08-08 16:24:15 +03:00
2023-12-05 21:50:45 +03:00
# Save [LINK] for later use.
2023-12-30 22:21:42 +03:00
[[ -f "Src.txt" ]] || echo "${target}" > Src.txt
2023-12-05 21:50:45 +03:00
# Download [LINK] content.
2023-12-30 22:21:42 +03:00
yt-dlp -f 'bestvideo[height<=?1081]+bestaudio/best' --download-archive Index.txt --embed-thumbnail --embed-subs --write-auto-subs --embed-metadata --merge-output-format mkv -cio '%(playlist_index)000006d_%(id)s.%(ext)s' ${target} # || _vdl_retry
}
2023-12-07 04:02:47 +03:00
# Temporary fix for vk downloads.
# Usage: vdl_vk <LINK>
2023-12-07 01:44:42 +03:00
function vdl_vk() {
2023-12-07 00:42:06 +03:00
vdl --format mp4 "${@}"
}
2023-11-24 02:29:38 +03:00
2023-12-07 04:02:47 +03:00
# Download all videos from file with links.
# Usage: vdl_file <FILE>
2023-12-07 01:44:42 +03:00
function vdl_file() {
2023-12-07 00:42:06 +03:00
vdl -a "${@}"
}