shell-scripte-code/youtube-dl.sh

43 lines
811 B
Bash
Raw Normal View History

2019-01-07 20:23:02 +01:00
#!/usr/bin/env bash
2017-05-18 22:51:33 +02:00
2017-06-06 21:17:36 +02:00
set -ex
2017-07-24 02:07:42 +02:00
if [ "$1" == "--help" ] || [[ -z "$1" ]]
then
2018-11-11 04:24:37 +01:00
echo "bash ./youtube-dl.sh URL FORMAT"
echo "Formate: [opus/m4a/video/hd/fullhd/4k]"
exit 0
2017-07-24 02:07:42 +02:00
fi
url="$1"
2018-05-30 20:30:37 +02:00
format="$2"
2017-05-18 22:51:33 +02:00
2017-05-31 13:16:28 +02:00
if [ "$format" == "opus" ]
2017-05-18 22:51:33 +02:00
then
2020-05-12 08:47:03 +02:00
format="--audio-format opus"
audio="-x"
quality="--audio-quality 0"
2017-09-16 16:05:40 +02:00
elif [ "$format" == "m4a" ]
2017-05-31 13:16:28 +02:00
then
2020-05-12 08:47:03 +02:00
format="--audio-format m4a"
audio="-x"
2020-05-12 08:09:45 +02:00
elif [ "$format" == "mp4" ]
then
2020-05-12 08:47:03 +02:00
format="--audio-format mp4"
audio="-x"
2017-06-06 21:17:36 +02:00
elif [ "$format" == "video" ]
then
format="-f 43"
2017-09-16 16:05:40 +02:00
elif [ "$format" == "hd" ]
then
format="-f 247+251"
2017-09-16 02:05:17 +02:00
elif [ "$format" == "fullhd" ]
2017-07-24 01:30:14 +02:00
then
format="-f 303+251"
2017-09-16 02:05:17 +02:00
elif [ "$format" == "4k" ]
then
format="-f 315+251"
2017-05-18 22:51:33 +02:00
fi
2020-05-12 08:47:03 +02:00
youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames $format $audio $quality $url