# Download video from URL. When no `[LINK]` specified, it tries to update previously downloaded link. # Usage: vdl [LINK] function vdl() { # Check that ffmpeg and ffprobe are available. if [[ "$(ffmpeg -version)" = "" ]] || [[ "$(ffprobe -version)" = "" ]]; then _error "ffmpeg and ffprobe are required." return 1 fi local target="${@}" # What to download/update. # If no [LINK] provided, try to read from `src.txt`. [[ "${target}" = "" ]] && target="$(cat src.txt)" # If could not get [LINK] eventually, show an error and exit. if [[ "${target}" = "" ]]; then _error "Could not determine [LINK] to download." help vdl return 2 fi # Save [LINK] for later use. [[ -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} # || _vdl_retry } # Temporary fix for vk downloads. # Usage: vdl_vk function vdl_vk() { vdl --format mp4 "${@}" } # Download all videos from file with links. # Usage: vdl_file function vdl_file() { vdl -a "${@}" }