add new default formats

This commit is contained in:
user1 2023-05-08 10:10:34 +02:00
parent d74ad85037
commit f0af44bb27

View file

@ -13,16 +13,17 @@ url="$1"
format="$2"
[[ -z "${url}" ]] && read -p "URL: " url
[[ -z "${format}" ]] && read -p "Format [opus/flac/m4a/video/hd/fullhd/4k]: " format
[[ -z "${format}" ]] && read -p "Format [opus/flac/m4a/mp4/video/hd/fullhd/4k]: " format
if [ "$format" == "opus" ]
then
format="--audio-format opus"
# https://github.com/yt-dlp/yt-dlp/issues/979
format="--audio-format opus -f "ba" --format-sort "abr,codec""
audio="-x"
quality="--audio-quality 0"
elif [ "$format" == "flac" ]
then
format="--audio-format flac"
format="--audio-format flac -f "ba" --format-sort "abr,codec""
audio="-x"
quality="--audio-quality 0"
elif [ "$format" == "m4a" ]
@ -35,16 +36,23 @@ then
audio="-x"
elif [ "$format" == "video" ]
then
format="-f 43"
# Download and merge the best video-only format and the best audio-only format,
# or download the best combined format if video-only format is not available
# Download the best video available with the largest resolution but no better than 480p,
# or the best video with the smallest resolution if there is no video under 480p
# Resolution is determined by using the smallest dimension.
# So this works correctly for vertical videos as well
format="-S "res:480" -f "bv+ba/b""
elif [ "$format" == "hd" ]
then
format="-f 247+251"
format="-S "res:720" -f "bv+ba/b""
elif [ "$format" == "fullhd" ]
then
format="-f 303+251"
format="-S "res:1080" -f "bv+ba/b""
elif [ "$format" == "4k" ]
then
format="-f 315+251"
format="-S "res:2160" -f "bv+ba/b""
fi
yt-dlp -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --embed-thumbnail --embed-metadata --match-filter "!was_live" $format $audio $quality -v $url