Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

buckuxc

macrumors regular
Original poster
Aug 28, 2003
208
0
hey all,

I'm an Applescript noob, but I have an idea for something to work with iTunes that I really want to try and implement. Before I go ahead with spending the extra time learning Applescript to bring this idea to life, I have some questions about the power and the limits of Applescript, especially in conjunction with iTunes. Is there anyone that wouldn't mind keeping an email conversation with me to help me out? Thanks.


sps
 

Doctor Q

Administrator
Staff member
Sep 19, 2002
39,789
7,525
Los Angeles
Any reason not to use the forums? It might be less personal, but then you benefit from our joint knowledge instead of from just one person. And other AppleScripters like me will benefit by listening in.

For iTunes scripting, I suggest that you start by collecting the iTunes scripts already written by others, especially where source code is provided, so you can see what's possible and what's already been done.
 

buckuxc

macrumors regular
Original poster
Aug 28, 2003
208
0
i tried posting to the forum

....a day or two ago. Acutally, two forums. I posted my idea. No one responded. I have a better idea, formulated from the last one, but this time I'm just gonna do it myself. I need to find out if specific tasks possible with Applescript, though, before I start spending my little free time figuring it out; otherwise, maybe it's possible with Cocoa? If someone can tell me that, that would ok, too. To begin I suppose my first questions are these:

1) Is it possible to have Applescript export playlists? I could not find this function in the dictionary.

2) Is it possible for an Applescript to work with more than one program, say iTunes and Text Editor? Or must you have separate scripts for each?

3) Is it possible with Applescript to compare text within more than one file? For example, I have 5 exported song lists in 5 different XML files. I want to find any XML strings that are exactly the same in 2 or more of these XML files.

or

is it possible in iTunes to export 5 separate playlists to the same XML file? Then with Applescript, search the entire XML file for strings that show up more than once?

That's my questions for now. Read the next post for my reasoning.
 

Doctor Q

Administrator
Staff member
Sep 19, 2002
39,789
7,525
Los Angeles
Re: i tried posting to the forum

Originally posted by buckuxc
....a day or two ago. Acutally, two forums. I posted my idea. No one responded.
Sorry. I didn't see it. It's lousy when nobody responds to a post.
2) Is it possible for an Applescript to work with more than one program, say iTunes and Text Editor? Or must you have separate scripts for each?
Yes. The tell command directs AppleScript actions to particular programs, and you can use as many tell commands as you like.
 

buckuxc

macrumors regular
Original poster
Aug 28, 2003
208
0
Reasoning

If anyone is familiar with the iTunes Top 20 Playlist strategy over at SmartPlaylists.com, then this should make sense. Basically, there are 3 playlists:

Favs - Hot:
Five Stars AND
Last Played is in the last 3 days

Favs - Recyled
Five Stars AND
Last Played is not in the last 1 week
Last Played is in the last 2 weeks

Favs - Forgotten
Five Stars AND
Last Played is not in the last 4 weeks

This is a good strategy for listening to those songs that are stuck in your head at any given point in time. However, you have to constantly evaluate which songs are worth 5 stars and manually set them. This isn't that bad, unless you're like me and are in the process of ripping your entire CD collection to your computer; trust me, you can't listen to THAT much music and stay sane, live your life, etc...

What is needed is a way to determine how many times a song has been played in the last couple of days, then give it 5 stars or not based on this criteria. There is, sadly, no way of keeping track of PlayCount within the last N days. I'm trying to determine a way. I made 5 new playlists (could be a different number if you want) with these criteria:

Last 1 day: Last Played is in the last 1 days

Last 2 days: Last Played is in the last 2 days and Last Played is not in the last 1 days.

Last 3 days: Last Played is in the last 3 days and Last Played is not in the last 2 days.

Last 4 days: Last Played is in the last 4 days and Last Played is not in the last 3 days.

Last 5 days: Last Played is in the last 5 days and Last Played is not in the last 4 days.

If a song has been played on 2 or more days in the last 5 days, then it will appear on more than one of those playlists. If one could compare the results of those 5 playlists, even just once a day at the end of the day, then one could find songs that show up on more than one. If then one could have the rating automatically set to 5 stars on any song that does appear on two or more of those lists, the one could dynamically have their songs tastes recorded.

I would also think about adding a Not Played in N amount of days/weeks/months list, and having the Applescript (or perhaps a Cocoa app or iTunes plugin for either of these ideas???) decrease the rating to 4, then to 3 (after longer), then to 2...etc...

I know this is long, but hopefully a few people with better knowledge can help me and help each other towards a solution...

...at least until Apple adds this sort of feature (along with boolean "or" capabilities in Smartlists).

sps
 

buckuxc

macrumors regular
Original poster
Aug 28, 2003
208
0
maybe iTunes Database FMP v1.8.5

Maybe one could this by fiddling with this Applescript? Then instead of comparing text strings in several XML files, one could compare values in a database.

Only one catch: I don't have Filemaker Pro...and I don't know how many actually do. However, could this be implemented using Apache? Isn't that a database app that is included on every OS X machine?

sps
 

evil_santa

macrumors 6502a
Sep 23, 2003
893
0
London, England
Re: i tried posting to the forum

Im not that good with apple script, ive only writen a few simple script, but i hope this helps..


Originally posted by buckuxc

1) Is it possible to have Applescript export playlists? I could not find this function in the dictionary.


I know you should be able to write to a text edit doc. I think there was a script for this on Dougs site, but ive just looked for it and the server is down


2) Is it possible for an Applescript to work with more than one program, say iTunes and Text Editor? Or must you have separate scripts for each?


Use tell

tell application "iTunes"
...
end tell
tell application "Internet Explorer"
...
end tell



3) Is it possible with Applescript to compare text within more than one file? For example, I have 5 exported song lists in 5 different XML files. I want to find any XML strings that are exactly the same in 2 or more of these XML files.

not sure,


or

is it possible in iTunes to export 5 separate playlists to the same XML file?

dont close the file until your script has exported all 5 lists.
Then with Applescript, search the entire XML file for strings that show up more than once?
not sure about this!

hope this is of some help
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.