Add twitter video download alias

This commit is contained in:
Michael Campagnaro 2022-08-03 18:05:57 -04:00
parent b78306c95b
commit 9ed266f056

53
aliases
View File

@ -682,6 +682,56 @@ dl_vimeo_vid() {
fi
}
# Download Twitter videos.
dl_twitter_vid() {
local format="$1"
local make_folder="$2"
local url="$3"
local vid_name="$4"
shift 4
local opts="$@"
if [[ $url == "" ]]; then
error "Format: $0 <make folder?> <url> <optional args>\n"
return
fi
printf "${BOLD}Downloading Twitter vid.${NORMAL}\n"
if [[ $vid_name == "" ]]; then
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-twitter-%(id)s"
else
local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-twitter-%(id)s"
fi
if [[ $make_folder == "1" ]]; then
make_vid_dir_and_cd_into $url $vid_name $opts
if [[ $? -ne 0 ]]; then
return
fi
fi
if [[ $format == "" ]]; then
printf "${BOLD}No format given; using best available.${NORMAL}\n"
format="b"
fi
# Download the video.
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
error=$?
if [[ $error -eq 1 ]]; then
error "Error: Failed to download '$url'\n"
fi
if [[ $make_folder == "1" ]]; then
cd ..
fi
}
# Download MP4 video.
dl_mp4() {
local url="$1"
@ -809,6 +859,9 @@ alias vimeo-compressed='dl_vimeo_vid "Original" $SHORTNAME_OFF $COMPRESSION_ON'
# Instagram Vid DL
alias ig-download-and-hflip='dl_instagram_vid_and_hflip '
# Twitter Vid DL
alias twitter='dl_twitter_vid "" '
# Misc
alias download-mp4='dl_mp4'
alias download-from-m3u8='dl_from_m3u8'