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

32 lines
1.1 KiB
Bash
Raw Normal View History

# Download video from URL in background. When no [LINK] specified, it tries to update previously downloaded link.
# Usage: vdl [LINK]
2023-08-08 16:24:15 +03:00
vdl()
{
# 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 2
fi
local target="${@}" # What to download/update.
2023-08-08 16:24:15 +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
# 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}"
echo "Usage: vdl [LINK]"
return 1
fi
2023-08-08 16:24:15 +03:00
# Save [LINK] for later use.
2023-11-10 03:32:18 +03:00
[[ -f "src.txt" ]] || echo "${target}" > src.txt
# 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}"
2023-08-08 16:24:15 +03:00
}
# download all videos from file.
alias vdl_file="vdl -a"