Trying to search all tracks based on properties

GO TO ADMIN PANEL > ADD-ONS AND INSTALL VERTIFORO SIDEBAR TO SEE FORUMS AND SIDEBAR

joelbradshaw

New member
Joined
Sep 27, 2009
Messages
7
Points
0
Location
Washington DC
I want to build a script which can search all playlists or specific playlists for tracks which meet any of the properties, or combinations of properties I specify, and which can, once selected, report back on the length of the track to be added to the playlist I'm creating.

I expect several tracks to meet the search criteria, and the ability to randomly select one of the matching tracks is desirable.

I've searched the forum, and haven't found anything which specifically says how to search for tracks based on anything other than the basics.

any help is appreciated for this applescript newbie.

joelb
 

joelbradshaw

New member
Joined
Sep 27, 2009
Messages
7
Points
0
Location
Washington DC
It's called a smartlist.
Um... I'm not *THAT* new. ;)

I need to be able to select a bunch of songs with different criteria for all of them, then combine those into a playlist which is as close to sixty minutes and no seconds as I can.

The problem would be having to create a couple dozen smartlists to find the individual songs.

Complicating the matter is they all need to trigger off Genre, which I need to be able to change.

The upshot is I used to work in radio (back in the day) and I want to create a format to create an hour long playlist. The criteria except Genre or Playlist (for collections which aren't genre specific) are the same, if I could update all the smart lists to change the 'Genre' or playlist they reference might work.

Then I'd have the problem of having to subtotal the songs, and pick the last song by time alone.

So that's the end I'm trying to accomplish. A little more involved than just a smart playlist can handle.

:)

That said, any ideas?
 

Code Monkey

New member
Joined
Jun 24, 2004
Messages
5,213
Points
0
Location
Midstate New York
Uh, it's still called a smartlist.

In fact, you can give all the parameters you want, then say "Limit to 60 minutes selected according to random" at the bottom of the smartlist.

iTunes will do all the heavy lifting for you. And with forked internal logic any more, unless it's necessary to weight the percentages of the final make up, you can even do it in a single playlist no matter how complex the logic.
 

joelbradshaw

New member
Joined
Sep 27, 2009
Messages
7
Points
0
Location
Washington DC
Ok

How about this.
I've got it mostly solved. But I need some code to search a playlist and choose a track based on the duration of the track.

Everything else is solved.

joelb

set ANums to 1
set BNums to 1
set CNums to 1
set DNums to 1
set ONums to 1

tell application "iTunes"
copy track ANums of user playlist "A's" to playlist "Now Playing"
set ANums to ANums + 1
copy track CNums of user playlist "C's" to playlist "Now Playing"
set CNums to CNums + 1
copy track BNums of user playlist "B's" to playlist "Now Playing"
set BNums to BNums + 1
end tell
tell application "iTunes"
if duration of playlist "Now Playing" is less than (15 * minutes) then
copy track ONums of user playlist "Oldies" to playlist "Now Playing"
set ONums to ONums + 1
end if
end tell

tell application "iTunes"
copy track ANums of user playlist "A's" to playlist "Now Playing"
set ANums to ANums + 1
copy track DNums of user playlist "D's" to playlist "Now Playing"
set DNums to DNums + 1
copy track BNums of user playlist "B's" to playlist "Now Playing"
set BNums to BNums + 1
end tell
tell application "iTunes"
if duration of playlist "Now Playing" is less than (30 * minutes) then
copy track ANums of user playlist "A's" to playlist "Now Playing"
set ANums to ANums + 1
end if
end tell

tell application "iTunes"
copy track ANums of user playlist "A's" to playlist "Now Playing"
set ANums to ANums + 1
copy track DNums of user playlist "D's" to playlist "Now Playing"
set DNums to DNums + 1
copy track CNums of user playlist "C's" to playlist "Now Playing"
set CNums to CNums + 1
end tell
tell application "iTunes"
if duration of playlist "Now Playing" is less than (45 * minutes) then
copy track BNums of user playlist "B's" to playlist "Now Playing"
set BNums to BNums + 1
end if
end tell

tell application "iTunes"
copy track ANums of user playlist "A's" to playlist "Now Playing"
set ANums to ANums + 1
copy track BNums of user playlist "B's" to playlist "Now Playing"
set BNums to BNums + 1
copy track ONums of user playlist "Oldies" to playlist "Now Playing"
set ONums to ONums + 1
end tell

tell application "iTunes"
set PrefillTime to duration of playlist "Now Playing"
set TimeToFill to 3600 - PrefillTime
end tell


tell application "iTunes"
-- this is the part that I keep screwing up now.
--I need to search playlist "A Top of Hour" for a track that matches TimeToFill
end tell
 

joelbradshaw

New member
Joined
Sep 27, 2009
Messages
7
Points
0
Location
Washington DC
tell application "iTunes"

-- do some loop through all tracks of playlist
set CurrentDuration to duration of track ATOHCount of playlist "A Top of Hour"
set CurrentDuration to round (CurrentDuration)
if CurrentDuration = TimeToFill then
copy track ATOHCount of user playlist "A Top of Hour" to playlist "Now Playing"
end if
--loop return

end tell
 

Code Monkey

New member
Joined
Jun 24, 2004
Messages
5,213
Points
0
Location
Midstate New York
Hey, I'd like to apologize for the above. I didn't pay attention that you posted this specifically to the scripts forum (I just always grab the daily posts), so even though I don't know why you're doing what you're doing when you could do the same thing with some smartlists as best I can tell and save yourself the trouble, I was out of line.

Good luck figuring out the part of the script you want, Apple Script is not my area of expertise.
 

joelbradshaw

New member
Joined
Sep 27, 2009
Messages
7
Points
0
Location
Washington DC
:)
No sweat.

Most radio stations have a format that they follow. I wanted to emulate that as closely as possible.

The idea is A songs are Hot Popular Current.
B songs are similar, but either on the way down or up, and not deserving of the heavier rotation of an 'A' spot.
C songs are songs that didn't go as high as an A or B, but were good none the less, but are worth bringing up somewhat regularly.
D songs are the honorary mentions of the top charting songs and again are just scattered in for flavor
The Oldies are formerly A's and B's but are at least 10 years old.

Plan to the quarter hour, 4 songs per quarter,with the last of the 4 being 'optional' based on how long the first 3 run.

I want to mimic actual format, so I don't just want to dump the songs which match into a playlist.
This is where music directors make the big bucks. A station's format is usually fairly well guarded.

The format here I'm doing from memory when I worked in Top 40 radio. The station has been country for more than a decade, so I'm not giving away state secrets buy posting my code.

Anyway, that's why I was sooo picky about what I was trying to accomplish
 

Code Monkey

New member
Joined
Jun 24, 2004
Messages
5,213
Points
0
Location
Midstate New York
Anyway, that's why I was sooo picky about what I was trying to accomplish
Hey, as long as you have your reasons and understand why you're doing it, that's what counts. I just sometimes see people attempting the most convoluted ways of doing something there's a much simpler answer for.

For example, once somone came in here looking for feedback on a two page Visual Basic program they had written to automate renaming .m4a files to .m4b extension files.

They were both surprised and chagrined to learn that what they had spent days working on, required specific .net runtimes to be installed, etc. could be accomplished by the 15 characters: "ren *.m4a *.m4b" either from the command prompt or as a 1k batch file.
 
Top