okay 'Scripter Hepcats.
the current iteration by grace of AppleScript and Mssr. Koenig…
This script combines a smart playlist (in order) and the interstitials playlist (randomly selected) to make a perfectly shuffled playlist all ready to go.
However, THAT is where it stops.
The command play playlist results in a “parameter error.” (Also, there are a couple notes imbedded in the script, re: failures in “use of playlistMerged”…)
progress is good, but the speed bumps are infuriating.
More tomorrow.
--Get Current Calendar Event via iCalBuddy hasseg.org/icalBuddy
set PlaylistTVShow to {first item of my text_to_list((do shell script "/usr/local/bin/icalbuddy -eed -nc -b \"\" eventsNow"), return) as text}
tell application "iTunes"
--Shuffle based on "CK's Evenly-shuffled Playlists v0.6" by Charles Kelly http://www.manythings.org/mac/
set playlistMerged to "Now Playing"
set PlaylistInterstitials to "[ID-D]" -- Intersitials for the [D]aytime broadcast
set PlaylistTVShow to PlaylistTVShow as text
set playlistUpNext to "[some filler playlist TBD]"
if (playlist playlistMerged) is {} then
set playlistMerged to make new user playlist with properties {name:playlistMerged} -- if no playlist, make it
else
set playlistMerged to playlistMerged as text
set playlistMerged to user playlist playlistMerged -- if playlist, clean it out
repeat
set tr to get tracks of playlist "Now Playing" -- use of playlistMerged got "descriptor type mismatch"
if tr is {} then exit repeat
repeat with t in tr
delete t
end repeat
end repeat
end if
set x to count of tracks of playlist PlaylistTVShow -- length based on requested TV Show
set MergedTracks to {}
repeat with i from 1 to x
set theTrack to some track of playlist PlaylistInterstitials
set theTrackID to database ID of theTrack
set enabled of (duplicate theTrack to playlistMerged) to true
set MergedTracks to MergedTracks & (theTrackID)
set theTrack to track i of playlist PlaylistTVShow
set theTrackID to database ID of theTrack
set enabled of (duplicate theTrack to playlistMerged) to true
set MergedTracks to MergedTracks & (theTrackID)
end repeat
play playlist "Now Playing" -- use of playlistMerged gets "descriptor type mismatch" / current syntax results in "iTunes got an error: Parameter error." I DON'T KNOW WHAT TO BELIEVE ANYMORE.
set full screen to true
end tell
--wait for playlist to finish
on idle
tell application "iTunes"
try
if player state is not stopped then return 5
on error
return 5
end try
play playlist playlistUpNext
end tell
return 5
end idle
on text_to_list(txt, delim)
set saveD to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to {delim}
set theList to every text item of txt
on error errStr number errNum
set AppleScript's text item delimiters to saveD
error errStr number errNum
end try
set AppleScript's text item delimiters to saveD
return (theList)
end text_to_list
Ӯ