Pages : 1
#1 Le 22/07/2010, à 20:50
- TheCaméléon
Conky - Paroles Synchronisées
Bonjour !
J'ai fait il y a quelques semaines un petit script pour conky qui affiche les paroles synchronisées dans conky.
Il est basé sur Conky Lyrics, mais adapté pour Conky. Par simplicité, le script n'utilise qu'une source pour les paroles, alors que le script original en utilise plusieurs (3-4 il me semble).
FONCTIONNE AVEC RHYTHMBOX
Il est fonctionnel et ne beug pas de trop. Il enregistre les nouvelles paroles dans un fichier afin de ne pas avoir à les ré-télécharger à chaque rafraichissement de Conky. Les paroles sont assez longues à s'afficher au début de chaque morceau, mais après ça fonctionne très bien
Le script affiche la ligne en cours, plus les 3 suivantes et précédentes
Il nécessite 2 fichiers et en créé 2 autres lors de son exécution.
GetLiveLyrics (à rendre exécutable)
#! /bin/sh
here="$(dirname $0)"
artiste=$(rhythmbox-client --print-playing-format "%aa")
morceau=$(rhythmbox-client --print-playing-format "%tt")
temps=$(rhythmbox-client --print-playing-format "%te")
if [ "$temps" = "Inconnu" ]; then
temps="0"
fi
min=$(echo $temps | cut -d':' -f1)
sec=$(echo $temps | cut -d':' -f2)
sec=$(echo "$sec" | sed -r 's/^0//g')
tps_sec=$((min*60+sec))
song_cache=$(cat "$here/song")
if [ "$artiste @ $morceau" = "$song_cache" ]; then
retour=$(cat "$here/lyric")
else
request=$(cat "$here/query.xml" | sed "s/title/$morceau/" | sed "s/artist/$artiste/")
retour=$(wget \
--header='Content-Type: text/xml; charset=utf-8' \
--header='Host: lyrics.alsong.net' \
--post-data="$request" \
-O - \
-q \
"http://lyrics.alsong.net/alsongwebservice/service1.asmx" |
perl -pe 's|^.*<strLyric>(.*)</strLyric>.*$|\1|g' |
sed 's/<br>/\n/g' |
uniq -w 10)
echo "$retour" > $here/lyric
echo "$artiste @ $morceau" > $here/song
fi
min=$(($tps_sec-10))
max=$(($tps_sec+20))
if [ "$(echo "$min" | cut -c1)" = "-" ]; then
min="0"
fi
diff_small="100000000000000"
line="1"
echo "$retour" | ( while read ligne
do
tps_ligne=$(echo "$ligne" | sed -r 's/^\[([0-9:.]{8})\].*$/\1/g' | cut -c-5)
minute=$(echo $tps_ligne | cut -d':' -f1)
seconde=$(echo $tps_ligne | cut -d':' -f2)
seconde=$(echo "$seconde" | sed -r 's/^0//g')
tps_ligne_sec=$((minute*60+seconde))
if [ "$tps_ligne_sec" -gt "$min" ] && [ "$tps_ligne_sec" -lt "$max" ]; then
lyric_ligne=$(echo "$ligne" | cut -c11-)
#echo "$lyric_ligne"
fi
diff_tps=$(echo "$((tps_sec - tps_ligne_sec))" | sed 's/^-//g')
#echo "> $line - $tps_ligne_sec - $diff_tps - $diff_small" >> $here/log
if [ "$diff_tps" -le "$diff_small" ]; then
current_line="$line"
diff_small="$diff_tps"
fi
#echo "(prev current_line $current_line)" >> $here/log
line=$((line + 1))
done
#echo "> $current_line <" >> $here/log
#printf "$retour" | cut -c11- | cat -n | sed -r 's/\t/ /g' | grep -E "^ +$current_line " | sed -r 's/^ +([0-9]+) //g' | sed -r 's/^/♫ /g' | xclip -i -selection primary♫
echo "$retour" | cut -c11- | cat -n | sed -r 's/\t/ /g' | grep -E "^ +$((current_line - 1)) " -B 2 | sed -r 's/^ +([0-9]+) //g'
echo "$retour" | cut -c11- | cat -n | sed -r 's/\t/ /g' | grep -E "^ +$current_line " | sed -r 's/^ +([0-9]+) //g' | sed -r 's/^/> /g'
echo "$retour" | cut -c11- | cat -n | sed -r 's/\t/ /g' | grep -E "^ +$((current_line + 1)) " -A 2 | sed -r 's/^ +([0-9]+) //g'
)
(vers la fin il y a une ligne à décommenter pour envoyer les paroles en cours vers le presse papier du clic milieu, mais cela à l'inconvénient de faire perdre la sélection de texte si tel est le cas)
query.xml
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="ALSongWebServer">
<SOAP-ENV:Body>
<ns1:GetResembleLyric2>
<ns1:stQuery>
<ns1:strTitle>$title</ns1:strTitle>
<ns1:strArtistName>$artist</ns1:strArtistName>
<ns1:nCurPage>0</ns1:nCurPage>
</ns1:stQuery>
</ns1:GetResembleLyric2>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
.conkyrc
${exec ~/.conky/GetLiveLyrics 2>/dev/null}
Voilà !
Si vous avez des commentaires, n'hésitez pas
Dernière modification par TheCaméléon (Le 22/07/2010, à 20:53)
Hors ligne
#2 Le 31/07/2010, à 19:38
- TheCaméléon
Re : Conky - Paroles Synchronisées
Pour ceux qui voudraient récupérer tous les fichiers d'un coup :
http://pictuga.0dollarwebspace.com/fiche-269.html
Dernière modification par TheCaméléon (Le 31/07/2010, à 19:38)
Hors ligne
Pages : 1