shell-scripte-code/youtube.sh

43 lines
825 B
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
2017-09-23 17:30:59 +02:00
if [ "$1" == "--help" ] || [[ -z "$1" ]]
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
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"
2017-09-23 17:10:53 +02:00
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-03-31 15:22:07 +02:00
yt-dlp -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --embed-thumbnail $format $audio $quality $url