Why does this code result in an empty playlist, and how can I get that track into the playlist?
#!/usr/local/bin/macruby
framework 'Cocoa'
framework 'ScriptingBridge'
load_bridge_support_file 'iTunes.bridgesupport'
iTunes = SBApplication.applicationWithBundleIdentifier 'com.apple.iTunes'
userPlaylists = iTunes.sources.objectWithName("Library").userPlaylists
userPlaylists << (ITunesUserPlaylist.alloc.initWithProperties Hash[{"name"=>"something unique"}])
playlist = userPlaylists.objectWithName("something unique")
iTunes.add [userPlaylists.objectWithName("Music").tracks[0]], to:playlist
(if you know a way to avoid needing to insert the playlist before using it, that'd be helpful too.)