From maillist at steelskies.com Wed Dec 6 13:20:23 2006 From: maillist at steelskies.com (Jonathan del Strother) Date: Wed, 6 Dec 2006 18:20:23 +0000 Subject: [Rubyosa-discuss] Getting 'seld' of an itunes track... Message-ID: (Disclaimer: I know next-to-nothing about AppleEvents and Applescript, so forgive me if any of this is gibberish) In Applescript Editor, returning an itunes track will show something like the following in the results window : file track id 4369 of user playlist id 1361 of source id 37 of application "iTunes" I need to read that id - 4369 - in rubyosa. Looking at the track in Script Debugger's AEPrint window shows this : 'obj '{ 'form':'ID ', 'want':'cFlT', 'seld':4369, ... } So, I want the 'seld' property. Any suggestions on getting it? Thanks for any help, Jon From jenspetr at gmail.com Wed Dec 6 14:22:47 2006 From: jenspetr at gmail.com (Jens-Petr Mikhailovich) Date: Wed, 6 Dec 2006 11:22:47 -0800 Subject: [Rubyosa-discuss] Getting 'seld' of an itunes track... In-Reply-To: References: Message-ID: On 12/6/06, Jonathan del Strother wrote: > > (Disclaimer: I know next-to-nothing about AppleEvents and > Applescript, so forgive me if any of this is gibberish) > > In Applescript Editor, returning an itunes track will show something > like the following in the results window : > > file track id 4369 of user playlist id 1361 of source id 37 of > application "iTunes" > > I need to read that id - 4369 - in rubyosa. > Looking at the track in Script Debugger's AEPrint window shows this : > > 'obj '{ > 'form':'ID ', > 'want':'cFlT', > 'seld':4369, > ... > > } Given the AppleScript above, it seems as though that might be the track's unique identifier, does the following method return the same value? >> OSA::ITunes::Track#database_id - jens -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rubyosa-discuss/attachments/20061206/e051068d/attachment.html From jdelstrother at gmail.com Wed Dec 6 15:34:55 2006 From: jdelstrother at gmail.com (Jonathan del Strother) Date: Wed, 6 Dec 2006 20:34:55 +0000 Subject: [Rubyosa-discuss] Getting 'seld' of an itunes track... In-Reply-To: References: Message-ID: On 6 Dec 2006, at 19:22, Jens-Petr Mikhailovich wrote: > On 12/6/06, Jonathan del Strother wrote: > (Disclaimer: I know next-to-nothing about AppleEvents and > Applescript, so forgive me if any of this is gibberish) > > In Applescript Editor, returning an itunes track will show something > like the following in the results window : > > file track id 4369 of user playlist id 1361 of source id 37 of > application "iTunes" > > I need to read that id - 4369 - in rubyosa. > Looking at the track in Script Debugger's AEPrint window shows this : > > 'obj '{ > 'form':'ID ', > 'want':'cFlT', > 'seld':4369, > ... > > } > > Given the AppleScript above, it seems as though that might be the > track's unique identifier, does the following method return the > same value? > >> OSA::ITunes::Track#database_id Sadly not. database_id is per-file. I'm comparing the application's current_track to the list of tracks in the party shuffle playlist. If the same track occurs twice in the party shuffle list, that database id will occur twice. However, the seld id appears to be unique to each playlist entry, but is common between the current_track and the corresponding track in the party shuffle list. Did that make sense? Jon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rubyosa-discuss/attachments/20061206/1b5f453a/attachment.html From jenspetr at gmail.com Wed Dec 6 16:36:04 2006 From: jenspetr at gmail.com (Jens-Petr Mikhailovich) Date: Wed, 6 Dec 2006 13:36:04 -0800 Subject: [Rubyosa-discuss] Getting 'seld' of an itunes track... In-Reply-To: References: Message-ID: On 12/6/06, Jonathan del Strother wrote: > > On 6 Dec 2006, at 19:22, Jens-Petr Mikhailovich wrote: > > On 12/6/06, Jonathan del Strother wrote: > > > > (Disclaimer: I know next-to-nothing about AppleEvents and > > Applescript, so forgive me if any of this is gibberish) > > > > In Applescript Editor, returning an itunes track will show something > > like the following in the results window : > > > > file track id 4369 of user playlist id 1361 of source id 37 of > > application "iTunes" > > > > I need to read that id - 4369 - in rubyosa. > > Looking at the track in Script Debugger's AEPrint window shows this : > > > > 'obj '{ > > 'form':'ID ', > > 'want':'cFlT', > > 'seld':4369, > > ... > > > > } > > > Given the AppleScript above, it seems as though that might be the track's > unique identifier, does the following method return the same value? > >> OSA::ITunes::Track#database_id > > > Sadly not. database_id is per-file. I'm comparing the application's > current_track to the list of tracks in the party shuffle playlist. If the > same track occurs twice in the party shuffle list, that database id will > occur twice. However, the seld id appears to be unique to each playlist > entry, but is common between the current_track and the corresponding track > in the party shuffle list. > Did that make sense? > > Jon > Quite tricky indeed. I am not able to coerce the data to type 'sled' however you might be able to access it in some other manner though the __data__ method. >> OSA.app('iTunes').current_track.get.__data__ - jens -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rubyosa-discuss/attachments/20061206/c50b8285/attachment-0001.html From henryj at paradise.net.nz Thu Dec 7 04:13:43 2006 From: henryj at paradise.net.nz (Henry Maddocks) Date: Thu, 07 Dec 2006 22:13:43 +1300 Subject: [Rubyosa-discuss] UTF-8 sdef and BBedit Message-ID: I downloaded rubyosa yesterday because I wanted to do some stuff with the keychain. I couldn't get anything to work so I thought I'd start a bit easier and try doing some stuff with BBedit. That didn't work either! So I decided to have a poke around and found, amongst other things, this... (http://rubyforge.org/tracker/index.php? func=detail&aid=6338&group_id=1845&atid=7180) This is wrong. The problem isn't that there are non ascii characters in the sdef, it is because the sdef is returned as utf-8 which you can't use for ruby module names. The method codes in the sdef are actually 32bit integers, not ascii strings and for some reason the sdef is being encoded as utf-8 rather than returning the raw ints. Anyway after some experimentation I ended up with this... def self.rubyfy_constant_string(string, upcase=false) string = string.unpack('U*').join if /^\d/.match(string) string = 'C' << string else string = string.dup string[0] = string[0].chr.upcase end escape_string(upcase ? string.upcase : string.gsub(/\s(.)/) { |s| s[1].chr.upcase }) end Strangely this seems to work. At least my meager testing and the sdef sample seems to do the right thing. Anyone like to test this properly. henry From lrz at chopine.be Thu Dec 7 07:26:27 2006 From: lrz at chopine.be (Laurent Sansonetti) Date: Thu, 7 Dec 2006 13:26:27 +0100 Subject: [Rubyosa-discuss] UTF-8 sdef and BBedit In-Reply-To: References: Message-ID: <3D6EA93C-BB07-40FE-B04F-B4ACF8F5CB1A@chopine.be> Hi Henry, Thanks for the feedback, however this issue has been already fixed in SVN, so feel free to check out the latest revision or wait for the next release Laurent On Dec 7, 2006, at 10:13 AM, Henry Maddocks wrote: > I downloaded rubyosa yesterday because I wanted to do some stuff with > the keychain. I couldn't get anything to work so I thought I'd start > a bit easier and try doing some stuff with BBedit. That didn't work > either! > > So I decided to have a poke around and found, amongst other things, > this... > > (http://rubyforge.org/tracker/index.php? > func=detail&aid=6338&group_id=1845&atid=7180) > > This is wrong. The problem isn't that there are non ascii characters > in the sdef, it is because the sdef is returned as utf-8 which you > can't use for ruby module names. The method codes in the sdef are > actually 32bit integers, not ascii strings and for some reason the > sdef is being encoded as utf-8 rather than returning the raw ints. > > Anyway after some experimentation I ended up with this... > > > def self.rubyfy_constant_string(string, upcase=false) > string = string.unpack('U*').join > if /^\d/.match(string) > string = 'C' << string > else > string = string.dup > string[0] = string[0].chr.upcase > end > escape_string(upcase ? string.upcase : string.gsub(/\s(.)/) > { |s| s[1].chr.upcase }) > end > > > Strangely this seems to work. At least my meager testing and the sdef > sample seems to do the right thing. Anyone like to test this properly. > > henry > _______________________________________________ > Rubyosa-discuss mailing list > Rubyosa-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/rubyosa-discuss From lrz at chopine.be Thu Dec 7 08:52:28 2006 From: lrz at chopine.be (Laurent Sansonetti) Date: Thu, 7 Dec 2006 14:52:28 +0100 Subject: [Rubyosa-discuss] Getting 'seld' of an itunes track... In-Reply-To: References: Message-ID: Hi, On Dec 6, 2006, at 10:36 PM, Jens-Petr Mikhailovich wrote: > On 12/6/06, Jonathan del Strother wrote: > On 6 Dec 2006, at 19:22, Jens-Petr Mikhailovich wrote: > >> On 12/6/06, Jonathan del Strother < maillist at steelskies.com> wrote: >> (Disclaimer: I know next-to-nothing about AppleEvents and >> Applescript, so forgive me if any of this is gibberish) >> >> In Applescript Editor, returning an itunes track will show something >> like the following in the results window : >> >> file track id 4369 of user playlist id 1361 of source id 37 of >> application "iTunes" >> >> I need to read that id - 4369 - in rubyosa. >> Looking at the track in Script Debugger's AEPrint window shows this : >> >> 'obj '{ >> 'form':'ID ', >> 'want':'cFlT', >> 'seld':4369, >> ... >> >> } >> >> Given the AppleScript above, it seems as though that might be the >> track's unique identifier, does the following method return the >> same value? >> >> OSA::ITunes::Track#database_id > > Sadly not. database_id is per-file. I'm comparing the > application's current_track to the list of tracks in the party > shuffle playlist. If the same track occurs twice in the party > shuffle list, that database id will occur twice. However, the seld > id appears to be unique to each playlist entry, but is common > between the current_track and the corresponding track in the party > shuffle list. > Did that make sense? > > Jon > > Quite tricky indeed. I am not able to coerce the data to type 'sled' > however you might be able to access it in some other manner though > the __data__ method. > >> OSA.app('iTunes').current_track.get.__data__ In fact the problem is that iTunes doesn't define an "ID " property in its sdef. AppleScript doesn't follow the sdef, hence why you can access it. As this is a basic property I changed RubyOSA to handle it if necessary (committed as r110). $ ruby -I. -I./src/lib -r rbosa -e "p OSA.app('iTunes').sources[0].id2" 41 $ ruby -I. -I./src/lib -r rbosa -e "p OSA.app('iTunes').sources[0].playlists[0].tracks[42].id2" 2076 (Note that the method to use here is "id2", as "id" already exists (it's in fact a method of the Ruby basic Object class). RubyOSA automatically appends a counter on method names if they are already defined in the target class.) Laurent From cocoasmuggler at gmail.com Wed Dec 13 04:13:57 2006 From: cocoasmuggler at gmail.com (nutsmuggler) Date: Wed, 13 Dec 2006 10:13:57 +0100 Subject: [Rubyosa-discuss] Rubyosa not working with bibdesk and filemaker Message-ID: <19F05882-8193-4E9C-8756-9A667FAD85C9@gmail.com> Yesterday I downloaded RubyOSA from SVN, complied it, and tried a few simple scripts. I noticed that RubyOSA doesn't seem to work wiit a number of app. My script was VERY basic, like require 'rbosa' app = OSA.app('TextEdit.app') While the script works with TextEdit, iTunes, iPhoto, finder (that is, the script opens the app), I get no effect with BibDesk and an error with FileMaker: "RuntimeError: Error when translating the application" I browsed through the list archives and found out a similar issue was present with BBEdit (http://rubyforge.org/pipermail/rubyosa-discuss/ 2006-December/000063.html). I wonder if this is a more general rubyosa bug; if so, is there a workaround? Thanks, Davide From kth7485 at rit.edu Thu Dec 21 18:04:49 2006 From: kth7485 at rit.edu (Kyle Howarth) Date: Thu, 21 Dec 2006 18:04:49 -0500 Subject: [Rubyosa-discuss] Fixing the Demo on the Front Page Message-ID: <1419F006-698E-4F21-A4BA-2D961FAEB4B6@rit.edu> Hey guys, Just an FYI that the code on the front page is wrong. Track.duration returns an OSA.Element. Track.time is what returns the length of the track now. Just an FYI since it's still shown in the rdoc generated from iTunes. Kyle