From 863fab4d1e07317ce1d5293ab791135a50ad9140 Mon Sep 17 00:00:00 2001 From: Djan GICQUEL <> Date: Wed, 27 Jul 2022 21:25:35 +0200 Subject: [PATCH] adding zenitypulsate adding basic error management --- youtube-dl-pseudogui.sh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/youtube-dl-pseudogui.sh b/youtube-dl-pseudogui.sh index a6b2424..ad1e6e3 100755 --- a/youtube-dl-pseudogui.sh +++ b/youtube-dl-pseudogui.sh @@ -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