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.3 KiB
Bash
Raw Normal View History

2023-12-07 04:02:47 +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
echo -e "${color_red}ffmpeg and ffprobe are required.${color_default}"
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-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
echo -e "${color_red}Could not determine [LINK] to download.${color_default}"
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-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-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 "${@}"
}