Identifying a volume as being an iPod

On 7 Dec, 03:58, John J. [email protected]
wrote:

Thanks has,
some nice tips there!!
I spent some time last weekend reading about and working through some
AppleScript material.
It has tiny moments of wow, and lots and lots of uggggghhh
Feels about as fun as COBOL and should probably be renamed to APPOL.
I’m not a fan of it.

Won’t argue with those sentiments, but until the Ruby community builds
up enough knowledge and experience to stand on its own in this area,
it’s hard to avoid AppleScript completely. Folks like myself try to do
our bit in bringing that knowledge across, but there’s a lot to do and
more bodies are needed.

I’d also suggest reading the appscript documentation <http://rb-
appscript.rubyforge.org/doc/appscript-manual/index.html>, which
provides a brief introduction and tutorial to general application
scripting principles. I realise it’s rather thin and less than
brilliantly written (comments, criticisms, and requests and
suggestions for improvements would be hugely appreciated, btw) but
hopefully it’ll be of some help in getting your head around the
concepts involved.

Anyway, after digging deep enough, GUI scripting with Applescript
will require the user to enable GUI scripting.

I’m still not clear why you believe you have to use GUI Scripting, as
opposed to iTunes’ own scripting interface, but unless you can say
exactly what it is your script needs to do I can’t offer any more
specific advice on that front.

HTH

has

Anyway, after digging deep enough, GUI scripting with Applescript
will require the user to enable GUI scripting.

I’m still not clear why you believe you have to use GUI Scripting, as
opposed to iTunes’ own scripting interface, but unless you can say
exactly what it is your script needs to do I can’t offer any more
specific advice on that front.
Has, thanks again,
So far, as far as I can tell, the iTunes AppleScript library doesn’t
include a way to do what I want to do.
Of course I’m still getting a handle on AppleScript itself and making
sense of each application’s scripting library. They’re always pretty
thinly documented. I mean, they are terse. It’s like they were
written by credit card companies. Too short and hard to understand.

Anyway, I’ll figure out if I can actually use AppleScript or OSA
(without GUI scripting) once I have enough time to learn AS and OSA
more solidly. It’s a work in progress in spare time.

What I want to do is fundamentally this:
move some audio files (non-DRM’d, the type you’ve taken off of CD’s
yourself, and which have already been converted to mp3 or aac
formats) into the iTunes library.

Ideally, I’d like to move them into the library through iTunes in
order to have iTunes handle its own library xml files and such
itself, and parse all the files for their internal metadata (id3
tags, etc…). Let iTunes do the hard part.

If you already know a way to have iTunes rebuild or rescan its
library for files, then that would be great help. Then I would just
need to be able to ask iTunes where its library is and move the files
to it, then have them added to the library’s xml.

The other option conceptually was, telling iTunes to call its import
command and selecting the files from the directory they are in.

If you know which hooks I need or how to easily do any of this, it
would certainly save me some time and energy.

On Dec 7, 2007, at 10:15 PM, has wrote:

ITunes.add(files, :to=>app.playlists[‘your playlist’])

If the tracks are on an iPod that’s already listed in iTunes, it may
also be possible to directly copy them in iTunes without having to
muck about in the file system at all. However, I’m not an iTunes guru
so unless there’s any other ruby-talkers here who happen to know you
may need to ask on one of the AppleScript lists or look for existing
examples on http://dougscripts.com/itunes for help there.

Wow, excellent has!!
That’s a great help.
the add command is described in the scripting definition as adding to
a playlist, so I was very unsure if it would add to the library.

Quick question for you: can AppleScript like that be used with iTunes
for Windows as well?

If you have any other appscript or applescript tips, general ones
even, by all means clue me in!
Making sense of sdef libraries is definitely a tough thing to do with
the sparse docs.
You basically, just wrote the other half of my script for me!

Now, I’m going to give it a simple GUI so users don’t need to muck
about with the terminal.

by the way, is appscript the same as the appscript-rb gem?
Seems to be.

I picked up the OREILLY AppleScript book, seems useful.

On 8 Dec, 00:36, John J. [email protected]
wrote:

What I want to do is fundamentally this:
move some audio files (non-DRM’d, the type you’ve taken off of CD’s
yourself, and which have already been converted to mp3 or aac
formats) into the iTunes library.

Adding audio files to iTunes is easy enough, if typically under-
documented:

require ‘appscript’
include Appscript

ITunes = app(‘iTunes’)

files = [
MacTypes::Alias.path(’/path/to/file1.mp3’),
MacTypes::Alias.path(’/path/to/file2.mp3’),

]

track_refs = ITunes.add(files) # add files to iTunes library

p track_refs

If you want to add the files to a specific user playlist as well as
the main library playlist, you can supply a reference to that playlist
via the optional :to parameter:

ITunes.add(files, :to=>app.playlists[‘your playlist’])

If the tracks are on an iPod that’s already listed in iTunes, it may
also be possible to directly copy them in iTunes without having to
muck about in the file system at all. However, I’m not an iTunes guru
so unless there’s any other ruby-talkers here who happen to know you
may need to ask on one of the AppleScript lists or look for existing
examples on http://dougscripts.com/itunes for help there.

HTH

has

Hi all, for those of you who were into this thread, I was kind of
inspired by it and built a little backup script which runs in the
context of Rails, although all it really uses from Rails is
ActiveRecord and a schema auto-migrate plugin.

Of course being the shameless self-promoting blogger I am that gives
me the chance to form a totally provocative URL:

http://gilesbowkett.blogspot.com/2007/12/back-up-your-ipod-with-rails.html

But it’s really a shell script. The shell just happens to be IRB
instead of bash or zsh, and because of this it can use ActiveRecord,
the media file metadata libraries MP4Info and ID3Lib, and some other
niftiness.

Re: the original thread, John and has were talking quite a bit about
appscript, but I kind of went in the opposite direction. Although
appscript looks like a cool project, I want to get rid of iTunes
completely, so scripting it is an unsatisfying solution for me
personally.


Giles B.

Podcast: http://hollywoodgrit.blogspot.com
Blog: http://gilesbowkett.blogspot.com
Portfolio: http://www.gilesgoatboy.org
Tumblelog: http://giles.tumblr.com

On 9 Dec, 00:17, John J. [email protected]
wrote:

Quick question for you: can AppleScript like that be used with iTunes
for Windows as well?

No. The Windows version of iTunes has a COM API, however, so I’d
suggest looking into that. BTW, I believe there’s a project on
RubyForge to develop a cross-platform iTunes module; I don’t know how
far along it is, but you may want to look it up.

If you have any other appscript or applescript tips, general ones
even, by all means clue me in!

Understand how the Apple Event Object Model works - while every
application API is different, the basic rules by which they operate
are generally the same.

When figuring out a specific application API, start by reading the
dictionary, then hunt around for any supplementary documentation,
sample scripts, scripts written by other users, previous online
discussions, etc. to fill in the various bits of information that
dictionaries don’t tell you. Expect to do some trial-and-error
exploration and testing yourself to figure things out, and don’t be
shy to ask for advice when you get stuck - AppleScripters are well
used to exchanging knowledge this way.

Read the appscript manual. (You may also find some useful stuff on the
appscript site’s links page.)

ASDictionary and ASTranslate are your friends.

Appscript’s built-in #help method rocks for exploring applications in
irb. File feature requests with scriptable application developers
asking them to improve their documentation.

File feature requests with the appscript developer (me) asking for
improvements in the appscript documentation. (If you can be specific
about which bits need improved, that will be a big help.)

Making sense of sdef libraries is definitely a tough thing to do with
the sparse docs.

Tell us about it. If it’s any consolation, figuring out applications’
scripting interfaces does get easier with practice. You should find
Matt’s book some help in getting started here, and if you’ve any
specific questions then just ask.

by the way, is appscript the same as the appscript-rb gem?
Seems to be.

Yep. Ruby appscript (rb-appscript) is available in source, gem and
binary installer formats. Python and ObjC versions of appscript are
also available (py-appscript, objc-appscript). Unfortunately, the use
of prefixes is somewhat inconsistent, and they quite often get omitted
due to laziness, oversight or (in the case of py-appscript) historical
reasons. e.g. Use ‘gem install rb-appscript’ to install the Ruby
appscript gem and ‘require “appscript”’ to import it.

HTH

has

Giles,
I was thinking the last 2 weeks of just such an idea… (email me
directly to discuss that… it is an interesting idea I have
regarding that…)

My little curmudgeon of an app for moving songs from an iPod to
iTunes is going to be ready today.
It’s still a little rough and it does unfortunately rely on some GUI
scripting at this time, but it works.

It’d be easy enough to change it to do other things, like simply copy
the files to elsewhere, but things would get more involved with a
necessary check for DRM since DRMd songs would be useless without
violating the DMCA and getting sued.

At this time I don’t really want to do that.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs