shell-scripte-code/youtube.sh

51 lines
1.1 KiB
Bash
Raw Normal View History

2019-01-07 20:23:02 +01:00
#!/usr/bin/env bash
2017-06-06 21:17:36 +02:00
2021-08-30 22:36:00 +02:00
set -ex
2017-06-06 21:17:36 +02:00
if [ "$1" == "--help" ]
2017-06-06 21:34:54 +02:00
then
2022-03-30 18:50:35 +02:00
echo "bash ./youtube-dl.sh URL FORMAT"
echo "Formate: [opus/m4a/video/hd/fullhd/4k]"
2017-11-17 21:24:15 +01:00
exit 0
2017-06-06 21:34:54 +02:00
fi
2017-07-15 08:19:35 +02:00
2022-03-30 18:50:35 +02:00
url="$1"
format="$2"
2017-09-23 17:30:59 +02:00
[[ -z "${url}" ]] && read -p "URL: " url
2022-07-06 18:59:56 +02:00
[[ -z "${format}" ]] && read -p "Format [opus/flac/m4a/video/hd/fullhd/4k]: " format
2017-06-06 21:17:36 +02:00
if [ "$format" == "opus" ]
then
2022-03-30 18:50:35 +02:00
format="--audio-format opus"
audio="-x"
quality="--audio-quality 0"
2022-07-06 19:11:59 +02:00
elif [ "$format" == "flac" ]
2022-07-06 18:59:56 +02:00
then
format="--audio-format flac"
audio="-x"
quality="--audio-quality 0"
elif [ "$format" == "m4a" ]
2017-06-06 21:17:36 +02:00
then
2022-03-30 18:50:35 +02:00
format="--audio-format m4a"
audio="-x"
elif [ "$format" == "mp4" ]
then
format="--audio-format mp4"
audio="-x"
2017-06-06 21:17:36 +02:00
elif [ "$format" == "video" ]
then
format="-f 43"
2017-09-23 17:10:53 +02:00
elif [ "$format" == "hd" ]
then
format="-f 247+251"
elif [ "$format" == "fullhd" ]
2017-07-15 08:19:35 +02:00
then
format="-f 303+251"
2017-09-23 17:10:53 +02:00
elif [ "$format" == "4k" ]
then
format="-f 315+251"
2017-06-06 21:17:36 +02:00
fi
2022-08-31 13:54:32 +02:00
yt-dlp -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --embed-thumbnail --embed-metadata --match-filter "!was_live" $format $audio $quality $url