navarf
11-01-07, 00:05
Sono appena entrato nel tunnel degli script per Itunes :lol: :lol: :lol:
NE ho trovato uno per ottenere i testi delle canzoni qui
Get Lyrics v2.1 (http://www.dougscripts.com/itunes/scripts/scripts09.php?page=1#getlyrical)
Penso siano free (altrimenti bacchettatemi) questo è lo script
global foundcount
try
set foundcount to 0
tell application "iTunes"
set diag to button returned of (display dialog "What do you want to get lyrics for?" buttons {"Cancel", "Current", "Selection"} default button 3)
end tell
if diag is "Current" then
tell application "iTunes"
if player state is not stopped then
set trackers to {1}
set sel to current track --as list
--return sel
my liracl(sel, true)
else
display dialog "No tracks playing..." buttons {"OK"} default button 1 with icon 2 giving up after 15
error
end if
end tell
else if diag is "Selection" then
tell application "iTunes" to set trackers to (get selection)
if trackers is not {} then
repeat with i from 1 to number of items in trackers
set theTrack to item i of trackers
my liracl(theTrack, true)
end repeat
else
tell application "iTunes" to display dialog "No tracks selected..." buttons {"OK"} default button 1 with icon 2 giving up after 15
error
end if
else
error
end if
tell application "iTunes" to display dialog "Done finding lyrics!" & return & foundcount & " of " & (number of items in trackers) buttons {"OK"} default button 1 --giving up after 15
on error
--
end try
--Subroutines--
on liracl(theTrack, overwrite)
--display dialog 1
try
tell application "iTunes"
tell theTrack
set origlyr to lyrics
if (origlyr is not "") and (overwrite is false) then error
set nom to my justletters(my smallCaps(name))
set art to my justletters(my smallCaps(artist))
--display dialog nom giving up after 1
end tell
end tell
set lyrsearchlink to "http://search.lyrics.astraweb.com/?word=" & art & "+" & nom
set thelyrsearch to do shell script "curl -A\"Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-GB; rv — 1.7.10) Gecko/20050717 Firefox/1.0.6\" \"" & lyrsearchlink & "\""
set aa to item 1 of my textToList(item 2 of (my textToList(thelyrsearch, "1. [b]<a href=\"/display/")), ".html\">")
set ab to "http://lyrics.astraweb.com/displayp.cgi?f=" & item 2 of my textToList(aa, "/")
set thelyr to do shell script "curl -A\"Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-GB; rv — 1.7.10) Gecko/20050717 Firefox/1.0.6\" \"" & ab & "\""
set ba to item 1 of my textToList(item 2 of my textToList(thelyr, "<blockquote>"), "</blockquote>")
set bb to switchText(ba, "
", return)
set clearedhtml to my clearHTML(bb)
set LyricalF to my rmfb(bb) & return & return & "[ Find/add/request lyrics at lyrics.astraweb.com ]"
--display dialog 1 default answer LyricalF
tell application "iTunes"
tell theTrack
set lyrics to LyricalF
end tell
end tell
set foundcount to foundcount + 1
on error
--error
end try
end liracl
on rmfb(t)
set p1 to paragraphs of t
repeat with i from 1 to number of items in p1
set ti to item i of p1
set sh to do shell script "echo '" & ti & "' | sed 's/^[ \\t]*//;s/[ \\t]*$//'"
if sh is not "" then
set p2 to items i thru -1 of p1
exit repeat
end if
end repeat
set p2 to reverse of p2
repeat with i from 1 to number of items in p2
set ti to item i of p2
set sh to do shell script "echo '" & ti & "' | sed 's/^[ \\t]*//;s/[ \\t]*$//'"
if sh is not "" then
set p3 to items i thru -1 of p2
exit repeat
end if
end repeat
set p3 to reverse of p3
set the item_count to the number of items in p3
repeat with i from 1 to the item_count
set ti to item i of p3
if i is 1 then
set ret to ti
else
set ret to ret & return & ti
end if
end repeat
return ret as text
end rmfb
on switchText(tex, remove, neww)
set d to text item delimiters
set text item delimiters to remove
set tex to tex's text items
set text item delimiters to neww
tell tex to set tex to beginning & ({""} & rest)
set text item delimiters to d
return tex
end switchText
on textToList(theText, theSep)
set soFar to {}
set textSoFar to theText
repeat until theSep is not in textSoFar
set thePos to the offset of theSep in textSoFar
set thenewPos to thePos
if thenewPos is 1 then set thenewPos to 2
set nextBit to text 1 through (thenewPos - 1) of textSoFar
if textSoFar is not theSep then
set textSoFar to text (thePos + (count of text items in theSep)) through -1 of textSoFar
copy nextBit to the end of soFar
else
set textSoFar to ""
end if
end repeat
copy textSoFar to the end of soFar
return soFar
end textToList
on clearHTML(theText)
set Lthetext to text items of theText
set tl to {}
set kill to false
repeat with i from 1 to number of items in Lthetext
set this_item to item i of Lthetext
if this_item is "<" then set kill to true
if kill is false then set end of tl to this_item
if this_item is ">" then set kill to false
end repeat
return tl as text
end clearHTML
on justletters(teststring)
if word 1 of teststring is "the" then set teststring to text 5 thru -1 of teststring
set the testlist to the text items of the teststring
set ns to {}
repeat with letter in testlist
set asc to the ASCII number of the letter
if (asc is greater than 96) and (asc is less than 123) then
set end of ns to ASCII character asc
else if asc is 32 then
set end of ns to ASCII character 43
end if
end repeat
set the teststring to the ns as text
return the teststring
end justletters
on smallCaps(teststring)
set the testlist to the text items of the teststring
repeat with letter in testlist
set asc to the ASCII number of the letter
if (asc is greater than 64) and (asc is less than 91) then
set the contents of the letter to ASCII character (asc + 32)
end if
end repeat
set the teststring to the testlist as text
return the teststring
end smallCaps
Vorrei sapere come fare a cambiare il sito dove prende i testi per esempio invece che astraweb ecc.. vada su getlyrics.com o magari un altro più fornito
Qualcuno ha idea?...magari non è complicato (spero) ealtri utenti possono essere interessati
Grazie
:)
NE ho trovato uno per ottenere i testi delle canzoni qui
Get Lyrics v2.1 (http://www.dougscripts.com/itunes/scripts/scripts09.php?page=1#getlyrical)
Penso siano free (altrimenti bacchettatemi) questo è lo script
global foundcount
try
set foundcount to 0
tell application "iTunes"
set diag to button returned of (display dialog "What do you want to get lyrics for?" buttons {"Cancel", "Current", "Selection"} default button 3)
end tell
if diag is "Current" then
tell application "iTunes"
if player state is not stopped then
set trackers to {1}
set sel to current track --as list
--return sel
my liracl(sel, true)
else
display dialog "No tracks playing..." buttons {"OK"} default button 1 with icon 2 giving up after 15
error
end if
end tell
else if diag is "Selection" then
tell application "iTunes" to set trackers to (get selection)
if trackers is not {} then
repeat with i from 1 to number of items in trackers
set theTrack to item i of trackers
my liracl(theTrack, true)
end repeat
else
tell application "iTunes" to display dialog "No tracks selected..." buttons {"OK"} default button 1 with icon 2 giving up after 15
error
end if
else
error
end if
tell application "iTunes" to display dialog "Done finding lyrics!" & return & foundcount & " of " & (number of items in trackers) buttons {"OK"} default button 1 --giving up after 15
on error
--
end try
--Subroutines--
on liracl(theTrack, overwrite)
--display dialog 1
try
tell application "iTunes"
tell theTrack
set origlyr to lyrics
if (origlyr is not "") and (overwrite is false) then error
set nom to my justletters(my smallCaps(name))
set art to my justletters(my smallCaps(artist))
--display dialog nom giving up after 1
end tell
end tell
set lyrsearchlink to "http://search.lyrics.astraweb.com/?word=" & art & "+" & nom
set thelyrsearch to do shell script "curl -A\"Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-GB; rv — 1.7.10) Gecko/20050717 Firefox/1.0.6\" \"" & lyrsearchlink & "\""
set aa to item 1 of my textToList(item 2 of (my textToList(thelyrsearch, "1. [b]<a href=\"/display/")), ".html\">")
set ab to "http://lyrics.astraweb.com/displayp.cgi?f=" & item 2 of my textToList(aa, "/")
set thelyr to do shell script "curl -A\"Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-GB; rv — 1.7.10) Gecko/20050717 Firefox/1.0.6\" \"" & ab & "\""
set ba to item 1 of my textToList(item 2 of my textToList(thelyr, "<blockquote>"), "</blockquote>")
set bb to switchText(ba, "
", return)
set clearedhtml to my clearHTML(bb)
set LyricalF to my rmfb(bb) & return & return & "[ Find/add/request lyrics at lyrics.astraweb.com ]"
--display dialog 1 default answer LyricalF
tell application "iTunes"
tell theTrack
set lyrics to LyricalF
end tell
end tell
set foundcount to foundcount + 1
on error
--error
end try
end liracl
on rmfb(t)
set p1 to paragraphs of t
repeat with i from 1 to number of items in p1
set ti to item i of p1
set sh to do shell script "echo '" & ti & "' | sed 's/^[ \\t]*//;s/[ \\t]*$//'"
if sh is not "" then
set p2 to items i thru -1 of p1
exit repeat
end if
end repeat
set p2 to reverse of p2
repeat with i from 1 to number of items in p2
set ti to item i of p2
set sh to do shell script "echo '" & ti & "' | sed 's/^[ \\t]*//;s/[ \\t]*$//'"
if sh is not "" then
set p3 to items i thru -1 of p2
exit repeat
end if
end repeat
set p3 to reverse of p3
set the item_count to the number of items in p3
repeat with i from 1 to the item_count
set ti to item i of p3
if i is 1 then
set ret to ti
else
set ret to ret & return & ti
end if
end repeat
return ret as text
end rmfb
on switchText(tex, remove, neww)
set d to text item delimiters
set text item delimiters to remove
set tex to tex's text items
set text item delimiters to neww
tell tex to set tex to beginning & ({""} & rest)
set text item delimiters to d
return tex
end switchText
on textToList(theText, theSep)
set soFar to {}
set textSoFar to theText
repeat until theSep is not in textSoFar
set thePos to the offset of theSep in textSoFar
set thenewPos to thePos
if thenewPos is 1 then set thenewPos to 2
set nextBit to text 1 through (thenewPos - 1) of textSoFar
if textSoFar is not theSep then
set textSoFar to text (thePos + (count of text items in theSep)) through -1 of textSoFar
copy nextBit to the end of soFar
else
set textSoFar to ""
end if
end repeat
copy textSoFar to the end of soFar
return soFar
end textToList
on clearHTML(theText)
set Lthetext to text items of theText
set tl to {}
set kill to false
repeat with i from 1 to number of items in Lthetext
set this_item to item i of Lthetext
if this_item is "<" then set kill to true
if kill is false then set end of tl to this_item
if this_item is ">" then set kill to false
end repeat
return tl as text
end clearHTML
on justletters(teststring)
if word 1 of teststring is "the" then set teststring to text 5 thru -1 of teststring
set the testlist to the text items of the teststring
set ns to {}
repeat with letter in testlist
set asc to the ASCII number of the letter
if (asc is greater than 96) and (asc is less than 123) then
set end of ns to ASCII character asc
else if asc is 32 then
set end of ns to ASCII character 43
end if
end repeat
set the teststring to the ns as text
return the teststring
end justletters
on smallCaps(teststring)
set the testlist to the text items of the teststring
repeat with letter in testlist
set asc to the ASCII number of the letter
if (asc is greater than 64) and (asc is less than 91) then
set the contents of the letter to ASCII character (asc + 32)
end if
end repeat
set the teststring to the testlist as text
return the teststring
end smallCaps
Vorrei sapere come fare a cambiare il sito dove prende i testi per esempio invece che astraweb ecc.. vada su getlyrics.com o magari un altro più fornito
Qualcuno ha idea?...magari non è complicato (spero) ealtri utenti possono essere interessati
Grazie
:)