PDA

View Full Version : Scriptable Search Field in itunes.


sorahn
08-05-2008, 05:53 AM
Hey guys, what i'm looking for is the ability to script the search field in itunes. Basically i'm looking for the functionality of "flipping the arrow" so that if a song is playing, you would run the script and it would enter the current album into the search field so you could just have itunes continue playing, but only that album, and have a similar script for artist.

I know that's what the arrow does if you option click (or get the script to flip the action) but i find the search field easier to use than the media browser that shows genre's and albums and that crap.

S2_Mac
08-06-2008, 12:59 PM
Hmm...what is this "option-click" you mention?

To do this, you'd have to go through "GUI scripting" and have a script enter the characters into the Search field and then press Enter key. Google for info on gui scripting.

This isn't what you what, but it only took a couple minutes to cook up ;-) When activated, this script finds all tracks by the currently playing artist, and adds them to a playlist named "Artist Now Playing". If the playlist doesn't exist, it is created; the playlist is emptied before receiving an artist's tracks. The view then switches to that playlist.
-- script: "all current artist tracks to playlist", 2008
tell application "iTunes"
set music_playlist to some playlist whose special kind is Music
if player state is stopped then
display dialog "Play something!"
return
end if

set cur_artist to artist of current track
set pla_name to "Artist Now Playing"
if not (exists user playlist pla_name) then make new user playlist with properties {name:pla_name}
set dest_playlist to playlist pla_name

set search_res to search music_playlist for cur_artist only artists
if search_res is not {} then
delete every track of dest_playlist
repeat with trak in search_res
duplicate trak to dest_playlist
end repeat
set view of front browser window to dest_playlist
end if
end tell

sorahn
08-07-2008, 04:37 PM
Turn on the "show arrows linking to media store" in the preferences, then option click one of them and watch what happens.

If you like the result, there's a script that can make it so that's the default action, instead of the option-click action.