AnsuzPeorth a écritTu connais le poids du fichier téléchargé au depart ? Si oui, c'est juste une histoire de calcul (finalement, les maths qu'on nous a obligé à apprendre, nous sert un peu...!)
Perso, je ne m'embeterais pas avec les progress, j'indiquerais juste le nom et le poids du fichier (refresh 5s par exemple). Je trouve gourmand en ressource juste pour afficher une progress....Enfin, c'est juste mon avis 🙂
Je ne connais pas la taille du flux à l'avance, peut-ete y'a t-il moyen de le récupérer.
Sinon, c'est vrai que les barres de progressions sont gourmandes, mais j'aime bien le concept alors je vais quand meme essayer d'optimiser cela. Maintenant si vous trouvez vraiment le script trop lourd en ressources on peu essayer de faire sans . C'est jute ton avis mais il m'interesse autant que les autres. 😉
@ Lancelin :
Le lancemant dans la balise action ne devrait pas poser de pb puisque la notation ./scripts.sh, sert à lancer le script "script.sh" à partir du dossier courant. Au début du script, une variable $SCRIPT est initialisée avec le nom du script.
La ligne dont tu nous parle signifie donc : lancer le script $script qui se trouve dans le dossier courant.
Cela ne devrait donc pas (à priori) poser de pb si tu déplace ou renomme le script. En revanche, c'est ce qui fait que tu ne peut pas lancer le script par son chemin absolu.
Cependant, afin d'éliminer une nouvelle hypothèse, j'ai fait quelques modifs pour forcer le script à toujours s'apeller par son chemin absolu.
Comme je ne suis pas sur que cela reglera le pb, je ne voudrais pas publier une mise à jour juste pour ca. pourrait-tu donc stp faire le test directement en remplacant TOUT le contenu de ton script par ceci :
#!/bin/bash
############################################################################################################################################################
# Script de téléchargements des emissions réccurentes de Canal +.
# Ce script utilise les flux rss du site http://www.vosflux.tv/site/ pour l'indexation des vidéos.
#
# Ce script est un logiciel libre ; vous pouvez le redistribuer et/ou le modifier selon les
# termes de la Licence Publique Générale GNU ( GNU GPL ) publiée par la Free Software Foundation.
#
# #
# Redisded
# Historique des versions :
# - Version 0.3 (18/02/09)
# Ajout de quelques émissions recemment apparues sur le site www.vosflux.tv.
# Ajout d'une gestion de la fréquence de rafraichissement des barres de progression pour moduler la charge cpu.
# Correction d'un bug dans la configuration.
# Correction d'un bug empêchant le renommage du script.
# Affichage de la dernière liste des videos affichées au lancement du script.
# Légère modification de l'interface principale.
# Correction orthographique.
# - Version 0.2 (17/02/09)
# Modification des barres de chargements pour atténuer une surcharge cpu.
# - Version 0.1 (16/02/09)
# Version originale. Permet le téléchargement des vidéos de chaque emission.
#
############################################################################################################################################################
##### Déclaration des variables. #####
# Déclaration du numéro de version du script.
export VERSION="0.3"
# Déclaration du dossier contenant le script
export DIR=$(dirname $0)
# Déclaration du nom du script.
export SCRIPT=$(basename $0)
# Emplacement du dossier de configuration
export CONF_DIR="/home/"$USER"/.get-canal.conf"
# Emplacement du dossier temporaire.
export TEMP_DIR="/tmp/get-canal.tmp"
# Déclaration de la variable servant à gérer les numéros des téléchargements dans la file d'attente.
export DL_NUM="1"
# Déclaration du répertoire de téléchargement des vidéos.
export DOWNLOAD_DIR="$(grep DOWNLOAD_DIR= $CONF_DIR/get-canal.cfg | cut -d"=" -f2)"
# Déclaration du player vidéo.
export VIDEO_PLAYER="$(grep VIDEO_PLAYER= $CONF_DIR/get-canal.cfg | cut -d"=" -f2)"
# Déclaration du popup apparaissant pendant les temps de chargements.
export POPUP='
<window window_position="1" decorated="false" skip_taskbar_hint="true">
<vbox>
<text>
<input>echo "$MESS"</input>
</text>
</vbox>
</window>
'
# Déclaration de l'en-tête de la playlist.
TEXT_PLAYLIST="[playlist]"
##### Déclaration des fonctions utilisées par gtkdialog. #####
# Fonction de gestion des numéros des vidéos dans la file d'attente des téléchargements.
NB_PROGRESSBAR () {
while true ; do
if grep -q $DL_NUM $TEMP_DIR/progress_bar.list ; then
DL_NUM=$(( $DL_NUM + 1 ))
else
break
fi
done
echo $DL_NUM
}
# Fonction d'affichage de la liste des vidéos pour l'emission choisie par l'utilisateur.
SHOW_LIST () {
export MESS="Chargement de la liste des vidéos. Veuillez patientez..." ; gtkdialog --program=POPUP & pid=$!
if [ -f "$TEMP_DIR/index.$1" ] ; then
kill -9 $pid ; exit 0
fi
STREAM_URL="http://www.vosflux.tv/emission/$1/rss"
wget -v "$STREAM_URL" -O - | iconv -f ISO-8859-15 -t UTF-8 >"$TEMP_DIR/index.$1"
TITRES="$(sed -e 's/></\n/g' -e 's/</>/g' "$TEMP_DIR/index.$1" | grep "title" | sed '1d' | cut -d">" -f2)"
DATES="$(sed -e 's/></\n/g' "$TEMP_DIR/index.$1" | grep "url=" | cut -d"\"" -f2 | sed -e '/_AUTO_/s/.*\(..\)\(..\)\(..\)_AUTO_.*/\3-\2-\1/g' -e '/_CAN_/s/.*\(..\)\(..\)\(..\)_CAN_.*/\3-\2-\1/g')"
VIDEOS="$(sed -e 's/></\n/g' "$TEMP_DIR/index.$1" | grep "url=" | cut -d"\"" -f2)"
echo -e $TITRES
i="1"
n=$(echo -e "$TITRES" | wc -l)
while [ "$i" -le "$n" ] ; do
echo "$(echo "$TITRES" | head -$i | tail -1)|$(echo -e "$DATES" | head -$i | tail -1)|$(echo -e "$VIDEOS" | head -$i | tail -1)" >>$TEMP_DIR/videos.$1
i=$(( $i + 1 ))
done
kill -9 $pid
}
# Fonction de téléchargement de la vidéo sélectionnée.
GET_VIDEO () {
export MESS="Lancement du téléchargement..." ; gtkdialog --program=POPUP & pid=$!
NB_PROGRESSBAR
sleep 1
if [ "$DL_NUM" -gt "10" ] ; then
kill -9 $pid
notify-send -t 3000 -i stop "Impossible de lancer plus de 10 téléchargements simultanés"
tmp_list=$(grep -v "next=" $TEMP_DIR/progress_bar.list)
echo -e "$tmp_list" >$TEMP_DIR/progress_bar.list
else
ID=$(head -1 "$TEMP_DIR/show_list" | sed -e 's/.*(\(.*\))/\1/g')
TITRE_TEMP=$(grep "$1" "$TEMP_DIR/videos.$ID" | cut -d"|" -f1 | sed -e 's/ /_/g')
DATE_DIFF=$(grep "$1" "$TEMP_DIR/videos.$ID" | cut -d"|" -f2)
TITRE="$TITRE_TEMP"_"$DATE_DIFF.flv"
echo "$DL_NUM" >>$TEMP_DIR/progress_bar.list
echo "" >$TEMP_DIR/progress_bar$DL_NUM.log
kill -9 $!
wget -O "$TEMP_DIR/videos/$TITRE" "$1" 2>>$TEMP_DIR/progress_bar$DL_NUM.log & kill -9 $pid
echo "TITRE=$TITRE" >$TEMP_DIR/progress_bar$DL_NUM.log
tmp_list=$(grep -v "next=" $TEMP_DIR/progress_bar.list)
echo -e "$tmp_list" >$TEMP_DIR/progress_bar.list
while ps aux | tr -s ' ' | cut -d" " -f2 | grep $! ; do
sleep $(grep REFRESH_DELAY= $CONF_DIR/get-canal.cfg | cut -d"=" -f2)
done
#sleep 1
if [ -f "$TEMP_DIR/videos/$TITRE" ] ; then
notify-send -t 3000 -i info "Téléchargement terminé : $TITRE" & echo -e ". . . . . . . 100\nTITRE=$TITRE" >$TEMP_DIR/progress_bar$DL_NUM.log
fi
fi
}
# Fonction de sauvegarde de la vidéo sélectionnée.
SAVE_FILE () {
titre=$(grep TITRE= $TEMP_DIR/progress_bar$1.log | cut -d"=" -f2)
if [ "$titre" = "" ] ; then
export MESS="Aucune vidéo à sauvegarder !" ; gtkdialog --program=POPUP & sleep 3 ; kill -9 $!
elif ps aux | grep "wget -O /tmp/get-canal.tmp/videos/$titre" | grep -v "grep" ; then
export MESS="Veuillez attendre la fin du téléchargement !" ; gtkdialog --program=POPUP & sleep 3 ; kill -9 $!
elif [ -f "$DOWNLOAD_DIR"/"$titre" ] ; then
notify-send -t 3000 -i stop "L'émission $titre à déja été sauvegardée !"
else
mv "$TEMP_DIR/videos/$titre" "$DOWNLOAD_DIR/$titre" && notify-send -t 3000 -i "filesave" "Emission sauvegardée : $titre" || notify-send -t 3000 -i stop "Impossible de sauvegarder la vidéo : $titre"
fi
}
# Fonction servant à enlever la vidéo sélectionnée de la liste des téléchargements.
DELETE_FILE () {
titre=$(grep TITRE= $TEMP_DIR/progress_bar$1.log | cut -d"=" -f2)
if [ "$titre" = "" ] ; then
export MESS="Aucune vidéo à supprimer !" ; gtkdialog --program=POPUP & sleep 3 ; kill -9 $!
elif ps aux | grep "wget -O /tmp/get-canal.tmp/videos/$titre" | grep -v "grep" ; then
kill -9 $(ps aux | grep "wget -O /tmp/get-canal.tmp/videos/$titre" | grep -v "grep" | tr -s ' ' |cut -d " " -f2)
progress_bar_list=$(grep -v "$1" $TEMP_DIR/progress_bar.list)
echo -e "$progress_bar_list" >$TEMP_DIR/progress_bar.list ; echo "0" >$TEMP_DIR/progress_bar$1.log
rm -f "$TEMP_DIR/videos/$titre" && notify-send -t 3000 -i stop "Téléchargement annulé : $titre"
else
progress_bar_list=$(grep -v "$1" $TEMP_DIR/progress_bar.list)
echo -e "$progress_bar_list" >$TEMP_DIR/progress_bar.list ; echo "0" >$TEMP_DIR/progress_bar$1.log
fi
}
# Fonction d'affichage des barres de progression.
PROGRESS_BAR () {
while true ; do
if head -1 $TEMP_DIR/progress_bar$1.log | grep -q ^0$ ; then
echo 0 ; echo " " ; sleep $(grep REFRESH_DELAY= $CONF_DIR/get-canal.cfg | cut -d"=" -f2)
elif head -1 $TEMP_DIR/progress_bar$1.log | grep -q ". . . . . . . 100" ; then
echo 100
echo $(grep TITRE= $TEMP_DIR/progress_bar$1.log | cut -d"=" -f2) : Terminé
sleep $(grep REFRESH_DELAY= $CONF_DIR/get-canal.cfg | cut -d"=" -f2)
else
echo $(tail -2 $TEMP_DIR/progress_bar$1.log | head -1 | sed 's/^[ \t]*//' | tr -s " " | cut -d" " -f7 | grep -v [[:alpha:]] | sed -e 's/%//g' -e 's/»/100/g')
echo $(grep TITRE= $TEMP_DIR/progress_bar$1.log | cut -d"=" -f2) : $(tail -2 $TEMP_DIR/progress_bar$1.log | head -1 | sed 's/^[ \t]*//' | tr -s ' ' | cut -d" " -f9 | sed -e 's/\[.*\]/Terminé/g')
sleep $(grep REFRESH_DELAY= $CONF_DIR/get-canal.cfg | cut -d"=" -f2)
fi
done
}
# Fonction de modification de la playlist
ADD_PLAYLIST () {
titre=$(grep "TITRE=" "$TEMP_DIR/progress_bar$1.log" | cut -d"=" -f2)
if [ "$titre" = "" ] ; then
export MESS="Aucune vidéo à ajouter !" ; gtkdialog --program=POPUP & sleep 3 ; kill -9 $!
elif ps aux | grep "wget -O /tmp/get-canal.tmp/videos/$titre" | grep -v "grep" ; then
export MESS="Veuillez attendre la fin du téléchargement !" ; gtkdialog --program=POPUP & sleep 3 ; kill -9 $!
elif cat $TEMP_DIR/playlist.pls | grep "$titre" ; then
notify-send -t 3000 -i stop "L'émission $titre est déja présente dans votre playlist !"
else
n=$(head -1 "/$TEMP_DIR/playlist.id")
n=$(($n+1))
echo "$n" >"/$TEMP_DIR/playlist.id"
if [ -f "$TEMP_DIR/videos/$titre" ] ; then
echo "$n=$TEMP_DIR/videos/$titre" >>/$TEMP_DIR/playlist.info
elif [ -f "$DOWNLOAD_DIR/$titre" ] ; then
echo "$n=$DOWNLOAD_DIR/videos/$titre" >>/$TEMP_DIR/playlist.info
else
notify-send "La video $titre est introuvable ! Veuillez la re-télécharger."
fi
echo "$TEXT_PLAYLIST" >$TEMP_DIR/playlist.pls
cat "/$TEMP_DIR/playlist.info" | while read line ; do
echo "File$(echo $line | cut -d"=" -f1)=file://$(echo $line | cut -d"=" -f2)" >>$TEMP_DIR/playlist.pls
done
fi
}
##### Lecture des arguments passés au script et lancement des fonctions gtkdialog si argument -g ou --gtk passé au script. #####
if [ "$1" != "" ] ; then
while getopts "gh-:" option ; do
if [ "$option" = "-" ] ; then
case $OPTARG in
gtk)
option=g
;;
help)
option=h
;;
*)
echo "$OPTARG : option inconnue." ; echo "$MAN" ; exit 2
;;
esac
fi
case $option in
g)
shift ; $1 "$2" ; exit 0
;;
h)
zenity --info --title="$0" --text="$options" ; exit 0
;;
?)
echo "$option : option inconnue." ; echo "$MAN" ; exit 2
;;
esac
done
fi
##### Déclaration des fenêtres gtkdialog. #####
# Déclaration de la fenêtre configuration.
export MAIN_CONFIG='
<window title="Configuration de '$SCRIPT'" window_position="1">
<vbox>
<frame Répertoire de téléchargement des fichiers>
<hbox>
<entry accept="directory" activates_default="true">
<label>Choisissez un répertoire</label>
<default>'$PWD'</default>
<variable>FILE_DIRECTORY</variable>
</entry>
<button>
<input file stock="gtk-open"></input>
<action type="fileselect">FILE_DIRECTORY</action>
</button>
</hbox>
</frame>
<frame Lecteur vidéo préféré>
<combobox case-sensitive="false" value-in-list="true">
<variable>VIDEO_PLAYER</variable>
<item>kaffeine</item>
<item>mplayer</item>
<item>totem</item>
<item>vlc</item>
<item>xine</item>
</combobox>
</frame>
<hbox>
<button ok></button>
<button cancel></button>
</hbox>
</vbox>
</window>
'
# Déclaration de la fenêtre principale.
export MAIN_PROGRAMM='
<window title="'$SCRIPT'" window_position="1">
<vbox>
<notebook labels="Principal|Téléchargements automatiques|Options">
<hbox>
<vbox>
<text wrap="true" width-chars="32" use_markup="true">
<label>Choisissez une émission puis cliquez sur la loupe.</label>
</text>
<combobox case-sensitive="false" value-in-list="true">
<item>+ Clair (226)</item>
<item>Action discrète (594)</item>
<item>Canal presque (593)</item>
<item>Chris Esquerre (230)</item>
<item>Dimanche+ (228)</item>
<item>Groland magzine (45)</item>
<item>L'\''édition spéciale (229)</item>
<item>L'\''effet papillon (13)</item>
<item>La boite à question (44)</item>
<item>La matinale (227)</item>
<item>La semaine de Guillon (595)</item>
<item>Le buzz du jour (47)</item>
<item>Le grand journal (14)</item>
<item>Le meilleur du hier (48)</item>
<item>Le petit journal actu (43)</item>
<item>Le petit journal people (42)</item>
<item>Le zapping (46)</item>
<item>Les bonus de Guillaume (592)</item>
<item>Les guignols (36)</item>
<item>Pépites sur le net (41)</item>
<item>Salut les terriens! (12)</item>
<item>SAV des emissions (40)</item>
<item>Têtes à claques (231)</item>
<variable>EMISSION</variable>
</combobox>
<button>
<input file icon="gtk-find"></input>
<action>echo "$EMISSION" >$TEMP_DIR/show_list ; sed -i "/EMISSION/s/=.*/=$EMISSION/g" $CONF_DIR/get-canal.cfg ; '$DIR/$SCRIPT' --gtk "SHOW_LIST" "$(echo "$EMISSION" | sed -e '\''s/.*(\(.*\))/\1/g'\'')"</action>
<action type="refresh">VIDEO</action>
</button>
<text wrap="true" width-chars="32" use_markup="true">
<label>" Double-cliquez sur une vidéo pour la télécharger."</label>
</text>
<tree headers_visible="false" exported_column="2">
<label> Titre | Date | Adresse de la vidéo </label>
<input>cat $TEMP_DIR/videos.$(head -1 "$TEMP_DIR/show_list" | sed -e '\''s/.*(\(.*\))/\1/g'\'')</input>
<variable>VIDEO</variable>
<action>'$DIR/$SCRIPT' --gtk "GET_VIDEO" "$VIDEO" & sleep 2</action>
</tree>
</vbox>
<frame Téléchargements>
<hbox>
<progressbar>
<input>'$DIR/$SCRIPT' --gtk "PROGRESS_BAR" "1"</input>
</progressbar>
<button>
<input file icon="filesave"></input>
<action>'$DIR/$SCRIPT' --gtk "SAVE_FILE" "1"</action>
</button>
<button sensitive="true">
<input file icon="redo"></input>
<action>'$DIR/$SCRIPT' --gtk "ADD_PLAYLIST" "1"</action>
<action type="refresh">PLAYLIST</action>
</button>
<button>
<input file icon="stop"></input>
<action>'$DIR/$SCRIPT' --gtk "DELETE_FILE" "1"</action>
</button>
</hbox>
<hbox>
<progressbar>
<input>'$DIR/$SCRIPT' --gtk "PROGRESS_BAR" "2"</input>
</progressbar>
<button>
<input file icon="filesave"></input>
<action>'$DIR/$SCRIPT' --gtk "SAVE_FILE" "2"</action>
</button>
<button sensitive="false">
<input file icon="redo"></input>
<action>OK</action>
</button>
<button>
<input file icon="stop"></input>
<action>'$DIR/$SCRIPT' --gtk "DELETE_FILE" "2"</action>
</button>
</hbox>
<hbox>
<progressbar>
<input>'$DIR/$SCRIPT' --gtk "PROGRESS_BAR" "3"</input>
</progressbar>
<button>
<input file icon="filesave"></input>
<action>'$DIR/$SCRIPT' --gtk "SAVE_FILE" "3"</action>
</button>
<button sensitive="false">
<input file icon="redo"></input>
<action>OK</action>
</button>
<button>
<input file icon="stop"></input>
<action>'$DIR/$SCRIPT' --gtk "DELETE_FILE" "3"</action>
</button>
</hbox>
<hbox>
<progressbar>
<input>'$DIR/$SCRIPT' --gtk "PROGRESS_BAR" "4"</input>
</progressbar>
<button>
<input file icon="filesave"></input>
<action>'$DIR/$SCRIPT' --gtk "SAVE_FILE" "4"</action>
</button>
<button sensitive="false">
<input file icon="redo"></input>
<action>OK</action>
</button>
<button>
<input file icon="stop"></input>
<action>'$DIR/$SCRIPT' --gtk "DELETE_FILE" "4"</action>
</button>
</hbox>
<hbox>
<progressbar>
<input>'$DIR/$SCRIPT' --gtk "PROGRESS_BAR" "5"</input>
</progressbar>
<button>
<input file icon="filesave"></input>
<action>'$DIR/$SCRIPT' --gtk "SAVE_FILE" "5"</action>
</button>
<button sensitive="false">
<input file icon="redo"></input>
<action>OK</action>
</button>
<button>
<input file icon="stop"></input>
<action>'$DIR/$SCRIPT' --gtk "DELETE_FILE" "5"</action>
</button>
</hbox>
<hbox>
<progressbar>
<input>'$DIR/$SCRIPT' --gtk "PROGRESS_BAR" "6"</input>
</progressbar>
<button>
<input file icon="filesave"></input>
<action>'$DIR/$SCRIPT' --gtk "SAVE_FILE" "6"</action>
</button>
<button sensitive="false">
<input file icon="redo"></input>
<action>OK</action>
</button>
<button>
<input file icon="stop"></input>
<action>'$DIR/$SCRIPT' --gtk "DELETE_FILE" "6"</action>
</button>
</hbox>
<hbox>
<progressbar>
<input>'$DIR/$SCRIPT' --gtk "PROGRESS_BAR" "7"</input>
</progressbar>
<button>
<input file icon="filesave"></input>
<action>'$DIR/$SCRIPT' --gtk "SAVE_FILE" "7"</action>
</button>
<button sensitive="false">
<input file icon="redo"></input>
<action>OK</action>
</button>
<button>
<input file icon="stop"></input>
<action>'$DIR/$SCRIPT' --gtk "DELETE_FILE" "7"</action>
</button>
</hbox>
<hbox>
<progressbar>
<input>'$DIR/$SCRIPT' --gtk "PROGRESS_BAR" "8"</input>
</progressbar>
<button>
<input file icon="filesave"></input>
<action>'$DIR/$SCRIPT' --gtk "SAVE_FILE" "8"</action>
</button>
<button sensitive="false">
<input file icon="redo"></input>
<action>OK</action>
</button>
<button>
<input file icon="stop"></input>
<action>'$DIR/$SCRIPT' --gtk "DELETE_FILE" "8"</action>
</button>
</hbox>
<hbox>
<progressbar>
<input>'$DIR/$SCRIPT' --gtk "PROGRESS_BAR" "9"</input>
</progressbar>
<button>
<input file icon="filesave"></input>
<action>'$DIR/$SCRIPT' --gtk "SAVE_FILE" "9"</action>
</button>
<button sensitive="false">
<input file icon="redo"></input>
<action>OK</action>
</button>
<button>
<input file icon="stop"></input>
<action>'$DIR/$SCRIPT' --gtk "DELETE_FILE" "9"</action>
</button>
</hbox>
<hbox>
<progressbar>
<input>'$DIR/$SCRIPT' --gtk "PROGRESS_BAR" "10"</input>
</progressbar>
<button>
<input file icon="filesave"></input>
<action>'$DIR/$SCRIPT' --gtk "SAVE_FILE" "10"</action>
</button>
<button sensitive="false">
<input file icon="redo"></input>
<action>OK</action>
</button>
<button>
<input file icon="stop"></input>
<action>'$DIR/$SCRIPT' --gtk "DELETE_FILE" "10"</action>
</button>
</hbox>
<hbox>
<text>
<input>echo "Raffraichir les barres toutes les"</input>
</text>
<text>
<input>grep REFRESH_DELAY= $CONF_DIR/get-canal.cfg | cut -d"=" -f2</input>
<variable>REFRESH_DELAY</variable>
</text>
<text>
<input>echo "secondes"</input>
</text>
</hbox>
<hbox>
<button>
<input file icon="gtk-remove"></input>
<action>REFRESH_DELAY=$(grep REFRESH_DELAY= $CONF_DIR/get-canal.cfg | cut -d"=" -f2) ; if [ "$REFRESH_DELAY" -gt "1" ] ; then RD=$(($REFRESH_DELAY-1)) ; sed -i "/REFRESH_DELAY=/s/=.*/=$RD/g" $CONF_DIR/get-canal.cfg ; fi</action>
<action type="refresh">REFRESH_DELAY</action>
</button>
<button>
<input file icon="gtk-add"></input>
<action>REFRESH_DELAY=$(grep REFRESH_DELAY= $CONF_DIR/get-canal.cfg | cut -d"=" -f2) ; if [ "$REFRESH_DELAY" -lt "5" ] ; then RD=$(($REFRESH_DELAY+1)) ; sed -i "/REFRESH_DELAY=/s/=.*/=$RD/g" $CONF_DIR/get-canal.cfg ; fi</action>
<action type="refresh">REFRESH_DELAY</action>
</button>
</hbox>
</frame>
<frame Playlist>
<tree headers_visible="false">
<width>300</width><height>250</height>
<label>Titre</label>
<input>cat $TEMP_DIR/playlist.info</input>
<variable>PLAYLIST</variable>
</tree>
</frame>
</hbox>
</notebook>
<hbox>
<button>
<input file icon="exit"></input>
<label>Quitter</label>
<action type="exit">OK</action>
</button>
</hbox>
</vbox>
</window>
'
##### Execution du script. #####
# Vérification de l'existance d'un dossier de configuration et lancement éventuel de la fenêtre de configuration.
if [ ! -d "$CONF_DIR" ] ; then
mkdir "$CONF_DIR"
echo "REFRESH_DELAY=1" >>$CONF_DIR/get-canal.cfg
VARIABLES=`gtkdialog --program=MAIN_CONFIG`
eval $VARIABLES
if [ "$EXIT" != "OK" ] ; then
exit 1
fi
if grep "DOWNLOAD_DIR=" $CONF_DIR/get-canal.cfg ; then
config=$(grep -v "DOWNLOAD_DIR=" $CONF_DIR/get-canal.cfg)
echo -e "$config\nDOWNLOAD_DIR=$FILE_DIRECTORY" >$CONF_DIR/get-canal.cfg
else
echo "DOWNLOAD_DIR=$FILE_DIRECTORY" >>$CONF_DIR/get-canal.cfg
fi
export DOWNLOAD_DIR="$FILE_DIRECTORY"
if grep "VIDEO_PLAYER=" $CONF_DIR/get-canal.cfg ; then
config=$(grep -v "VIDEO_PLAYER=" $CONF_DIR/get-canal.cfg)
echo -e "$config\nVIDEO_PLAYER=$VIDEO_PLAYER" >$CONF_DIR/get-canal.cfg
else
echo "VIDEO_PLAYER=$VIDEO_PLAYER" >>$CONF_DIR/get-canal.cfg
fi
else
export DOWNLOAD_DIR="$(grep DOWNLOAD_DIR= $CONF_DIR/get-canal.cfg | cut -d"=" -f2)"
export VIDEO_PLAYER="$(grep VIDEO_PLAYER= $CONF_DIR/get-canal.cfg | cut -d"=" -f2)"
if [ "$DOWNLOAD_DIR" = "" ] || [ "$VIDEO_PLAYER" = "" ] ; then
touch $CONF_DIR/get-canal.cfg
VARIABLES=`gtkdialog --program=MAIN_CONFIG`
eval $VARIABLES
if [ "$EXIT" != "OK" ] ; then
exit 1
fi
if grep "DOWNLOAD_DIR=" $CONF_DIR/get-canal.cfg ; then
config=$(grep -v "DOWNLOAD_DIR=" $CONF_DIR/get-canal.cfg)
echo -e "$config\nDOWNLOAD_DIR=$FILE_DIRECTORY" >$CONF_DIR/get-canal.cfg
else
echo "DOWNLOAD_DIR=$FILE_DIRECTORY" >>$CONF_DIR/get-canal.cfg
fi
export DOWNLOAD_DIR="$FILE_DIRECTORY"
if grep "VIDEO_PLAYER=" $CONF_DIR/get-canal.cfg ; then
config=$(grep -v "VIDEO_PLAYER=" $CONF_DIR/get-canal.cfg)
echo -e "$config\nVIDEO_PLAYER=$VIDEO_PLAYER" >$CONF_DIR/get-canal.cfg
else
echo "VIDEO_PLAYER=$VIDEO_PLAYER" >>$CONF_DIR/get-canal.cfg
fi
fi
fi
if ! grep REFRESH_DELAY=. $CONF_DIR/get-canal.cfg ; then
echo "REFRESH_DELAY=1" >>$CONF_DIR/get-canal.cfg
fi
if ! grep EMISSION=.* $CONF_DIR/get-canal.cfg ; then
echo "EMISSION=\"+ Clair226\"" >>$CONF_DIR/get-canal.cfg
fi
# Préparation du dossier temporaire.
if [ ! -d "$TEMP_DIR" ] ; then
mkdir -p $TEMP_DIR/videos
else
rm -rf $TEMP_DIR/* ; mkdir -p $TEMP_DIR/videos
fi
touch $TEMP_DIR/progress_bar.list
for i in $(seq 1 10) ; do
echo "0" >$TEMP_DIR/progress_bar$i.log
done
echo "0" >/$TEMP_DIR/playlist.id
# Chargement de la liste de la dernière emission affichée.
SHOW_LIST $(grep EMISSION= $CONF_DIR/get-canal.cfg | cut -d"\"" -f2 | sed -e 's/.*(\(.*\))/\1/g')
echo $(grep EMISSION= $CONF_DIR/get-canal.cfg | cut -d"\"" -f2) >$TEMP_DIR/show_list
# Lancement de la fenêtre principale.
gtkdialog --program=MAIN_PROGRAMM
# Supression du dossier temporaire.
rm -rf "$TEMP_DIR"
# "Kill" des processus résiduels.
killall $(basename $SCRIPT)
for i in $(ps aux | grep "/tmp/get-canal.tmp/" | grep -v grep | tr -s ' ' | cut -d" " -f2) ; do
kill -9 $i
done
exit 0
Sur cette version, je suis en train de bosser sur la playlist, il y a donc quelques petites modifs par rapport à la précédentes version, mais celles-ci ne sont pas encore fonctionnelles, donc, merci à toi de ne pas en tenir compte.
Et sinon, merci également de consacrer du temps au debuggage du script.
P.S :
Lancelin a écritEt en ce qui concerne les barres de progression il suffirait juste que tu enlèves les KB/s et MB/s pour que je sois content.
En ce qui me concerne, il suffirait que le script fonctionne chez toi comme c'est prévu qu'il fonctionne pour que je soit content 😉