2023-12-07 05:23:53 +03:00
|
|
|
# Download video from URL. When no `[LINK]` specified, it tries to update previously downloaded link.
|
2023-11-03 15:45:24 +03:00
|
|
|
# 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
|
2023-12-27 14:05:07 +03:00
|
|
|
_error "ffmpeg and ffprobe are required."
|
2023-12-05 21:50:45 +03:00
|
|
|
return 1
|
|
|
|
fi
|
2023-11-03 23:24:25 +03:00
|
|
|
|
2023-12-05 21:50:45 +03:00
|
|
|
local target="${@}" # What to download/update.
|
2023-08-08 16:24:15 +03:00
|
|
|
|
2023-12-05 21:50:45 +03:00
|
|
|
# If no [LINK] provided, try to read from `src.txt`.
|
2023-12-07 04:02:47 +03:00
|
|
|
[[ "${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
|
2023-12-27 14:05:07 +03:00
|
|
|
_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.
|
|
|
|
[[ -f "src.txt" ]] || echo "${target}" > src.txt
|
2023-11-03 15:45:24 +03:00
|
|
|
|
2023-12-05 21:50:45 +03:00
|
|
|
# Download [LINK] content.
|
|
|
|
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-11-20 13:05:41 +03:00
|
|
|
}
|
|
|
|
|
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 "${@}"
|
|
|
|
}
|