July 13th, 2010

More iTunes Remote Fun

Filed under: daily,geek,mac — saul @ 8:13 AM

Search your remote Library and create a playlist based on your search - and of course play your playlist, knowledge gleaned from Doug and Rory

-- you'll want to set this line to reflect your remote machine info
set remoteMachine to "eppc://username:password@machinename.local"
set keyword to "Gogol Bordello"
display dialog "Search:" default answer keyword
set vol to text returned of the result
using terms from application "iTunes"
	tell application "iTunes" of machine remoteMachine
		set my_search_results to (search library playlist 1 for keyword)
		if my_search_results is not {} then
			set myList to make new playlist with properties {name:keyword}
			set sel to a reference to my_search_results
			repeat with aTrack in sel
				set thisTrack to (get location of aTrack)
				set dbid to (get database ID of aTrack)
				add thisTrack to myList
			end repeat
			set currentList to playlist keyword
			play the playlist named keyword
			reveal current track
		end if
	end tell
end using terms from

Two obvious TODO’s in my code - it doesn’t do muchANY error checking so although iTunes does seemed to care if you have multiple playlists sharing a name (meaning it doesn’t overwrite them) THAT might not be what you’re intention. I’ll probably be fixing that at a later date. Lastly it doesn’t offer any feedback - which I suppose is fine, but not very me so I’ll probably add some GROWL notification in regards to if the playlist was created and how many tracks were added.

Again really just scratching the surface here, and Doug & Rory did all the heavy lifting on this one.

No Comments »

No comments yet.

Leave a comment

Comments will be sent to the moderation queue.