youtube-dl-install/youtube-dl-pseudogui.sh

79 lines
2.6 KiB
Bash
Raw Permalink Normal View History

2022-06-26 10:08:58 +02:00
#! /bin/bash
# VARIABLES
2022-06-26 10:08:58 +02:00
dir="$HOME/Téléchargements/"
log="/tmp/youtubedlurl_$(date +%d-%b-%Y--%H-%M).txt"
2022-06-26 10:08:58 +02:00
youtubedlbinary="$HOME/bin/yt-dlp"
# FONCTIONS
f_telechcommence(){ notify-send -i youtube "yt-dlp téléchargement commencé" "$title\n$url" ; }
f_iferr(){
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
2024-01-19 09:21:08 +01:00
choix=$(zenity --height=400 --list --title=youtubedl --hide-header --hide-column=1 --column=1 --column=2 \
1 "Télécharger une vidéo Youtube (HD)" \
2 "Télécharger une vidéo Youtube (SD)" \
3 "Télécharger une vidéo (original)" \
4 "Télécharger une musique/audio" \
5 "Mettre à jour yt-dlp")
2022-06-26 10:08:58 +02:00
if [ "$choix" = "1" ];then
url=$(zenity --width 500 --entry --title "url à télécharger (HD)")
title=$($youtubedlbinary --get-title "$url")
f_telechcommence
2023-07-19 17:24:18 +02:00
$youtubedlbinary -f 'bestvideo[height<800]' --output "%(title)s.%(ext)s" "$url" | tee $log | ZenityPulsate
f_iferr
2022-06-26 10:08:58 +02:00
elif [ "$choix" = "2" ];then
url=$(zenity --width 500 --entry --title "url à télécharger (SD)")
title=$($youtubedlbinary --get-title "$url")
f_telechcommence
$youtubedlbinary -f 'bestvideo[height<=480]+bestaudio/best[height<=480]' --output "%(title)s.%(ext)s" "$url" | tee $log | ZenityPulsate
f_iferr
2022-06-26 10:08:58 +02:00
elif [ "$choix" = "3" ];then
2024-01-19 09:21:08 +01:00
url=$(zenity --width 500 --entry --title "url à télécharger (original)")
title=$($youtubedlbinary --get-title "$url")
f_telechcommence
$youtubedlbinary --output "%(title)s.%(ext)s" "$url" | tee $log | ZenityPulsate
f_iferr
elif [ "$choix" = "4" ];then
2022-06-26 10:08:58 +02:00
url=$(zenity --width 500 --entry --title "url à télécharger (audio)")
title=$($youtubedlbinary --get-title "$url")
f_telechcommence
$youtubedlbinary --extract-audio --audio-format mp3 --output "%(title)s.%(ext)s" --restrict-filenames "$url" | tee $log | ZenityPulsate
f_iferr
2022-06-26 10:08:58 +02:00
2024-01-19 09:21:08 +01:00
elif [ "$choix" = "5" ];then
return=$($youtubedlbinary --update)
2023-08-18 20:35:43 +02:00
notify-send -t 60000 -i youtube "yt-dlp" "Mise à jour terminée\n\n$return"
2022-06-26 10:08:58 +02:00
fi