Hi
Das Skript hat einen Fehler!
#using parametre or user input
if [ -z $1 ]
then
read -p "Give me the Youtube-URL : " url ;
read -p "Name the output : " of ;
youtube-dl ${url} ;
else
youtube-dl ${1} ;
fi
Der Name der Datei wird nicht definiert, wenn $1 gegeben ist!
Also müsste man z.B. $1 und $2 als Bedingung haben
oder eine weitere Abfrage für den Namen, was flexibler wäre.
Etwa so:
#!/bin/bash
#
# Author: hQy
# Changelog(piet): added parametre handling for youtubeurls
# Changelog(maces): added parameter handling for filenames
mkdir ~/tmp ;
cd ~/tmp ;
#youtube-dl already installed
if [ -f /usr/bin/youtube-dl ]
then
echo "youtube-dl is already installed"
else
exit 0
fi
#using parametre or user input
if [ -z $1 ]
then
read -p "Give me the Youtube-URL : " url ;
# read -p "Name the output : " of ;
youtube-dl ${url} ;
else
youtube-dl ${1} ;
fi
if [ -z $2 ]
then
read -p "Name the output : " of ;
fi
cd .. ;
ffmpeg -i ~/tmp/*.flv -vcodec libx264 -acodec copy ${of}.mp4 ;
rm -R ~/tmp ;
echo "Downloaded and converted successfully!" ;
echo "Saved in your home-folder!" ;
exit
Bei mir hat es funktioniert (nur die Url als Parameter angegeben)
Hoffe auch mal das das anpassen in Ordnung war und ich jetzt keinen Fehler reingebaut habe 😉
Wenn wir grad schon dabei sind, wie wäre es wenn man noch per Parameter
oder/und input das End-Format (z.B. mp4, mp3) angeben könnte (Default ist dann z.B. mp4)?
maces