Pages : 1
#1 Le 09/02/2010, à 23:35
- wlourf
conky pour FIP
Bonjour,
Je suis en train d'écrire un conky pour afficher la programmation de FIP sur mon bureau. Le conky va appeler un script bash qui renvoie les valeurs Artiste,Album ....
Voici le script
#! /bin/bash
file1="/tmp/get_fip.txt"
file2="/tmp/fip.txt"
function extract {
a=$(($(expr "$line_txt" : ".*$begin")))
b=$(($(expr "$line_txt" : ".*$end")-$a-${#end}))
echo ${line_txt:$a:$b}
}
if [ "$1" == "W" ]; then
if [ -f $file2 ]; then
rm $file2
fi
GET http://sites.radiofrance.fr/chaines/fip/endirect/popprog.php?first=0 > $file1
match="<td BGCOLOR=\"#ED1A3B\" CLASS=\"blanc11\"><SPAN CLASS=\"txt\">"
line_txt=""
while read line
do
if [[ "$line" =~ "${match}" ]]; then
line_txt=$line
break
fi
done < $file1
if [[ "$line_txt" == "" ]]; then
echo "Pas d'info FIP..."
exit
fi
begin="<B>"
end="</B>"
artist=$(extract)
begin=$end
end="</SPAN>"
title=$(extract)
begin="Album :"
end="<br>Label"
album=$(extract)
begin="Label :"
end="<br>Ann"
label=$(extract)
begin="Ann"
end="</td>"
year=$(extract)
if [ "$title" == "PROGRAMME FIP" ]; then
artist=""
album=""
label=""
year=""
fi
echo
echo $line_txt #<=== ligne à commenter pour utiliser avec le conky
echo
echo $artist > $file2
echo $title >> $file2
echo $album >> $file2
echo $label >> $file2
echo $year >> $file2
fi
if [ "$1" == "R" ]; then
i=0
while read line
do
if [ "$i" == "$2" ]; then
echo $line
fi
i=$(( $i + 1 ))
done < $file2
fi
Pour lancer le script et enregistrer les données dans un fichier (/tmp/fip.txt):
./get_fip.sh W
Voici mon problème, je n'arrive pas à retourner l'année (à cause de l'accent) et probablement tous les titres avec des accents, quelqu'un peut m'aider , pleaze ?
Sinon, voici le conky, pour ceux que ça interesse :
# -- Conky settings -- #
background no
update_interval 15
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
double_buffer yes
no_buffers yes
text_buffer_size 2048
imlib_cache_size 0
# -- Window specifications -- #
own_window yes
own_window_type desktop
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
minimum_size 400 100
alignment tl
gap_y 500
gap_x 500
# -- Graphics settings -- #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
# -- Text settings -- #
use_xft yes
xftfont webdings:size=12
xftalpha 0.8
color0 666666
color1 BBBBBB
default_color FFFFFF
TEXT
${font Purisa:size=12}${color #FF0000}${exec /home/wlourf/scripts/conkys/get_fip.sh "W"}${color #666666}
${if_existing /tmp/fip.txt}${color0}${voffset -24}${font webdings:size=24}ó ${color1}${voffset -6}${font Purisa:size=12}${exec /home/wlourf/scripts/conkys/get_fip.sh "R" "0"}
${color0}${font webdings:size=24}Ø ${color1}${voffset -6}${font Purisa:size=12}${exec /home/wlourf/scripts/conkys/get_fip.sh "R" "1"}
${color0}${font webdings:size=18}n ${color1}${offset 9}${voffset -3}${font Purisa:size=12}${exec /home/wlourf/scripts/conkys/get_fip.sh "R" "2"}
${color0}${font webdings:size=22}í ${color1}${offset 4}${voffset -1}${font Purisa:size=12}${exec /home/wlourf/scripts/conkys/get_fip.sh "R" "3"}
${color1}${font Purisa:size=12}${exec /home/wlourf/scripts/conkys/get_fip.sh "R" "4"}
${endif}
et voici la sortie en image, provisoire et sobre:
Merci d'avance pour vos idées !
Edit : script corrigé pour affichage correct quand pas d'infos (après 23h)
Dernière modification par wlourf (Le 10/02/2010, à 00:30)
Hors ligne
#2 Le 06/05/2010, à 05:14
- Seiko Matsumoto
Re : conky pour FIP
C'est une super idée, tu as trouvé une solution depuis le temps ?
www.utopie57.net
Hors ligne
#3 Le 06/05/2010, à 19:06
- wlourf
Re : conky pour FIP
oui, avec l'aide de AnsuzPeorth qui m'a aidé à extraire l'année.
J'ai aussi intégré l'image de l'album et rendu le script plus "universel". En entrée, le script reçoit un fichier texte (donc n'importe quel script peut générer un fichier pour n'importe quelle radio) avec au moins un des éléments suivants:
radio:__FIP radio__
artist:Sonny Rollins
title:Come, Gone
album:Way out West
label:Contemporary
year:1957
cover:/tmp/radio-cover
et en sortie, le conky affiche ça (pas dans une fenêtre, sur le bureau):
Enfin, tout est paramétrable, tous les détails sur mon blog qui t'amènera à la page de téléchargement sur ubuntu us. C'est en anglais, si tu as un soucis dis le moi.
Dernière modification par wlourf (Le 06/05/2010, à 19:10)
Hors ligne
#4 Le 24/04/2012, à 12:12
- olive33
Re : conky pour FIP
Bonjour,
déterrage de post!!
Depuis quelques mois la popup n'existe plus
quelqu'un a-t-il réussi à extraire les infos de la page d'accueil de FIP? ce me semble beaucoup plus compliqué, mais si on y arrive il y a plus d'infos: morceaux précédant, morceaux suivant, pochette...
O.
Ubuntu 14.04 LTS... -Intel i5 -nvidia gt520 ...joli boitier de salon bien silencieux :D
Lubuntu pour la musique dans un boitier encore plus joli et encore plus silencieux !!
Hors ligne
Pages : 1