From f0af44bb27fcf15d4560fd72f8e28d9ab66a1ce8 Mon Sep 17 00:00:00 2001 From: user1 Date: Mon, 8 May 2023 10:10:34 +0200 Subject: [PATCH] add new default formats --- youtube.sh | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/youtube.sh b/youtube.sh index 18428ec..123a8a2 100755 --- a/youtube.sh +++ b/youtube.sh @@ -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