From bseymore at gmail.com Sun Jun 22 02:34:44 2008 From: bseymore at gmail.com (Brooks Seymore) Date: Sat, 21 Jun 2008 23:34:44 -0700 Subject: [Rubyosa-discuss] Setting Values in iTunes? Message-ID: I'm trying to put together a script to automate the filling in the Sort Artist field in iTunes. The code I've written, included below, grabs the Artist name from the selected tracks, performs some minor Ruby mojo to convert the artist name ("Tom Waits") into last name, first name ("Waits, Tom). Where I've run into problems is trying to set the Sort Artist filed in iTunes. I've scoured the Google, but have yet to find a solution to this anywhere on the Internets. Anyone have any thoughts? Regards, Brooks #!/usr/bin/env ruby require 'appscript' include Appscript itunes = app('iTunes') full_name = itunes.selection.artist.get.each do |track| names = track.split lastname = names.pop firstname = names.join(' ') sort_name = lastname + ", " + firstname ## show the artist name p sort_name ## attempt, unsuccessful, at setting the Sort Artist field # track.sort_artist.set("#{lastname}, #{firstname}") end From henrik at nyh.se Sun Jun 22 05:06:04 2008 From: henrik at nyh.se (Henrik Nyh) Date: Sun, 22 Jun 2008 11:06:04 +0200 Subject: [Rubyosa-discuss] photos.every(:image_path) breaks; equivalent of 'album "My Photos"'? Message-ID: Scripting iPhoto. I have two questions. Example script: require "rubygems" require "rbosa" app = OSA.app("iPhoto") album = app.albums.find {|a| a.name == "My Vacation" } # 1 puts album.photos.map {|p| p.image_path } # 2 1. When writing AppleScript, I can do album "My Vacation" for a reference to it. Is there an equivalent in RubyOSA, or is #find the way to do it? 2. Though puts album.photos.map {|p| p.image_path } works, using #every is faster, as I understand it. But while puts album.photos.every(:name) works fine, none of these do: puts album.photos.every(:image_path) puts album.photos.every(:"image_path") puts album.photos.every(:imagepath) I get ArgumentError: desired class `OSA::IPhoto::Photo' does not have a attribute named `image_path' Probably a bug? I'm poking inside the RubyOSA code, and it seems like the rbosa_properties.rb file does not have a mapping for image_path. Not sure what it should map to, but I'll look into it. From henrik at nyh.se Sun Jun 22 05:36:43 2008 From: henrik at nyh.se (Henrik Nyh) Date: Sun, 22 Jun 2008 11:36:43 +0200 Subject: [Rubyosa-discuss] photos.every(:image_path) breaks; equivalent of 'album "My Photos"'? In-Reply-To: References: Message-ID: On Sun, Jun 22, 2008 at 11:06 AM, Henrik Nyh wrote: > Though > puts album.photos.map {|p| p.image_path } > works, using #every is faster, as I understand it. But while > puts album.photos.every(:name) > works fine, none of these do: > puts album.photos.every(:image_path) > puts album.photos.every(:"image_path") > puts album.photos.every(:imagepath) > I get > ArgumentError: desired class `OSA::IPhoto::Photo' does not have a > attribute named `image_path' > > Probably a bug? I'm poking inside the RubyOSA code, and it seems like > the rbosa_properties.rb file does not have a mapping for image_path. > Not sure what it should map to, but I'll look into it. Figured it out. Though they don't have a mapping in that particular file, one is added on the fly. However, there is an issue where parts of the code expects :"image_path" and parts expect :"image path", causing it to always fail. Fix: http://pastie.textmate.org/219809 Also posted on a ticket here: http://rubyforge.org/tracker/index.php?func=detail&aid=10784&group_id=1845&atid=7180 From henrik at nyh.se Sun Jun 22 09:04:40 2008 From: henrik at nyh.se (Henrik Nyh) Date: Sun, 22 Jun 2008 15:04:40 +0200 Subject: [Rubyosa-discuss] =?utf-8?b?J29wZW4gwqtjbGFzcyBpTGliwrsgbmFtZWQg?= =?utf-8?b?IkZvbyInIGluIFJ1Ynk/?= Message-ID: Trying to translate this piece of AppleScript into RubyOSA.Haven't figured it out yet; does anyone know? Other than by using system("osascript...") :p tell application "iPhoto Library Manager" open ?class iLib? named "Foo" end