2c61717dc3
changing binary path by variable
61 lines
1.7 KiB
Bash
Executable File
61 lines
1.7 KiB
Bash
Executable File
#! /bin/bash
|
|
|
|
# VARIABLES
|
|
dir="$HOME/Téléchargements/"
|
|
file="/tmp/youtubedlurl_$(date +%d%b%Y%H%M%S).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"
|
|
exit
|
|
else
|
|
notify-send -i youtube "yt-dlp téléchargement terminé" "$title\n$url"
|
|
fi
|
|
}
|
|
|
|
cd "$dir" || exit
|
|
|
|
# GESTION DES CHOIX
|
|
choix=$(zenity --list --title=youtubedl --hide-header --hide-column=1 --column=1 --column=2 \
|
|
1 "Télécharger une vidéo (HD)" \
|
|
2 "Télécharger une vidéo (SD)" \
|
|
3 "Télécharger une musique/audio" \
|
|
4 "Mettre à jour yt-dlp")
|
|
|
|
if [ "$choix" = "1" ];then
|
|
url=$(zenity --width 500 --entry --title "url à télécharger (HD)")
|
|
title=$($youtubedlbinary --get-title "$url")
|
|
|
|
f_telechcommence
|
|
$youtubedlbinary --output "%(title)s.%(ext)s" "$url" >> $file
|
|
f_iferr
|
|
|
|
|
|
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" >> $file
|
|
f_iferr
|
|
|
|
|
|
elif [ "$choix" = "3" ];then
|
|
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" >> $file
|
|
f_iferr
|
|
|
|
|
|
elif [ "$choix" = "4" ];then
|
|
return=$($youtubedlbinary --update)
|
|
notify-send -t 60000 -i youtube "yt-dlp" "$return"
|
|
fi
|