adding zenitypulsate

adding basic error management
This commit is contained in:
Djan GICQUEL 2022-07-27 21:25:35 +02:00
parent 982c52693d
commit 863fab4d1e

View File

@ -2,22 +2,31 @@
# VARIABLES
dir="$HOME/Téléchargements/"
log="/tmp/youtubedlurl_$(date +%d%b%Y%H%M%S).txt"
log="/tmp/youtubedlurl_$(date +%d-%b-%Y--%H-%M).txt"
youtubedlbinary="$HOME/bin/yt-dlp"
# FONCTIONS
f_telechcommence(){ notify-send -i youtube "yt-dlp téléchargement commencé" "$title\n$url" ; }
f_iferr(){
if [ "$?" != "0" ]; then
echo "Erreur, le script va s'arreter."
notify-send -i youtube -t 30000 "yt-dlp erreur" "$title\n$url"
if grep "error" $log; then
notify-send -i youtube -t 30000 "yt-dlp erreur" "$title\n$url" &
zenity --text-info --width 600 --height 400 --title "yt-dlp erreur" --filename "$log" --cancel-label "Valider"
exit
elif grep "Error" $log; then
notify-send -i youtube -t 30000 "yt-dlp erreur" "$title\n$url" &
zenity --text-info --width 600 --height 400 --title "yt-dlp erreur" --filename "$log" --cancel-label "Valider"
exit
else
notify-send -i youtube "yt-dlp téléchargement terminé" "$title\n$url"
fi
}
ZenityPulsate () {
zenity --width=600 --window-icon=~/.icons/youtube.png --title=youtube-dl --text "Téléchargement en cours..." --progress --pulsate --auto-close --no-cancel
}
cd "$dir" || exit
# GESTION DES CHOIX
@ -32,7 +41,7 @@ if [ "$choix" = "1" ];then
title=$($youtubedlbinary --get-title "$url")
f_telechcommence
$youtubedlbinary --output "%(title)s.%(ext)s" "$url" > $log
$youtubedlbinary --output "%(title)s.%(ext)s" "$url" | tee $log | ZenityPulsate
f_iferr
@ -41,7 +50,7 @@ elif [ "$choix" = "2" ];then
title=$($youtubedlbinary --get-title "$url")
f_telechcommence
$youtubedlbinary -f 'bestvideo[height<=480]+bestaudio/best[height<=480]' --output "%(title)s.%(ext)s" "$url" > $log
$youtubedlbinary -f 'bestvideo[height<=480]+bestaudio/best[height<=480]' --output "%(title)s.%(ext)s" "$url" | tee $log | ZenityPulsate
f_iferr
@ -50,7 +59,7 @@ elif [ "$choix" = "3" ];then
title=$($youtubedlbinary --get-title "$url")
f_telechcommence
$youtubedlbinary --extract-audio --audio-format mp3 --output "%(title)s.%(ext)s" --restrict-filenames "$url" > $log
$youtubedlbinary --extract-audio --audio-format mp3 --output "%(title)s.%(ext)s" --restrict-filenames "$url" | tee $log | ZenityPulsate
f_iferr