Become a member of the iLounge Forums. Register Now!
To start viewing messages, select the forum that you want to visit from the selection below.
If this is your first visit, be sure to check out the Forum FAQ and Forum Policy.

Topic: Trying to search all tracks based on properties

Reply Thread Tools Topic Search
 
Old 09-26-2009, 01:37 PM
#1
 
Freshman Lounger
 
Join Date: Sep 2009
Location: Washington DC
Posts: 7
Cool Trying to search all tracks based on properties

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 is offline  
Reply With Quote

Join the iLounge Community and the ad above will disappear.

Old 09-26-2009, 01:43 PM
#2
 
Veteran Lounger
 
Code Monkey's Avatar
 
Join Date: Jun 2004
Location: Midstate New York
Posts: 5,213

It's called a smartlist.
Code Monkey is offline  
Reply With Quote
Old 09-26-2009, 02:05 PM
#3
 
Freshman Lounger
 
Join Date: Sep 2009
Location: Washington DC
Posts: 7

Quote:
Originally Posted by Code Monkey View Post
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?
joelbradshaw is offline  
Reply With Quote
Old 09-26-2009, 02:13 PM
#4
 
Veteran Lounger
 
Code Monkey's Avatar
 
Join Date: Jun 2004
Location: Midstate New York
Posts: 5,213

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.
Code Monkey is offline  
Reply With Quote
Old 09-26-2009, 08:02 PM
#5
 
Freshman Lounger
 
Join Date: Sep 2009
Location: Washington DC
Posts: 7
Red face

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 is offline  
Reply With Quote
Old 09-26-2009, 08:40 PM
#6
 
Freshman Lounger
 
Join Date: Sep 2009
Location: Washington DC
Posts: 7

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
joelbradshaw is offline  
Reply With Quote
Old 09-26-2009, 10:27 PM
#7
 
Veteran Lounger
 
Code Monkey's Avatar
 
Join Date: Jun 2004
Location: Midstate New York
Posts: 5,213

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.
Code Monkey is offline  
Reply With Quote
Old 09-26-2009, 11:01 PM
#8
 
Freshman Lounger
 
Join Date: Sep 2009
Location: Washington DC
Posts: 7


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
joelbradshaw is offline  
Reply With Quote
Old 09-27-2009, 11:38 AM
#9
 
Veteran Lounger
 
Code Monkey's Avatar
 
Join Date: Jun 2004
Location: Midstate New York
Posts: 5,213

Quote:
Originally Posted by joelbradshaw View Post
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.
Code Monkey is offline  
Reply With Quote

Topic: Trying to search all tracks based on properties

Reply Thread Tools Topic Search

Become a member of the iLounge Forums. Register Now!
To start viewing messages, select the forum that you want to visit from the selection below.
If this is your first visit, be sure to check out the Forum FAQ and Forum Policy.
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MP3 Audiobooks, tracks, and bookmarking? Pilaar39 Books and Spoken Word 11 05-12-2009 04:23 PM
autodelete tracks script ? nimionsergei AppleScripts for iTunes (Mac) 0 10-14-2008 04:23 PM
select tracks based on length? lowaffect AppleScripts for iTunes (Mac) 1 09-15-2008 12:27 AM
Autosync randomly removes tracks smoyerjx iPod classic & Legacy iPods 2 07-10-2005 01:32 PM
Auto sync removes tracks in error smoyerjx iTunes + Related Mac/PC Applications 0 06-15-2005 02:07 PM




View iLounge History. Read our old Forums Archive (2001-2003)
All times are GMT -4. The time now is 10:56 AM.


Shop for Accessories: Cases, speakers, chargers, etc.