fix youtube-scripts

This commit is contained in:
user1 2021-08-30 22:59:23 +02:00
parent 14d3925e99
commit 4d8d4c9c61
3 changed files with 18 additions and 9 deletions

View file

@ -5,12 +5,12 @@ set -ex
if [ "$1" == "--help" ] || [[ -z "$1" ]] if [ "$1" == "--help" ] || [[ -z "$1" ]]
then then
echo "bitte alles kleinschreiben" echo "bitte alles kleinschreiben"
echo "bash ./youtube-dl.sh suche/NOSUCHE URL/SUCHE FORMAT" echo "bash ./youtube-dl.sh suche/search URL/stichwort FORMAT"
echo "Formate: [opus/m4a/video/hd/fullhd/fullhdmp4/4k/FORMAT]" echo "Formate: [opus/m4a/video/hd/fullhd/fullhdmp4/4k/FORMAT]"
exit 0 exit 0
fi fi
if [ "$1" == "suche" ] || [ "$1" == "nosuche" ]; then if [ "$1" == "suche" ] || [ "$1" == "search" ]; then
suche="$1" suche="$1"
url="$2" url="$2"
format="$3" format="$3"
@ -45,15 +45,17 @@ elif [ -n "$format" ]; then
fi fi
video="" video=""
if [ "$suche" == "suche" ] if [ "$suche" == "suche" ] || [ "$suche" == "search" ]
then then
if ! youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format; then if ! youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format; then
echo "Download fehlgeschlagen" echo "Download fehlgeschlagen"
exit 1
fi fi
video=$(youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist --get-filename $format) video=$(youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist --get-filename $format)
else else
if ! youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format $url; then if ! youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format $url; then
echo "Download fehlgeschlagen" echo "Download fehlgeschlagen"
exit 1
fi fi
video=$(youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist --get-filename $format $url) video=$(youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist --get-filename $format $url)
fi fi
@ -62,4 +64,5 @@ if [ "${video}" != "" ]; then
vlc ${video} vlc ${video}
else else
echo "Konnte Video nicht finden" echo "Konnte Video nicht finden"
exit 1
fi fi

View file

@ -5,12 +5,12 @@ set -ex
if [ "$1" == "--help" ] || [[ -z "$1" ]] if [ "$1" == "--help" ] || [[ -z "$1" ]]
then then
echo "bitte alles kleinschreiben" echo "bitte alles kleinschreiben"
echo "bash ./youtube-dl.sh suche/NOSUCHE URL/SUCHE FORMAT" echo "bash ./youtube-dl.sh suche/search URL/stichwort FORMAT"
echo "Formate: [opus/m4a/video/hd/fullhd/fullhdmp4/4k/FORMAT]" echo "Formate: [opus/m4a/video/hd/fullhd/fullhdmp4/4k/FORMAT]"
exit 0 exit 0
fi fi
if [ "$1" == "suche" ] || [ "$1" == "nosuche" ]; then if [ "$1" == "suche" ] || [ "$1" == "search" ]; then
suche="$1" suche="$1"
url="$2" url="$2"
format="$3" format="$3"
@ -45,15 +45,17 @@ elif [ -n "$format" ]; then
fi fi
video="" video=""
if [ "$suche" == "suche" ] if [ "$suche" == "suche" ] || [ "$suche" == "search" ]
then then
if ! youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format; then if ! youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format; then
echo "Download fehlgeschlagen" echo "Download fehlgeschlagen"
exit 1
fi fi
video=$(youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist --get-filename $format) video=$(youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist --get-filename $format)
else else
if ! youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format $url; then if ! youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format $url; then
echo "Download fehlgeschlagen" echo "Download fehlgeschlagen"
exit 1
fi fi
video=$(youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist --get-filename $format $url) video=$(youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist --get-filename $format $url)
fi fi
@ -62,4 +64,5 @@ if [ "${video}" != "" ]; then
vlc.exe ${video} vlc.exe ${video}
else else
echo "Konnte Video nicht finden" echo "Konnte Video nicht finden"
exit 1
fi fi

View file

@ -5,12 +5,12 @@ set -ex
if [ "$1" == "--help" ] || [[ -z "$1" ]] if [ "$1" == "--help" ] || [[ -z "$1" ]]
then then
echo "bitte alles kleinschreiben" echo "bitte alles kleinschreiben"
echo "bash ./youtube-dl.sh suche/NOSUCHE URL/SUCHE FORMAT" echo "bash ./youtube-dl.sh suche/search URL/stichwort FORMAT"
echo "Formate: [opus/m4a/video/hd/fullhd/fullhdmp4/4k/FORMAT]" echo "Formate: [opus/m4a/video/hd/fullhd/fullhdmp4/4k/FORMAT]"
exit 0 exit 0
fi fi
if [ "$1" == "suche" ] || [ "$1" == "nosuche" ]; then if [ "$1" == "suche" ] || [ "$1" == "search" ]; then
suche="$1" suche="$1"
url="$2" url="$2"
format="$3" format="$3"
@ -45,15 +45,17 @@ elif [ -n "$format" ]; then
fi fi
video="" video=""
if [ "$suche" == "suche" ] if [ "$suche" == "suche" ] || [ "$suche" == "search" ]
then then
if ! youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format; then if ! youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format; then
echo "Download fehlgeschlagen" echo "Download fehlgeschlagen"
exit 1
fi fi
video=$(youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist --get-filename $format) video=$(youtube-dl "ytsearch:$url" -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist --get-filename $format)
else else
if ! youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format $url; then if ! youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist $format $url; then
echo "Download fehlgeschlagen" echo "Download fehlgeschlagen"
exit 1
fi fi
video=$(youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist --get-filename $format $url) video=$(youtube-dl -i -c --socket-timeout 10000 --force-ipv4 --restrict-filenames --no-playlist --get-filename $format $url)
fi fi
@ -62,4 +64,5 @@ if [ "${video}" != "" ]; then
vlc.exe ${video} vlc.exe ${video}
else else
echo "Konnte Video nicht finden" echo "Konnte Video nicht finden"
exit 1
fi fi