applescript folksonomy (genre tagger)

 
    • t-spoon said...
    • User
    • 25 May 2007, 20:57

    applescript folksonomy (genre tagger)

    Ever wish you could get your music library organized so you could make some really clever smartplaylists and be all smooth and Web 2.0? This script will get you closer. Looking at allmusic guide's genre suggestions got you scratching your head? Let the community decide.

    This script uses the artist top tags feed. The very top tag is assigned to genre while other popular tags are placed in the comments field. It's a little slow, but it's faster than doing the work manually. It crashes is Last.fm doesn't like the way you've got the artist tag. Not sure this isn't in the feature bin as it will point out to you tracks that can't be succesfully scrobbled. (clean up your tags!)Suggestings to stream-line would be appreciated. I am an XML novice. Oh, I borrowed big chunks of code from a script on the web i found here.

    Here's the source:

    tell application "iTunes"
    if selection = {} then
    display dialog "You must select one or more tracks first." buttons {"Cancel"} default button 1 with icon 1
    end if
    set trackList to selection
    set lastartist to ""
    set lastgenre to ""
    set lastcomment to ""
    repeat with i from 1 to count of trackList
    set thisTrack to item i of trackList
    set theartist to artist of thisTrack

    set genre of thisTrack to ""
    set comment of thisTrack to ""
    set thiscomment to ""


    if theartist = lastartist then
    set genre of thisTrack to lastgenre
    set comment of thisTrack to lastcomment
    else
    set theurl to "http://ws.audioscrobbler.com/1.0/artist/"; & my encode_text(theartist) & "/toptags.xml"

    set tags to {}

    set thexml to do shell script "curl " & theurl
    if thexml does not start with "No artist exists with this name:" then


    tell application "System Events"
    delete every XML data
    set this_data to make new XML data with properties {name:"toptags", text:thexml}
    tell this_data
    every XML element of XML element 1
    repeat with x in every XML element of XML element 1
    set thetag to value of XML element "name" of x
    set thestrength to value of XML element "count" of x

    if thestrength ≥ 50 then

    set the end of tags to thetag
    end if
    end repeat
    end tell
    delete every XML data
    end tell
    if tags ≠ {} then
    set genre of thisTrack to item 1 of tags
    repeat with i from 1 to count of tags
    set thiscomment to thiscomment & "'" & item i of tags & "' "
    end repeat
    set comment of thisTrack to thiscomment
    end if
    delay 1
    end if
    set lastartist to theartist
    set lastgenre to genre of thisTrack
    set lastcomment to thiscomment

    end if
    end repeat

    end tell


    -- this sub-routine is used to encode text
    on encode_text(this_text)
    set the unacceptable_characters to " &+%'/\"\\"
    set the encoded_text to ""
    set the character_list to {}
    repeat with this_char in this_text
    set this_char to the contents of this_char
    if this_char is not in the unacceptable_characters then
    set the end of the character_list to this_char
    else
    set the end of the character_list to encode_char(this_char)
    end if
    end repeat
    return (the character_list) as string
    end encode_text

    -- this sub-routine is used to encode a character
    on encode_char(this_char)
    set the ASCII_num to (the ASCII number this_char)
    set the hex_list to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
    set x to item ((ASCII_num div 16) + 1) of the hex_list
    set y to item ((ASCII_num mod 16) + 1) of the hex_list
    return ("%" & x & y) as string
    end encode_char

    tspoon
  • Nice Script!

    I'm actually trying to do the opposite (have my tags go over to last.fm), and stumbled upon this script. Probably not gonna use it, but just wanted to give a high-five to a fellow scripter/music-lover

  • bugfix...

    Just a note for those looking to use this, you may want to change the line:

    set thestrength to value of XML element "count" of x

    to

    set thestrength to value of XML element "count" of x as integer

    Otherwise, the comparisons won't work quite as you expect, and you'll get such interesting genre settings as "indie rock" for Zero 7.

    • arsenty said...
    • User
    • 1 Oct 2008, 13:45
    t-spoon, thanks!

  • there's a error in the script, just change the line
    set theurl to "http://ws.audioscrobbler.com/1.0/artist/";; & my
    to
    set theurl to "http://ws.audioscrobbler.com/1.0/artist/"; & my

    and then it works,
    t-spoon, thanks for the script, it's very useful

  • i mean
    change
    set theurl to "http://ws.audioscrobbler.com/1.0/artist/";; & my
    to
    set theurl to "http://ws.audioscrobbler.com/1.0/artist/"; & my

  • brillant
    i was thinking of doeing something similar but now that i use your script...
    really good work!

    • freeper said...
    • User
    • 29 Nov 2008, 21:46

    Nice Work

    Nautisch, I think we were on the same brain wave at the same time. Good work t-spoon. I was ready to do start doing this on my own. I might modify it a bit. I'll post changes if I make any.

  • track based?

    hey there
    i found out that tagging each track similarly based on just the artist often times makes not much sense (at least not in my mind), e.g. i dont want "nighttrain" to have the same tags as "november rain" (both by GnR)

    so i tried to modify the script to actually use the indivual track tags like for example http://ws.audioscrobbler.com/2.0/?method=track.gettoptags&artist=guns+n+roses&track=november+rain&api_key=b25b959554ed76058ac220b7b2e0a026

    the xml file generated almost looks the same, just the whole thing is in an extra <lfm status="ok"> tag. so far i haven't found out how i can actually use the tags within this xml file.

    any hints on how to do that?

    just in case u dont know the files generated, 2 examples
    1.) artist toptags used by this script here http://ws.audioscrobbler.com/2.0/artist/guns+n+roses/toptags.xml
    2.) indivudual track tags http://ws.audioscrobbler.com/2.0/?method=track.gettoptags&artist=guns+n+roses&track=november+rain&api_key=b25b959554ed76058ac220b7b2e0a026


    thankx in advance...

    • freeper said...
    • User
    • 24 Dec 2008, 05:56

    uses old api calls

    This script uses last.fm's old api I think. And the old api doesn't have a provision for toptags for tracks. Thus the xml is different and the applescript will need some work. I have fixed the code so that it doesn't overwrite the old comments.

    Time to learn some xml

    • freeper said...
    • User
    • 26 Dec 2008, 19:18

    Got it working

    It finally works. Had to wrestle the code a bit. It writes to the groupings field now. Check out more details here. Happy belated Christmas.

    http://stevemoser.wordpress.com/2008/12/26/lastfm-folksonomy-itunes-applescript/

    Let me know if you run into any bugs. I haven't had much time to test it.

    • freeper said...
    • User
    • 29 Dec 2008, 11:25

    sorry for the sloppy post

    I used code html tags insead of pre. Try it now.

  • PLZ HELP

    hey so i love script, t-spoon! (and i am sure yours works awesome too freeper but the way i listen to music its better for me to group by artist not song)

    I do hav a little problem though.... When i run the script some bands only get like one tag so i would like to change the sensitivity so they will get more tags. Can somone tell me how to do that?

    Also i would like to know how it picks which tags. is it by sheer number of tags? or is it the number of tags in comparison to the number of total tags? cause i listen to some kinda unkown bands so i was wondering if they would get fewer tags in their comment box than a really popular band

    THX!

    I have my own particular sorrows, loves, delights; and you have yours. But sorrow, gladness, yearning, hope, love, belong to all of us, in all times and in all places. Music is the only means whereby we feel these emotions in their universality. ~H.A. Overstreet
  • hm. same here. (use it track based)

    bands like e.g. U2 get tags until the group/comment field is just full, others get very few. that alone is not too much of a problem,

    but the following really sux, actually two things:
    (1)
    with popular bands there is always at least one weirdo who sets e.g. a tag "ballad" for a song that definitely (at least to some extent.. guess if you listen to speedmetal all day than everything else is a ballad....?!) is not a ballad. so theres then TONS of tags, and maybe "ballad" appears only once in the back of the list which is maybe topped by "metal" etc. so my itunes playlist "ballads" then also includes that one track...

    any way to somehow do something like
    - count how often the tags are given to a track
    - use top 3 (e.g.) as a maximum
    - only write tags to group field that at least are given top * 0,3 times

    (i.e. not use a fixed limit oftags, but a relative one!??)



    (2)
    in a track containing ' e.g. janie's got a gun, the script stops with an error. either the ' has to be processed/cut before running or thescript should just continue with the next track.... ideas?



    requested that before, i know, any news on that?

  • screw it, just hacked (1) together...

    so what it does is the following:
    - run through all tags retrieved from gettoptags first without writing any tags to files, thereby obtain maximum
    - run through all tags again (might not be too ressource saving but screw it),
    compare each tag with the maximum, only set tag if tag > maximum/X

    therefore by chaning X you can set the limit...

    so far it works quite well for me... thankx again to t-spoon and the rest...

    a , forgot the most important part:the code:


    use this code
    -------
    -- get maximum tag count (nautisch, feb 2k9)
    set max to 0 as integer

    repeat with x in every XML element of XML element 1

    set thestrength to value of XML element "count" of x

    if thestrength as integer > max then
    set max to thestrength as integer
    end if

    end repeat
    -- END get maximum tag count

    -- set actual tag ,old script
    repeat with x in every XML element of XML element 1
    set thetag to value of XML element "name" of x
    set thestrength to value of XML element "count" of x

    --change strength to your taste
    if thestrength as integer ≥ max / 3 as integer then -- change to fit your needs, works well with 2..5 (i think..)

    set the end of tags to thetag
    end if
    end repeat
    -- END set actual tag ,old script
    ---- instead of the "old"

    code repeat with x in every... until
    end repeat


    got questions? mailme. seemann (aet] mytum (pt} de

  • so i somehow got hooked on the idea of actually tuning the script even more, i.e. i am currently trying to define some useful rules for which tags should be applied to a file and which not.

    so far i have basically a threeway approach
    - use a white/blacklist to specify some tags that have/must not be added. (such as "seen live" on the blacklist)
    - reduce tags to synonyms, e.g. "favs", "favourites", "my favourites" all will be written as "favourites"
    - calculate the count of a tag in relation to the max count
    - use an absolute value as a minimum (as in the original by t-spoon)
    - make sure the tag is not already written to the file

    if anyone has any suggestions, let me know. I did some experimenting using excel to show how tag counts are distributed over tags for some example songs, not too easy....

    btw, jacob, the original script uses a "hardcoded" limit of 50 set in thestrength > 50, that u can adjust. However, due to the difference in known/unknown bands such a limit did not work too well for me.

    • freeper said...
    • User
    • 22 Feb 2009, 16:54
    nautisch,
    you have some great ideas on improving this script. Basically what you are running into is all the problems of folksonomy. If I had more time I would definitely take the script in the direction you are going. If you want another 'rule' to sort the tags you could look at the ratio of the number of people who use the tag to the number of times the tag was applied. I was playing with that before and there seems to be a good correlation there for finding 'bad' tags (Used lots of times by few people). Though I'm not sure if there is an api call to get those numbers.

    Anyways, I don't really like how this script works. Since it changes the ID3 tag Time Machine thinks its a 'new' file and it overwrites the old file completely which isn't necessary. So as to keep Time Machine from backing up my whole music library each time I update the tags I propose the script should sort tags by playlists. This way Time Machine only has to update the small file that contains the information about the playlists. This also keeps with Apple's philosophy of dividing information into a bunch of small files instead of one big file (look at the way Microsoft stores email to see a violation of this).

    Just some ideas. There are a ton of ways to improve this script. Good luck guys.

  • hi,

    your idea about a new rule is quite good, I'll work on that.

    I do not really understand what u mean by "the script should sort tags by playlists"; in order not to let TMachine backup a file the file itself must not be altered, right? which leaves me with chaning itunes playlists themselves? soudns tricky...
    btw, the way i intend to use the script is to run it once for a file, so there wont be any problems concerning TMachine - why would i run the script more than once (ok, maybe for a brand new album that is)

    another thing that really bothers me is the fact that somehow the xml files seem to be f**** upsomehow. described that here http://www.last.fm/forum/21716/_/507074
    they are not sorted by count (i figured the one with the highes count should be first with descending counts...) and why "metal"'s (actually a tag that makes sense a lots in gerenal) of foxy lady is almost 700K and therefore more (!) than classic rock - we're talking about Jimi Hendrix people....

    btw if you happen to still have the code that dealt with that correlation thing to find "bad" tags, mail me ;-)

  • nevermind the last post, that seems to be a common problem, anyway

    i added:
    valid_tags (thanx dajenz for the idea), i.e. out of the trillions of tags used i only potentially (i.e. if they match the other criteria) use the top 250 ones (retrieved with the tags. gettoptags api)
    therefore you don't have to worry about "tags" like "gay" for example.

    tested the whole thing today walking around all day with the ipod... seems to work more or less...

  • Can I ask for some exact instructions on using this, a step by step guide as to what to exactly do please?

  • are u referring to t-spoons original or my updated version?

    either way, you basically only have to download the code, open the apple script editor (only works on mac os, that u should know), paste the code, start itunes, select one or more tracks and run the script...

  • I've done that, copied everything from ----- get maximum down to

    end repeat

    Pasted into the applescript editor, highlighted some tracks in itunes, clicked the Run button and I get an error straight away "Syntax Error, Expected class name but found identifer". I click OK and the first instance of XML is highlighted as per this:

    http://www.ocukroguesgallery.com/feek/temp/error-20090225-181921.png

    Thanks.

  • so you just copied my code directly into the sript editor? doesnt workthatway, u haveto replace the code of t-spoons code. or... better idea, i just post the entire code here...
    -------------
    (*
    --further tuned by nautisch feb 2009
    --seemann (aet] mytum |point) de

    --orginial script authored by Last.fm user T-spoon
    --modified by Stephen Moser
    contact@stevemoser.org

    --way or selecting tags for track:
    --uses absolute + relative count as limit
    --supports black/whitelist for spefific tags not affected by other criteria
    --uses valid_tags (i.e. top250 tags used on last.fm)


    --further ideas
    -- define limit indivitually for different tags?
    -- also read if among top artists tracks via http://ws.audioscrobbler.com/2.0/?method=artist.gettoptracks&artist=metallica&api_key=b25b959554ed76058ac220b7b2e0a026


    v1.0 Dec 26 '08
    -- initial release

    http://www.stevemoser.wordpress.com

    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    Get a copy of the GNU General Public License by writing to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

    or visit http://www.gnu.org/copyleft/gpl.html
    *)




    -- configuration
    set minimum_absolute to 10000
    set minimum_relative to 0.05


    -- tags that no matter what will make it to the comments
    set whitelist to {"spanish", "german", "english", "french", "ballad", "eurodance"} -- languages important to me just to know no matter how seldom counted


    -- the only tags uesd at all (just all top 250 tags used on last.fm)
    -- limit by either deleting tags u dont think are valid or (better) list them in the blacklist
    set valid_tags to {"rock", "seen live", "alternative", "indie", "electronic", "pop", "metal", "female vocalists", "alternative rock", "classic rock", "punk", "jazz", "indie rock", "electronica", "folk", "singer-songwriter", "ambient", "hard rock", "hip-hop", "experimental", "dance", "80s", "black metal", "hardcore", "death metal", "progressive rock", "heavy metal", "chillout", "industrial", "punk rock", "instrumental", "british", "soundtrack", "emo", "soul", "favorites", "blues", "classical", "rap", "90s", "thrash metal", "japanese", "metalcore", "trance", "country", "progressive metal", "power metal", "reggae", "acoustic", "hip hop", "melodic death metal", "indie pop", "psychedelic", "trip-hop", "post-rock", "new wave", "funk", "electro", "techno", "house", "german", "britpop", "love", "gothic metal", "albums i own", "grunge", "ska", "rnb", "american", "00s", "beautiful", "gothic", "post-punk", "downtempo", "70s", "mellow", "screamo", "piano", "chill", "60s", "doom metal", "j-rock", "french", "awesome", "guitar", "idm", "finnish", "swedish", "symphonic metal", "favourites", "nu metal", "male vocalists", "oldies", "progressive", "female vocalist", "grindcore", "j-pop", "folk metal", "canadian", "lounge", "ebm", "polish", "world", "synthpop", "drum and bass", "favorite", "female", "post-hardcore", "pop punk", "cover", "pop rock", "darkwave", "minimal", "latin", "new age", "noise", "industrial metal", "dark ambient", "russian", "anime", "brutal death metal", "favourite", "avant-garde", "sexy", "gothic rock", "dub", "alternative metal", "psychedelic rock", "celtic", "jpop", "cool", "disco", "easy listening", "classic", "christian", "fun", "sad", "comedy", "shoegaze", "psytrance", "stoner rock", "folk rock", "melancholy", "favorite songs", "atmospheric", "viking metal", "uk", "blues rock", "visual kei", "goth", "alt-country", "christmas", "covers", "female fronted metal", "amazing", "irish", "deutsch", "relax", "lo-fi", "romantic", "fusion", "relaxing", "happy", "dark", "acid jazz", "live", "spanish", "garage rock", "good", "rockabilly", "deathcore", "norwegian", "emocore", "melancholic", "hardcore punk", "ethereal", "americana", "jrock", "hiphop", "glam rock", "synth pop", "favourite songs", "male vocalist", "ballad", "political", "swing", "italian", "australian", "melodic metal", "post rock", "party", "female vocals", "rock n roll", "soft rock", "brazilian", "vocal", "technical death metal", "sludge", "nu-metal", "remix", "epic", "club", "trip hop", "usa", "funky", "speed metal", "electroclash", "baroque", "industrial rock", "neofolk", "contemporary classical", "thrash", "progressive trance", "summer", "rhythm and blues", "rock and roll", "drum n bass", "psychobilly", "dancehall", "electropop", "bossa nova", "dnb", "art rock", "loved", "catchy", "guitar virtuoso", "singer songwriter", "dark electro", "breakbeat", "favorite albums", "ska punk", "video game music", "drone", "rapcore", "dreamy", "world music", "brasil", "favorite artists", "english", "medieval", "southern rock", "folk-rock", "symphonic black metal", "melodic black metal", "melodic", "christian rock", "avantgarde", "pagan metal", "sweet", "russian rock"}

    -- senseless i.e.meaningless tags filtered out. ("rock" especially is useless, anything is rock accoding to last.fm...)
    set blacklist to {"rock", "sexy", "crap", "seen live", "drums", "beats", "guitar", "gitarre", "life", "USA", "nice", "great", "cool", "good", "love it", "gut", "beautiful", "shit", "heard on pandora", "gay", "general", "albums i own"}


    -- set synonyms to get rid of multiple tags that basically state the same
    -- blocks of synonyms within {}{}{} such as {{block1}{block2}{block3}}
    -- if a tag should appear in eg block2 then it will be REPLACED BY THE FIRST tag in block2
    --example: "spain" will be replaced by "spanish"
    --feel free to add more blocks of synonyms
    set synonymes to {{"german", "deutsch", "germany"}, {"spanish", "spain", "spanisch", "castellano", "espanol", "latin", "latino", "spanish rock"}, {"upbeat", "uplift", "uplifting", "happy", "fun"}, {"chillout", "chilling", "chill", "relax", "relaxing", "soft", "soft rock", "mellow", "slow", "smooth", "calm", "easy listening", "lounge"}, {"favourite", "favourites", "favorite", "favorites", "favourites", "favourite songs", "my favourites", "all time favourites", "favs", "awesome", "excellent", "fucking awesome", "amazing", "favourite bands", "personal favourites", "favourite songs", "favorite songs", "loved", "Faves"}, {"hip-hop", "hip hop"}, {"comedy", "funny", "fun"}, {"electronic", "electronica"}, {"female vocalist", "female vocalists"}, {"romantic", "love"}, {"rock ballad", "rock ballads"}, {"pop-rock", "pop rock"}, {"alternative rock", "alt rock"}, {"nu-metal", "nu metal"}, {"drum and bass", "drum n bass", "dnb"}, {"singer-songwriter", "singer songwriter"}, {"melancholic", "melancholy"}, {"alternative", "alternative rock"}}



    tell application "iTunes"
    if selection = {} then
    display dialog "You must select one or more tracks first." buttons {"Cancel"} default button 1 with icon 1
    end if
    set trackList to selection
    set lastartist to ""
    set lastgenre to ""
    set lastcomment to ""

    repeat with i from 1 to count of trackList

    set thisTrack to item i of trackList
    set theartist to artist of thisTrack
    set thename to name of thisTrack
    set thegroup to grouping of thisTrack

    set thiscomment to ""

    set theurl to "-d api_key=b25b959554ed76058ac220b7b2e0a026 -d method=track.gettoptags -d artist=" & my encode_text(theartist) & " -d track=" & my encode_text(thename) & " http://ws.audioscrobbler.com/2.0/";

    set tags to {}

    set thexml to do shell script "curl " & theurl

    if thexml does not start with "failed" then

    tell application "System Events"
    delete every XML data

    set this_data to make new XML data with properties {name:"lfm", text:thexml}
    --tell thexml to set level_1 to XML element 1
    --tell thexml to set level_2 to XML element 1 of level_1
    tell XML element of this_data
    every XML element of XML element 1

    -- get maximum tag count (nautisch, feb 2k9)
    set max to 0 as integer -- maximum nr any tag is counted
    set tagcloud to "" -- later written to comment/group field
    set nr_tags_lastfm to 0 -- count number of tags lastfm knows
    set nr_tags_ok to 0 -- count nr of tags that passed the selection to be written to the file
    set max_tag to ""
    set sum_all_tags to 0
    set sum_valid_tags to 0

    repeat with x in every XML element of XML element 1
    set thetag to value of XML element "name" of x
    set thestrength to value of XML element "count" of x

    if (thestrength as integer > max and thetag is not "rock") then -- everything is rock so NOT USE rock as a maximum
    set max to thestrength as integer
    set max_tag to thetag
    end if

    set nr_tags_lastfm to nr_tags_lastfm + 1

    end repeat
    -- END get maximum tag count

    --return max_tag
    --return max
    --return nr_tags_lastfm

    -- set actual tag ,old script
    repeat with x in every XML element of XML element 1
    set thetag to value of XML element "name" of x
    set thestrength to value of XML element "count" of x


    -- get rid of redundant tags, ie replace these with first in BLOCK (see above)
    repeat with i from 1 to count of synonymes -- for allblocks of synonyms
    set block to item i of synonymes -- one block of synonyms
    repeat with j from 1 to count of block
    --return block
    if block contains thetag then
    set thetag to item 1 of block
    end if
    end repeat -- all elements of this block
    end repeat -- all blocks

    set sum_all_tags to sum_all_tags + thestrength

    --return thestrength
    --2do: add < > in tagcloud containts thetag ; rock != altenative rock !!!

    if thetag = "rock" then --huge influence of "rock"!
    set sum_valid_tags to sum_valid_tags + thestrength
    end if

    if ((valid_tags contains thetag and thestrength as integer ≥ max * minimum_relative as integer and thestrength as integer > minimum_absolute and blacklist does not contain thetag and tagcloud does not contain "‹" & thetag & "›") or (whitelist contains thetag)) then

    set sum_valid_tags to sum_valid_tags + thestrength

    set the end of tags to thetag

    set tagcloud to tagcloud & "‹" & thetag & "›"
    --to debug use this line
    --set tagcloud to tagcloud & thetag & "," & thestrength & ";
    --"
    set nr_tags_ok to nr_tags_ok + 1

    end if
    end repeat
    -- END set actual tag ,old script

    --return nr_tags_ok
    --return tagcloud

    end tell
    delete every XML data
    end tell

    --return sum_valid_tags / sum_all_tags

    -- write tags to grouping field of mp3
    if tags ≠ {} then
    set genre of thisTrack to item 1 of tags -- set genre to tag with highest count
    set grouping of thisTrack to (tagcloud)
    end if

    delay 1 --wait one second
    end if
    --set lastartist to theartist
    --set lastgenre to genre of thisTrack
    --set lastcomment to thiscomment

    end repeat -- whole tracklist



    end tell

    -- this sub-routine is used to encode text
    on encode_text(this_text)
    set the unacceptable_characters to " &+%'/\"\\()'"
    set the encoded_text to ""
    set the character_list to {}
    repeat with this_char in this_text
    set this_char to the contents of this_char
    if this_char is not in the unacceptable_characters then
    set the end of the character_list to this_char
    else
    set the end of the character_list to encode_char(this_char)
    end if
    end repeat
    return (the character_list) as string
    end encode_text

    -- this sub-routine is used to encode a character
    on encode_char(this_char)
    set the ASCII_num to (the ASCII number this_char)
    set the hex_list to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
    set x to item ((ASCII_num div 16) + 1) of the hex_list
    set y to item ((ASCII_num mod 16) + 1) of the hex_list
    return ("%" & x & y) as string
    end encode_char

    -------------
    hopy that works with all the "' etc.
    as you can see it's still in some sort of dev. state, but it should work ...

  • Ooo, thanks for that - Not sure it posted correctly as I get an error when I run it though so is it possible you can upload it somewhere so that it all paginates correctly?

    I'm hoping it will do exactly what I'm after.

  • ok, here you go. i upped it to my webspace
    http://www.michaelseemann.com/projects/folksonomy/folksonomy_01.zip

    check it out.
    you might want to replace the api_key with your own one, but for testing purposes u can use the one given

    btw, tell iTunes to show the grouping field to see what the script is doing, then define intelligeny playlists and set the Group fielt do whatever tags u like.

    attention:
    the script will DELETE everything that might be written into the grouping tag of your files!

    you can change grouping to comments though if you prefer...
    shoot me feedback

Anonymous users may not post messages. Please log in or create an account to post in the forums.