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
|
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-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
|
|
|
|
|
2021-08-30 22:36:00 +02:00
|
|
|
video=""
|
2017-06-06 21:34:54 +02:00
|
|
|
if [ "$suche" == "suche" ]
|
|
|
|
then
|
2021-08-30 22:36:00 +02:00
|
|
|
if ! youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format $url; then
|
|
|
|
echo "Download fehlgeschlagen"
|
|
|
|
fi
|
|
|
|
video=$(youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist --get-filename $format $url)
|
|
|
|
else
|
|
|
|
if ! youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format $url; then
|
|
|
|
echo "Download fehlgeschlagen"
|
|
|
|
fi
|
|
|
|
video=$(youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist --get-filename $format $url)
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${video}" != "" ]; then
|
|
|
|
vlc.exe ${video}
|
2017-06-06 21:34:54 +02:00
|
|
|
else
|
2021-08-30 22:36:00 +02:00
|
|
|
echo "Konnte Video nicht finden"
|
2017-06-06 21:34:54 +02:00
|
|
|
fi
|