shell-scripte-code/youtube.sh

57 lines
1.2 KiB
Bash
Raw Normal View History

2017-06-06 21:17:36 +02:00
#!/bin/bash
set -ex
2017-09-23 17:30:59 +02:00
if [ "$1" == "--help" ] || [[ -z "$1" ]]
2017-06-06 21:34:54 +02:00
then
2017-11-17 21:24:15 +01:00
echo "bitte alles kleinschreiben"
2018-03-24 02:55:08 +01:00
echo "bash ./youtube-dl.sh suche/NOSUCHE URL/SUCHE FORMAT"
2018-04-17 16:38:16 +02:00
echo "Formate: [opus/m4a/video/hd/fullhd/fullhdmp4/4k/FORMAT]"
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
2017-11-17 21:24:15 +01:00
if [ "$1" == "suche" ] || [ "$1" == "nosuche" ]; then
suche="$1"
url="$2"
format="$3"
else
url="$1"
format="$2"
fi
2017-09-23 17:30:59 +02:00
2017-11-17 18:22:35 +01:00
#read -p "Wie ist die URL/suche? : " url
2017-09-23 17:30:59 +02:00
#read -p "Wo sollen die Dateien heruntergeladen werden? : " pfad
#read -p "Soll ein Video heruntergeladen werden oder Audio? [opus/m4a/video/hd/fullhd/4k] : " format
2017-06-06 21:17:36 +02:00
if [ "$format" == "opus" ]
then
format="-f 251"
2017-09-23 17:10:53 +02:00
elif [ "$format" == "m4a" ]
2017-06-06 21:17:36 +02:00
then
format="-f 140"
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"
2018-04-17 16:38:16 +02:00
elif [ "$format" == "fullhdmp4" ]
then
2018-11-11 04:24:37 +01:00
format="-f 299+140" ]
2017-09-23 17:10:53 +02:00
elif [ "$format" == "4k" ]
then
format="-f 315+251"
2018-04-17 16:38:16 +02:00
elif [ -n "$format" ]; then
format="-f $format"
2017-06-06 21:17:36 +02:00
fi
2017-06-06 21:34:54 +02:00
if [ "$suche" == "suche" ]
then
2018-03-24 02:55:08 +01:00
youtube-dl "ytsearch:$url" -q --force-ipv4 $format -o- | mplayer -fs -cache 8192 -
2017-06-06 21:34:54 +02:00
else
2018-03-24 02:55:08 +01:00
youtube-dl -q --force-ipv4 $format -o- $url | mplayer -fs -cache 8192 -
2017-06-06 21:34:54 +02:00
fi