shell-scripte-code/youtube-dl.sh

45 lines
822 B
Bash
Raw Normal View History

2017-05-18 22:51:33 +02:00
#!/bin/bash
2017-06-06 21:17:36 +02:00
set -ex
2017-07-24 02:07:42 +02:00
if [ "$1" == "--help" ] || [[ -z "$1" ]]
then
echo "bash ./youtube-dl.sh URL PFAD FORMAT"
echo "Formate: opus/audio/video/BEST/4k"
exit 0
fi
url="$1"
pfad="$2"
format="$3"
#read -p "Wie ist die URL? : " url
#read -p "Wo sollen die Dateien heruntergeladen werden? : " pfad
2017-09-16 16:05:40 +02:00
#read -p "Soll ein Video heruntergeladen werden oder Audio? [opus/m4a/video/hd/fullhd/4k] : " format
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
2017-06-06 21:17:36 +02:00
format="-f 251"
2017-09-16 16:05:40 +02:00
elif [ "$format" == "m4a" ]
2017-05-31 13:16:28 +02:00
then
2017-06-06 21:17:36 +02:00
format="-f 140"
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
2017-09-16 02:05:17 +02:00
2017-05-31 13:16:28 +02:00
mkdir -p $pfad
2017-05-18 22:51:33 +02:00
cd $pfad
2017-09-23 17:10:53 +02:00
youtube-dl -i --socket-timeout 10000 --force-ipv4 $format $url