bash : vdl : combine vdl_update to vdl with no params and remove vdl_update_all in favor of using recursive
function.
This commit is contained in:
parent
c060e06edf
commit
e6b0eb08b4
|
@ -1,30 +1,25 @@
|
|||
# download video from URL in background.
|
||||
# Download video from URL in background. When no [LINK] specified, it tries to update previously downloaded link.
|
||||
# Usage: vdl [LINK]
|
||||
vdl()
|
||||
{
|
||||
echo "$@" > src.txt
|
||||
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' "$@"
|
||||
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
|
||||
echo -e "${color_red}Could not determine [LINK] to download.${color_default}"
|
||||
echo "Usage: vdl [LINK]"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Save [LINK] for later use.
|
||||
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}"
|
||||
}
|
||||
|
||||
# download all videos from file.
|
||||
alias vdl_file="vdl -a"
|
||||
|
||||
# update playlist.
|
||||
vdl_update()
|
||||
{
|
||||
local src="$(cat src.txt)"
|
||||
vdl "$src"
|
||||
}
|
||||
|
||||
# update all playlists recursively.
|
||||
vdl_update_all()
|
||||
{
|
||||
local root="$PWD"
|
||||
local dir
|
||||
for file in **/src.txt; do
|
||||
dir="${file%/*}"
|
||||
cd "$dir"
|
||||
echo "$PWD"
|
||||
vdl_update
|
||||
cd "$root"
|
||||
done
|
||||
}
|
||||
|
|
Reference in a new issue