IPB     Il futuro di Tevac dipende da te!  

Benvenuto Visitatore ( Log In | Registrati )

  · · · · · · · · · · · ·
Reply to this topicStart new topic
> Modifica Artista in iTunes
drscholls
messaggio 19 Feb 2008, 14:26
Messaggio #1


Level 4/11
****

Gruppo: Forum User +
Messaggi: 322
Iscritto il: 3-November 04
Utente Nr.: 2.630



Ho trovato un bellissimo script che modifica i nomi delle tracce in iTunes e le converte nel formato Aaaa Aaa Aaa, cioè la prima lettera maiuscola e tutte le altre minuscole.
Non avendone trovato uno apposito volevo modificarlo per fare la stessa cosa con i nomi degli artisti, ma sinceramente non so da dove cominciare.
Potete darci un'occhiata per favore?
Grazie mille
Gianluca

CODICE
(*
"Selected Track Names to Word Caps" v2.5
Capitalizes the first letter of each word
in the selected tracks' names;
thus, "Come as you are" becomes
"Come As You Are"

v2.5 -fixes single letter problem
- fixes problem when track name begins with punctuation
- fixes potential timeout problem

written by Doug Adams
Get more free AppleScripts for iTunes and
help writing your own:
http://www.malcolmadams.com/itunes/
*)
property ucha : {"Á", "À", "Â", "Ä", "Ã", "Å", "Ç", "É", "È", "Ê", "Ë", "Í", "Ì", "Î", "Ï", "Ñ", "Ó", "Ò", "Ô", "Ö", "Õ", "Ú", "Ù", "Û", "Ü", "Æ", "Œ", "Ÿ"}
property lcha : {"á", "à", "â", "ä", "ã", "å", "ç", "é", "è", "ê", "ë", "í", "ì", "î", "ï", "ñ", "ó", "ò", "ô", "ö", "õ", "ú", "ù", "û", "ü", "æ", "œ", "ÿ"}
property myDelims : {" ", "@", "#", "^", "&", "*", "(", "–", "-", "+", "=", ":", ";", ",", ".", "/", "<", "{", "[", "_", "~", "`"}

tell application "iTunes"
    if selection is not {} then -- if tracks are selected...
        -- store fixed indexing and set
        set old_fi to fixed indexing
        set fixed indexing to true
        
        set sel to get a reference to selection
        with timeout of 30000 seconds
            repeat with aTrack in sel
                set atracksname to aTrack's name
                
                set tempname to ""
                with timeout of 30000 seconds
                    
                    repeat with j from 1 to length of atracksname
                        
                        -- set all to LOWER CASE
                        set asc1 to (ASCII number of (character j of atracksname))
                        if (asc1 is greater than 64) and (asc1 is less than 91) then
                            set tempname to (tempname & (ASCII character (asc1 + 32)))
                        else
                            set x to character j of atracksname
                            repeat with ac from 1 to count of items in lcha
                                if item ac of ucha = x then set x to item ac of lcha
                            end repeat
                            set tempname to tempname & x
                        end if
                    end repeat -- with a character of atracksname
                end timeout
                
                copy tempname to atracksname
                if (count of words in (atracksname as text)) is greater than 1 then
                    --display dialog "WHOA!"
                    with timeout of 30000 seconds
                        repeat with punct in myDelims
                            if atracksname contains punct then
                                set word_list to my TextToList(atracksname, (punct as string))
                                
                                set newTitle to {} -- init holder
                                
                                
                                repeat with w from 1 to (count of items of word_list)
                                    set aWord to item w of word_list
                                    set newWord to "" -- iitialize holer
                                    if aWord is not "" then
                                        set t1 to (ASCII number of (first character of aWord))
                                        if t1 is greater than 96 and ¬
                                            t1 is less than 123 then
                                            if length of aWord is greater than 1 then
                                                set newWord to ((ASCII character (t1 - 32)) & (text 2 thru -1 of aWord))
                                            else
                                                set newWord to (ASCII character (t1 - 32))
                                            end if
                                        else if {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} does not contain (first character of aWord) then
                                            set x to first character of aWord
                                            repeat with ac from 1 to count of items in lcha
                                                if item ac of lcha = x then set x to item ac of ucha
                                            end repeat
                                            if length of aWord is greater than 1 then
                                                set newWord to x & (text 2 thru -1 of aWord)
                                            else
                                                set newWord to x
                                            end if
                                        else
                                            copy aWord to newWord
                                        end if
                                    end if
                                    copy newWord to end of newTitle
                                end repeat -- done with aWord
                                
                                set atracksname to my ListToText(newTitle, (punct as string)) -- convert list of words
                            end if -- punct in atracksname
                        end repeat -- next punct    
                    end timeout
                else
                    copy atracksname to aWord
                    set newWord to "" -- iitialize holer
                    set t1 to (ASCII number of (first character of aWord))
                    if t1 is greater than 96 and ¬
                        t1 is less than 123 then
                        if length of aWord is greater than 1 then
                            set newWord to ((ASCII character (t1 - 32)) & (text 2 thru -1 of aWord))
                        else
                            set newWord to (ASCII character (t1 - 32))
                        end if
                    else if {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} does not contain (first character of aWord) then
                        set x to first character of aWord
                        repeat with ac from 1 to count of items in lcha
                            if item ac of lcha = x then set x to item ac of ucha
                        end repeat
                        if length of aWord is greater than 1 then
                            set newWord to x & (text 2 thru -1 of aWord)
                        else
                            set newWord to x
                        end if
                    else
                        copy aWord to newWord
                    end if
                    copy newWord to atracksname
                end if
                set name of aTrack to atracksname
                
            end repeat -- all selected tracks
        end timeout
        copy old_fi to fixed indexing -- restore fixed indexing
        display dialog "Done!" buttons {"Thanks"} default button 1 with icon 1 giving up after 90
    else
        display dialog "No tracks have been selected." buttons {"Cancel"} default button 1 with icon 0
    end if -- no selection
end tell
--=============================================

on TextToList(theText, theDelimiter)
    set saveDelim to AppleScript's text item delimiters
    try
        set AppleScript's text item delimiters to {theDelimiter}
        set theList to every text item of theText
    on error errStr number errNum
        set AppleScript's text item delimiters to saveDelim
        error errStr number errNum
    end try
    set AppleScript's text item delimiters to saveDelim
    return (theList)
end TextToList

on ListToText(theList, theDelimiter)
    set saveDelim to AppleScript's text item delimiters
    try
        set AppleScript's text item delimiters to {theDelimiter}
        set theText to theList as text
    on error errStr number errNum
        set AppleScript's text item delimiters to saveDelim
        error errStr number errNum
    end try
    set AppleScript's text item delimiters to saveDelim
    return (theText)
end ListToText
Go to the top of the page
 
+Quote Post
chebfarid
messaggio 19 Feb 2008, 14:50
Messaggio #2


Level 8/11
********

Gruppo: Team Moderatori
Messaggi: 3.791
Iscritto il: 11-July 03
Da: Milano
Utente Nr.: 395



Ciao Gianluca,
non ho la possibilità di provarlo adesso ma dando una occhiata al codice da te postato mi sembra che devi semplicemente sostituire ogni riferimento al nome del brano (nello script aTrack's name) con un riferimento all'artista del brano che dovrebbe essere accessibile con aTracks artist.

Buon scripting
Farid


--------------------
Abends lustig, morgens triste
das ist Leben von Artiste
Go to the top of the page
 
+Quote Post
drscholls
messaggio 20 Feb 2008, 11:48
Messaggio #3


Level 4/11
****

Gruppo: Forum User +
Messaggi: 322
Iscritto il: 3-November 04
Utente Nr.: 2.630



Niente, purtroppo la modifica che mi hai proposto non funziona, continua a cambiare il titolo della canzone.
Ho dato un'occhiata al dizionario ma da profano mi pare di non aver trovato nulla che si riferisse all'artista.
Se qualcuno ne sa di più.....
Grazie mille
Gianluca
Go to the top of the page
 
+Quote Post
chebfarid
messaggio 20 Feb 2008, 12:57
Messaggio #4


Level 8/11
********

Gruppo: Team Moderatori
Messaggi: 3.791
Iscritto il: 11-July 03
Da: Milano
Utente Nr.: 395



Hai corretto anche questa riga?
CODICE
set name of aTrack to atracksname

che ovviamente deve diventare
CODICE
set artist of aTrack to atracksartist

dove atracksartist sta per la viariabile che stai utilizzando per l'artista del brano...

Ciao
Farid


--------------------
Abends lustig, morgens triste
das ist Leben von Artiste
Go to the top of the page
 
+Quote Post
drscholls
messaggio 20 Feb 2008, 15:05
Messaggio #5


Level 4/11
****

Gruppo: Forum User +
Messaggi: 322
Iscritto il: 3-November 04
Utente Nr.: 2.630



Allora, con cerca e sostituisci ho sostituito in tutto lo script "name" con "artist" e funziona correttamente.
Ecco lo script:

CODICE
(*
"Selected Track artists to Word Caps" v2.5
Capitalizes the first letter of each word
in the selected tracks' artists;
thus, "Come as you are" becomes
"Come As You Are"

v2.5 -fixes single letter problem
- fixes problem when track artist begins with punctuation
- fixes potential timeout problem

written by Doug Adams
Get more free AppleScripts for iTunes and
help writing your own:
http://www.malcolmadams.com/itunes/
*)
property ucha : {"Á", "À", "Â", "Ä", "Ã", "Å", "Ç", "É", "È", "Ê", "Ë", "Í", "Ì", "Î", "Ï", "Ñ", "Ó", "Ò", "Ô", "Ö", "Õ", "Ú", "Ù", "Û", "Ü", "Æ", "Œ", "Ÿ"}
property lcha : {"á", "à", "â", "ä", "ã", "å", "ç", "é", "è", "ê", "ë", "í", "ì", "î", "ï", "ñ", "ó", "ò", "ô", "ö", "õ", "ú", "ù", "û", "ü", "æ", "œ", "ÿ"}
property myDelims : {" ", "@", "#", "^", "&", "*", "(", "–", "-", "+", "=", ":", ";", ",", ".", "/", "<", "{", "[", "_", "~", "`"}

tell application "iTunes"
    if selection is not {} then -- if tracks are selected...
        -- store fixed indexing and set
        set old_fi to fixed indexing
        set fixed indexing to true
        
        set sel to get a reference to selection
        with timeout of 30000 seconds
            repeat with aTrack in sel
                set atracksartist to aTrack's artist
                
                set tempartist to ""
                with timeout of 30000 seconds
                    
                    repeat with j from 1 to length of atracksartist
                        
                        -- set all to LOWER CASE
                        set asc1 to (ASCII number of (character j of atracksartist))
                        if (asc1 is greater than 64) and (asc1 is less than 91) then
                            set tempartist to (tempartist & (ASCII character (asc1 + 32)))
                        else
                            set x to character j of atracksartist
                            repeat with ac from 1 to count of items in lcha
                                if item ac of ucha = x then set x to item ac of lcha
                            end repeat
                            set tempartist to tempartist & x
                        end if
                    end repeat -- with a character of atracksartist
                end timeout
                
                copy tempartist to atracksartist
                if (count of words in (atracksartist as text)) is greater than 1 then
                    --display dialog "WHOA!"
                    with timeout of 30000 seconds
                        repeat with punct in myDelims
                            if atracksartist contains punct then
                                set word_list to my TextToList(atracksartist, (punct as string))
                                
                                set newTitle to {} -- init holder
                                
                                
                                repeat with w from 1 to (count of items of word_list)
                                    set aWord to item w of word_list
                                    set newWord to "" -- iitialize holer
                                    if aWord is not "" then
                                        set t1 to (ASCII number of (first character of aWord))
                                        if t1 is greater than 96 and ¬
                                            t1 is less than 123 then
                                            if length of aWord is greater than 1 then
                                                set newWord to ((ASCII character (t1 - 32)) & (text 2 thru -1 of aWord))
                                            else
                                                set newWord to (ASCII character (t1 - 32))
                                            end if
                                        else if {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} does not contain (first character of aWord) then
                                            set x to first character of aWord
                                            repeat with ac from 1 to count of items in lcha
                                                if item ac of lcha = x then set x to item ac of ucha
                                            end repeat
                                            if length of aWord is greater than 1 then
                                                set newWord to x & (text 2 thru -1 of aWord)
                                            else
                                                set newWord to x
                                            end if
                                        else
                                            copy aWord to newWord
                                        end if
                                    end if
                                    copy newWord to end of newTitle
                                end repeat -- done with aWord
                                
                                set atracksartist to my ListToText(newTitle, (punct as string)) -- convert list of words
                            end if -- punct in atracksartist
                        end repeat -- next punct    
                    end timeout
                else
                    copy atracksartist to aWord
                    set newWord to "" -- iitialize holer
                    set t1 to (ASCII number of (first character of aWord))
                    if t1 is greater than 96 and ¬
                        t1 is less than 123 then
                        if length of aWord is greater than 1 then
                            set newWord to ((ASCII character (t1 - 32)) & (text 2 thru -1 of aWord))
                        else
                            set newWord to (ASCII character (t1 - 32))
                        end if
                    else if {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} does not contain (first character of aWord) then
                        set x to first character of aWord
                        repeat with ac from 1 to count of items in lcha
                            if item ac of lcha = x then set x to item ac of ucha
                        end repeat
                        if length of aWord is greater than 1 then
                            set newWord to x & (text 2 thru -1 of aWord)
                        else
                            set newWord to x
                        end if
                    else
                        copy aWord to newWord
                    end if
                    copy newWord to atracksartist
                end if
                set artist of aTrack to atracksartist
                
            end repeat -- all selected tracks
        end timeout
        copy old_fi to fixed indexing -- restore fixed indexing
        display dialog "Done!" buttons {"Thanks"} default button 1 with icon 1 giving up after 90
    else
        display dialog "No tracks have been selected." buttons {"Cancel"} default button 1 with icon 0
    end if -- no selection
end tell
--=============================================

on TextToList(theText, theDelimiter)
    set saveDelim to AppleScript's text item delimiters
    try
        set AppleScript's text item delimiters to {theDelimiter}
        set theList to every text item of theText
    on error errStr number errNum
        set AppleScript's text item delimiters to saveDelim
        error errStr number errNum
    end try
    set AppleScript's text item delimiters to saveDelim
    return (theList)
end TextToList

on ListToText(theList, theDelimiter)
    set saveDelim to AppleScript's text item delimiters
    try
        set AppleScript's text item delimiters to {theDelimiter}
        set theText to theList as text
    on error errStr number errNum
        set AppleScript's text item delimiters to saveDelim
        error errStr number errNum
    end try
    set AppleScript's text item delimiters to saveDelim
    return (theText)
end ListToText


Grazie mille
Gianluca
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 

Collapse

> 

    Titolo discussione Risposte Autore discussione Visite Ultima azione
No New Posts   3 danilomica 57 Ieri, 07:06
Ultimo messaggio di: danilomica
No New Posts   2 gerod 79 25 November 2008 - 08:49
Ultimo messaggio di: sem®
No New Posts   3 [Daitarn] 89 23 November 2008 - 11:48
Ultimo messaggio di: [Daitarn]
No New Posts   0 Tevac Staff 88 21 November 2008 - 09:19
Ultimo messaggio di: Tevac Staff
No New Posts   1 Lepronte 70 17 November 2008 - 16:22
Ultimo messaggio di: macdvd
No New Posts   6 therob 105 13 November 2