eric.mariaud a écritJ'ai l'impression que tu réinstalle chaque fois la nouvelle version.
En effet, mais une mise à jour ce n'est ni plus ni moins que la nouvelle version du programme.
Selon la méthode avec laquelle on a installé youtube-dl l'option
-U ne fonctionne pas (chez moi c'est comme ça).
Si tu veux un script pour télécharger une vidéo tu copies et colles ce qui suit dans un fichier que tu nommes par exemple
youtube-dl.sh (le
.sh est important à la fin).
#!/bin/bash
ERR(){ echo "ERROR: $1" 1>&2; }
declare -i DEPCOUNT=0
for DEP in /usr/bin/{xev,xdotool,yad,youtube-dl,wget}; {
[ -x "$DEP" ] || {
ERR "$LINENO Dependency '$DEP' not met."
DEPCOUNT+=1
}
}
[ $DEPCOUNT -eq 0 ] || exit 1
#download location
cd ~/Vidéos
export ytdownload='@bash -c "download_video %1"'
# We need this to store the youtube Link
export ytlink=$(mktemp /tmp/ytlnk.XXXXXXXX)
export ytdpipe=$(mktemp -u /tmp/ytd.XXXXXXXX)
export ytdpipetwo=$(mktemp -u /tmp/ytd2.XXXXXXXX)
mkfifo "$ytdpipe"
mkfifo "$ytdpipetwo"
function on_exit {
rm -f "$ytdpipe"
rm -f "$ytdpipetwo"
rm -f "$ytlink"
}
trap "on_exit" EXIT
ytdkey=$(($RANDOM * $$))
function download_video () {
echo "2:@disabled@"
# Check if the URL is valid with the spider
if wget -q --spider "$1"; then
echo "$1" > "$ytlink"
echo "#Preparation du téléchargement" >> "$ytdpipe"
while read line; do
if [[ "$(echo $line | grep '[0-9]*%')" ]];then
percent=$(echo $line | awk '{print $2}')
echo "${percent%.*}" >> "$ytdpipe"
fi
if [[ "$(echo $line | grep '\[download\]')" ]];then
progress=$(echo $line | awk '{$1=""; print $0}')
echo "#$progress" >> "$ytdpipe"
fi
done < "$ytdpipetwo" &
LOOP_PID="$!"
youtube-dl -f 'bestvideo [ext = mp4] + bestaudio [ext = m4a] / bestvideo + bestaudio' --merge-output-format mp4 --newline -i -o "%(title)s.%(ext)s" "$1" 2>&1 >> $ytdpipetwo &
ytproc_pid=$!
wait $ytproc_pid 2>/dev/null # supress message from kill command later
if [[ "$?" = 0 ]]
then
echo "0" >> "$ytdpipe"
echo "#Téléchargement terminé." >> "$ytdpipe"
kill "$LOOP_PID"
elif [[ ! -s "$ytdpid" ]]; then
echo "#Téléchargement annulé" >> "$ytdpipe"
echo "0" >> "$ytdpipe"
kill "$LOOP_PID"
else
echo "#Erreur de téléchargement" >> "$ytdpipe"
kill "$LOOP_PID"
fi
else
echo "#URL invalide" >> "$ytdpipe"
fi
echo "2:$ytdownload"
}
export -f download_video
function ytdl_version () {
echo "#MàJ Youtube-dl" >> "$ytdpipe"
wget --spider --user-agent="Mozilla/5.0 Gecko/20100101" --timeout=30 -q "https://rg3.github.io/youtube-dl/" -O /dev/null
if [[ "$?" -ne "0" ]]; then
echo "#Connexion impossible au serveur de youtube-dl" >> "$ytdpipe"
fi
ytdlcv=$(youtube-dl --version)
ytdllv=$(wget -O- -q "https://rg3.github.io/youtube-dl/update/LATEST_VERSION")
if [[ "$ytdlcv" == "$ytdllv" ]]; then
echo "#youtube-dl est à jour" >> "$ytdpipe"
else
echo "#Une mise à jour de youtube-dl est disponible" >> "$ytdpipe"
fi
}
export -f ytdl_version
function stop_clicked () {
if [[ ! -s "${ytlink}" ]]; then
echo "#Pas de processus à stopper." >> "$ytdpipe"
else
YoutubeLink="$(cat $ytlink)"
YtCommand="youtube-dl -f bestvideo [ext = mp4] + bestaudio [ext = m4a] / bestvideo + bestaudio --merge-output-format mp4 --newline -i -o %(title)s.%(ext)s $YoutubeLink"
YoutubePID="$(ps -eo pid,cmd | grep -F "$YtCommand" | grep -v "grep" | awk '{ print $1 }')"
if [[ "$YoutubePID" != "" ]]; then
kill -9 $YoutubePID
fi
fi
}
export -f stop_clicked
exec 3<> $ytdpipe
exec 4<> $ytdpipetwo
yad --plug="$ytdkey" --tabnum=1 --form --field "URL de la vidéo":CE "" \
--image=browser-download --field="Télécharger!browser-download:fbtn" "$ytdownload" &
yad --plug="$ytdkey" --tabnum=2 --window-icon="$ICON" \
--progress --borders=6 --auto-close --auto-kill <&3 &
echo "#URL de la vidéo." >> "$ytdpipe"
#ytdl_version &
yad --class="YtDownloader" --paned --key="$ytdkey" \
--button="MàJ yoututube-dl":'bash -c "ytdl_version" 2>/dev/null' \
--button="Stop":'bash -c "stop_clicked" 2>/dev/null' --text="" --width=500 --height=200 \
--title=$"Youtube-dl" --window-icon="browser-download" --center &
YPID="$!"
# Wait untill window opend, that is until windowname appears
until xdotool getwindowname "$(xdotool search --any --pid $YPID --class "YtDownloader" 2>/dev/null | tail -1 2>/dev/null)" &>/dev/null; do
# sleep until the window opens
sleep .1
done
# Decimal window id
WindowID="$(xdotool search --any --pid $YPID --class "YtDownloader" 2>/dev/null | tail -1)"
# Hexadecimal
WindowIDHex=$(printf "0x%08x" ${WindowID})
# Base seven
WindowBSeven=$(printf "0x%07x" ${WindowID})
# This is needed because youtube-dl prevents one yad --paned tab from closing
# Monitor for DestroyNotify event and kill youtube-dl
xev -event structure -id ${WindowIDHex} 2>/dev/null |
while IFS=$',' read -a A; do
if [[ "${A[0]}" =~ "DestroyNotify event" ]]; then
YoutubeLink="$(cat $ytlink)"
YtCommand="youtube-dl -f bestvideo [ext = mp4] + bestaudio [ext = m4a] / bestvideo + bestaudio --merge-output-format mp4 --newline -i -o %(title)s.%(ext)s $YoutubeLink"
YoutubePID="$(ps -eo pid,cmd | grep -F "$YtCommand" | grep -v "grep" | awk '{ print $1 }')"
if [[ "$YoutubePID" != "" ]]; then
kill -9 $YoutubePID
wait $YoutubePID
fi
XevPID="$(ps -eo pid,cmd | grep "xev -event structure -id $WindowIDHex" | grep -v "grep" | awk '{ print $1 }')"
kill $XevPID
wait $XevPID 2> /dev/null
fi
A=()
done & xev_pid=$!
wait $YPID
echo $?
wait $xev_pid
exec 3>&-
exec 4>&-
exit 0
Une fois ton fichier créé, clic droit dessus => Propriétés => Permissions => Autoriser le fichier à être exécuté comme un programme.
Si yad (un programme pour créer des fenêtres de dialogue) n'est pas installé fais-le :
sudo apt install yad
Quand tu le lanceras ça ouvrira une fenêtre où tu colleras ton lien de vidéo à télécharger.
Ce script n'est pas de moi, je l'ai trouvé sur un forum, je ne sais plus où, il peut paraître long pour une action simple, mais il fonctionne et permet de faire la mise à jour en appuyant sur le bouton «
MàJ youtube-dl» qui va bien.
À plus.