shell-scripte-code/youtube-vlc_windows.sh

72 lines
1.7 KiB
Bash
Raw Permalink Normal View History

2021-08-30 22:36:00 +02:00
#!/usr/bin/env bash
set -ex
if [ "$1" == "--help" ] || [[ -z "$1" ]]
then
echo "bitte alles kleinschreiben"
2021-08-30 22:59:23 +02:00
echo "bash ./youtube-dl.sh suche/search URL/stichwort FORMAT"
2021-08-31 14:45:23 +02:00
echo "Formate: [opus/m4a/video/hd/hdmp4/fullhd/fullhdmp4/4k/FORMAT]"
2021-08-30 22:36:00 +02:00
exit 0
fi
2021-08-30 22:59:23 +02:00
if [ "$1" == "suche" ] || [ "$1" == "search" ]; then
2021-08-30 22:36:00 +02:00
suche="$1"
url="$2"
format="$3"
else
url="$1"
format="$2"
fi
if [ "$format" == "opus" ]
then
format="-f 251"
elif [ "$format" == "m4a" ]
then
format="-f 140"
elif [ "$format" == "video" ]
then
format="-f 43"
elif [ "$format" == "hd" ]
then
format="-f 247+251"
2021-08-31 14:45:23 +02:00
elif [ "$format" == "hdmp4" ]
then
format="-f 22"
2021-08-30 22:36:00 +02:00
elif [ "$format" == "fullhd" ]
then
format="-f 303+251"
elif [ "$format" == "fullhdmp4" ]
then
2021-08-30 23:27:35 +02:00
format="-f 299+140"
2021-08-30 22:36:00 +02:00
elif [ "$format" == "4k" ]
then
format="-f 315+251"
elif [ -n "$format" ]; then
format="-f $format"
fi
video=""
2021-08-30 22:59:23 +02:00
if [ "$suche" == "suche" ] || [ "$suche" == "search" ]
2021-08-30 22:36:00 +02:00
then
2021-08-30 22:39:59 +02:00
if ! youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format; then
2021-08-30 22:36:00 +02:00
echo "Download fehlgeschlagen"
2021-08-30 22:59:23 +02:00
exit 1
2021-08-30 22:36:00 +02:00
fi
2021-08-30 22:39:59 +02:00
video=$(youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist --get-filename $format)
2021-08-30 22:36:00 +02:00
else
if ! youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format $url; then
echo "Download fehlgeschlagen"
2021-08-30 22:59:23 +02:00
exit 1
2021-08-30 22:36:00 +02:00
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}
else
echo "Konnte Video nicht finden"
2021-08-30 22:59:23 +02:00
exit 1
2021-08-30 22:36:00 +02:00
fi