Bonjour à tous!

Je suis en train d'écrire un script mais je bloque.

Le script doit
-Récupérer les paroles de la chanson (sure fichier de la chanson, pas sur le Web) en cours de lecture dans iTunes.
-Restituer les retours de ligne
-Élaguer les 10 premières lignes
-Découper le texte en plusieurs blocs de 15 lignes
-Afficher les blocs au fur et à mesure que la chanson est lue par iTunes (le script va etre utilisé ensuite avec GeekTool, qui s'occupera d'afficher les blocs sur le bureau de l'ordinateur)


Le script que j'ai bricolé compile et fonctionne partiellement mais ne fonctionne pas avec les textes de plus de 55 lignes.. J'ai tenté de le recopier ici avec les style de Applescript, sans succès, il est beaucoup plus lisible une fois compilé.

Je suis certain qu'il ne manque que quelques détails et je vous serais reconnaissant d'y jeter un coup d'oeil et éventuellement me dire ce qui ne va pas dans ce script.

Merci infiniment pour votre temps et vos conseils.



on run
set info to ""
tell application "System Events"
set runCount to count (every process whose name is "iTunes")
end tell
if runCount > 0 then
tell application "iTunes"
if player state is playing then

set _lyrics to lyrics of current track
set timetotal to duration of current track
set midtime to timetotal / 2
set thirdtime to timetotal / 3
set quartertime to timetotal / 4
set par_count to (count paragraphs in _lyrics)
set AppleScript's text item delimiters to return



if par_count ≤ 25 then
set fParagraphs1 to paragraphs 9 thru -1 of _lyrics
end if



if par_count > 25 and par_count ≤ 40 then
set fParagraphs1 to paragraphs 9 thru 25 of _lyrics
set fParagraphs2 to paragraphs 26 thru -1 of _lyrics
set fContentsNew1 to fParagraphs1 as string
set fContentsNew2 to fParagraphs2 as string

if player position ≤ midtime then
set info to fContentsNew1 as string
else
set info to fContentsNew2 as string
end if

end if



if par_count > 40 and par_count ≤ 55 then
set fParagraphs1 to paragraphs 9 thru 25 of _lyrics
set fParagraphs2 to paragraphs 26 thru 40 of _lyrics
set fParagraphs3 to paragraphs 41 thru -1 of _lyrics
set fContentsNew1 to fParagraphs1 as string
set fContentsNew2 to fParagraphs2 as string
set fContentsNew3 to fParagraphs3 as string


if player position ≤ thirdtime then
set info to fContentsNew1 as string
else if player position > thirdtime and player position ≤ thirdtime * 2 then
set info to fContentsNew2 as string
else if player position > thirdtime * 2 then
set info to fContentsNew3 as string
end if

end if
end if




if par_count > 55 then
set fParagraphs1 to paragraphs 9 thru 25 of _lyrics
set fParagraphs2 to paragraphs 26 thru 40 of _lyrics
set fParagraphs3 to paragraphs 41 thru 55 of _lyrics
set fParagraphs4 to paragraphs 56 thru -1 of _lyrics
set fContentsNew1 to fParagraphs1 as string
set fContentsNew2 to fParagraphs2 as string
set fContentsNew3 to fParagraphs3 as string
set fContentsNew4 to fParagraphs4 as string


if player position ≤ quartertime then
set info to fContentsNew1 as string
else if player position > quartertime and player position ≤ midtime then
set info to fContentsNew2 as string
else if player position > midtime and player position ≤ quartertime * 3 then
set info to fContentsNew3 as string
else if player position > quartertime * 3 then
set info to fContentsNew4 as string
end if

end if





end tell
end if
return info
end run