Accessing iTunes DB through Applescript?
I know this may/may not be game-related, but iDG has a larger community than iDA, and it's not inconceivable that someone might use this code in a game.
What I want to do is use Applescript to get a list of playlists from iTunes. I don't want to read the xml version of the library - I want a realtime list of playlists (as far as I understand it the xml is only revised on quit - I'd like changes made in iTunes to show up in my application).
Thing is, and I've googled this a ton, I can't for the life of me figure out how on earth to do this. I've pored over the applescript dictionary, looking at open source code - I just don't get it. This seems like a fairly simple thing to do - can someone give me a hand here? Thanks in advance.
What I want to do is use Applescript to get a list of playlists from iTunes. I don't want to read the xml version of the library - I want a realtime list of playlists (as far as I understand it the xml is only revised on quit - I'd like changes made in iTunes to show up in my application).
Thing is, and I've googled this a ton, I can't for the life of me figure out how on earth to do this. I've pored over the applescript dictionary, looking at open source code - I just don't get it. This seems like a fairly simple thing to do - can someone give me a hand here? Thanks in advance.
This is pretty basic and may be a little buggy. Plus my Script Editor app won't seem to run right now so I can't just copy and paste. Hopefully it works though
.
I'm sorry if there's an error, but I had a similar script running moments ago before my computer froze. Now it refuses to open that script. I'm assuming the file got corrupted because I can open and run other scripts. I'm also not the über-scripter, so you may want to double check to make sure you won't be getting errors with it.
.Code:
set song_counter to 1
tell application "iTunes"
repeat while(song_counter <= (number of tracks of library playlist 1))
set song_name to name of (track song_counter of library playlist 1)
-- then repeat for other information and do what you will with it
end tell
end tellI'm sorry if there's an error, but I had a similar script running moments ago before my computer froze. Now it refuses to open that script. I'm assuming the file got corrupted because I can open and run other scripts. I'm also not the über-scripter, so you may want to double check to make sure you won't be getting errors with it.
Great - this is a good start. As far as I understand it this code iterates through each track of the users library.
Now how would I tackle this for playlists?
Now how would I tackle this for playlists?
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Creating a window and accessing OpenGl using C++ | RagingAvatar | 5 | 3,875 |
Nov 5, 2009 10:37 AM Last Post: OneSadCookie |
|
| Accessing c++ class from Obj-C .h file | dsedov | 3 | 3,441 |
Jul 1, 2009 11:07 PM Last Post: dsedov |
|
| iTunes 8 Visualizer | Talyn | 3 | 2,263 |
Oct 7, 2008 09:50 PM Last Post: maximile |
|
| Applescript/shellscript | Byron Clarke | 3 | 2,557 |
Jul 26, 2005 02:16 AM Last Post: Andrew |
|

