[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Identifying a volume as being an iPod

John Joyce

12/1/2007 5:27:00 PM

Does anybody know how to identify a mounted volume as being an iPod ?
Or even more generally useful, is there a lib or gem to help identify
the type of volume or disk ?

I'm currently working on a prog to help transfer songs from your iPod
to an authorized iTunes account.
iTunes itself makes it easy to transfer "purchased songs", that is,
songs that are identified as purchased through iTunes, but fails to
offer an easy method to transfer songs that you did not buy through
iTunes, such as tracks you ripped from a CD.

Opening the directories that hold the music on an iPod is dead
simple, even opening them as Finder windows on OS X, but the two
areas that are stopping me know are:
1-- making an automated identification of the iPod
2-- actually moving the songs to the iTunes library.

The second one is something I'm currently learning AppleScript in
order to make it feasible, perhaps with the rubyOSA gem.
Ideally, I would like to make it cross platform, but I don't have any
Windows, so it would be up to somebody else to add that later.




27 Answers

Tiago Macedo

12/1/2007 6:11:00 PM

0

An iPod (at least when formatted in FAT32 will contain an "iPod_Control"
folder on the root.

You can also check the USB device ids:
Bus 005 Device 003: ID 05ac:1261 Apple Computer, Inc.
(this is an 80GB Classic Silver)

or just build a wrapper for libgpod (I don't it supports drm'ed tracks
though)

Tiago Macedo

John Joyce wrote:
> Does anybody know how to identify a mounted volume as being an iPod ?
> Or even more generally useful, is there a lib or gem to help identify
> the type of volume or disk ?
>
> I'm currently working on a prog to help transfer songs from your iPod to
> an authorized iTunes account.
> iTunes itself makes it easy to transfer "purchased songs", that is,
> songs that are identified as purchased through iTunes, but fails to
> offer an easy method to transfer songs that you did not buy through
> iTunes, such as tracks you ripped from a CD.
>
> Opening the directories that hold the music on an iPod is dead simple,
> even opening them as Finder windows on OS X, but the two areas that are
> stopping me know are:
> 1-- making an automated identification of the iPod
> 2-- actually moving the songs to the iTunes library.
>
> The second one is something I'm currently learning AppleScript in order
> to make it feasible, perhaps with the rubyOSA gem.
> Ideally, I would like to make it cross platform, but I don't have any
> Windows, so it would be up to somebody else to add that later.
>
>
>
>

John Joyce

12/1/2007 9:41:00 PM

0


On Dec 1, 2007, at 12:10 PM, Tiago Macedo wrote:

> An iPod (at least when formatted in FAT32 will contain an
> "iPod_Control" folder on the root.
>
> You can also check the USB device ids:
> Bus 005 Device 003: ID 05ac:1261 Apple Computer, Inc.
> (this is an 80GB Classic Silver)
>
> or just build a wrapper for libgpod (I don't it supports drm'ed
> tracks though)
>
> Tiago Macedo
>
The device ID info is in the right vein for what I'm thinking of.
I know about the "iPod_Control" folder.
It's on every iPod, inside it is the Music folder and that contains
the directories that actually hold the audio files.
I'm just curious, but I'll look into the way the system recognizes
the iPod... there must be some simple trick to go, ok this is an iPod
and not some other device.

MonkeeSage

12/1/2007 10:25:00 PM

0

On Dec 1, 3:40 pm, John Joyce <dangerwillrobinsondan...@gmail.com>
wrote:
> On Dec 1, 2007, at 12:10 PM, Tiago Macedo wrote:
>
> > An iPod (at least when formatted in FAT32 will contain an
> > "iPod_Control" folder on the root.
>
> > You can also check the USB device ids:
> > Bus 005 Device 003: ID 05ac:1261 Apple Computer, Inc.
> > (this is an 80GB Classic Silver)
>
> > or just build a wrapper for libgpod (I don't it supports drm'ed
> > tracks though)
>
> > Tiago Macedo
>
> The device ID info is in the right vein for what I'm thinking of.
> I know about the "iPod_Control" folder.
> It's on every iPod, inside it is the Music folder and that contains
> the directories that actually hold the audio files.
> I'm just curious, but I'll look into the way the system recognizes
> the iPod... there must be some simple trick to go, ok this is an iPod
> and not some other device.

On my system (linux, 2.6.22 kernel), this turns up some interesting
results...

$ sudo grep -R -i ipod /usr/src/linux/*

....particularly, the following files look like they have some stuff
for identifying ipod devices...

/usr/src/linux/drivers/ieee1394/sbp2.c
/usr/src/linux/drivers/usb/storage/unusual_devs.h

Regards,
Jordan

John Joyce

12/1/2007 11:32:00 PM

0


On Dec 1, 2007, at 4:25 PM, MonkeeSage wrote:

> On Dec 1, 3:40 pm, John Joyce <dangerwillrobinsondan...@gmail.com>
> wrote:
>> On Dec 1, 2007, at 12:10 PM, Tiago Macedo wrote:
>>
>>> An iPod (at least when formatted in FAT32 will contain an
>>> "iPod_Control" folder on the root.
>>
>>> You can also check the USB device ids:
>>> Bus 005 Device 003: ID 05ac:1261 Apple Computer, Inc.
>>> (this is an 80GB Classic Silver)
>>
>>> or just build a wrapper for libgpod (I don't it supports drm'ed
>>> tracks though)
>>
>>> Tiago Macedo
>>
>> The device ID info is in the right vein for what I'm thinking of.
>> I know about the "iPod_Control" folder.
>> It's on every iPod, inside it is the Music folder and that contains
>> the directories that actually hold the audio files.
>> I'm just curious, but I'll look into the way the system recognizes
>> the iPod... there must be some simple trick to go, ok this is an iPod
>> and not some other device.
>
> On my system (linux, 2.6.22 kernel), this turns up some interesting
> results...
>
> $ sudo grep -R -i ipod /usr/src/linux/*
>
> ...particularly, the following files look like they have some stuff
> for identifying ipod devices...
>
> /usr/src/linux/drivers/ieee1394/sbp2.c
> /usr/src/linux/drivers/usb/storage/unusual_devs.h
>
> Regards,
> Jordan
>
Interesting, ieee1394 is FireWire, but iPods haven't shipped with
that in quite some time.
none the less, if you look in there and happen to see anything
interesting, let me know please!
I don't currently have a Linux system running, even it requires
better hardware than my current crop of old hardware...

Giles Bowkett

12/2/2007 12:39:00 AM

0

> Opening the directories that hold the music on an iPod is dead
> simple, even opening them as Finder windows on OS X, but the two
> areas that are stopping me know are:
> 1-- making an automated identification of the iPod
> 2-- actually moving the songs to the iTunes library.

The iTunes library has an XML component and a binary component. The
XML part is just a dumb-as-nails XML file. I think I once edited it by
hand because iTunes was pissing me off and I wanted it to know who was
boss. Anyway, IIRC, iTunes didn't explode as a result. I don't know
what the binary component is but if my fuzzy memory is working
properly you can just change the XML and the program will deal.

However, I thought moving files off the iPod was impossible.

Oh wow, that's cool. You can just go in there in Term, or Path Finder.
I don't use Finder, but presumably you can get in that way too. Very
cool. Now I can archive all the stuff I bought on my old computer.
Weird how the files get renamed, though. Are they supposed to all have
names like F47/ENNS.mp3?

> The second one is something I'm currently learning AppleScript in
> order to make it feasible, perhaps with the rubyOSA gem.
> Ideally, I would like to make it cross platform, but I don't have any
> Windows, so it would be up to somebody else to add that later.

I think you can just do it with Builder in Ruby. I did a little
googling and the impression I got was that the binary and XML
components are exact duplicates, and that when iTunes finds the binary
version is corrupted, it uses the XML as a backup. So you could just
add the files in the XML, nuke the binary, and iTunes would
automatically go to the XML to stay up to date.

By the way, if you want to find out what the files in
iPod_Control/iTunes do, don't run cat against them, some of them are
quite large and others will make your Terminal beep at you.

--
Giles Bowkett

Podcast: http://hollywoodgrit.bl...
Blog: http://gilesbowkett.bl...
Portfolio: http://www.gilesg...
Tumblelog: http://giles....

Giles Bowkett

12/2/2007 12:41:00 AM

0

If you speak Perl there are some pretty wiggy-looking Perl libraries for it:

http://search.cpan.org/search?query=iPod&am...

What's really odd is that most of them seem to involve SQL.

--
Giles Bowkett

Podcast: http://hollywoodgrit.bl...
Blog: http://gilesbowkett.bl...
Portfolio: http://www.gilesg...
Tumblelog: http://giles....

John Joyce

12/2/2007 3:02:00 AM

0


On Dec 1, 2007, at 6:41 PM, Giles Bowkett wrote:

> If you speak Perl there are some pretty wiggy-looking Perl
> libraries for it:
>
> http://search.cpan.org/search?query=iPod&am...
>
> What's really odd is that most of them seem to involve SQL.
>
> --
> Giles Bowkett
>
> Podcast: http://hollywoodgrit.bl...
> Blog: http://gilesbowkett.bl...
> Portfolio: http://www.gilesg...
> Tumblelog: http://giles....
>
Sweet, I don't speak Perl, but when it's readable I can read it
enough to get what I need.

But yeah, you can go into /Volumes/ipod_name/iPod_Control/Music/
and there you find some cryptically named directories that contain
your audio files.
The names of tracks are stored internally in the files themselves.

just open each directory with the OS X terminal command open, then
drag the songs to the iTunes library in the iTunes app window.
Sometimes the tracks will not get their names as they should and
retain those cryptic names in iTunes.
I've yet to determine why but I supsect either for larger libraries,
it steps on itself during the transfer, or files that are not the
native iTunes format might not contain the track info internally.

Anyway, this is my little project to help me and my coworkers enjoy
our own music at work.
I've discovered that OS X has an IORegistry that holds xml of
connected devices, iPods make themselves pretty obviously iPods in
that IORegistry, but I don't yet know how to access the IORegistry to
check connected iPods and their names.
I want to make it so that the user can confirm that the proper iPod
is being accessed, then transfer the songs.

appleScript is currently on the menu for adding the files to the
iTunes library. The library's xml files are just too ugly for me.
I don't really want to dig in to how they are structured or ordered.
This gives me the impetus to finally learn appleScript and then I can
use rubyOSA...
but if you have some deeper insights into iTunes' xml then maybe we
can add that to it.
I suspect using the appleScript GUI scripting approach will be faster
than Ruby xml writing.

If this is nailed down well enough it should be cake for somebody
else to do the windows version of the program.

John Joyce

12/2/2007 5:32:00 AM

0

Well, I've found better stuff to work with, more practical anyway.

in:
/Volumes/ipod_name_here/iPod_Control/Device/
there is a nifty little file called SysInfo

I wouldn't dare modify it, but it is worth reading. In fact, I would
almost recommend creating read-only method to wrap whatever methods
you want to use to open and read the thing. Just to avoid any chance
of stepping on this file.
I have replaced my serial number with a five asterisks. You only need
the first 3 characters of a serial number on the ipod to identify it.
The most important line is line 3, the model number.
You could, if you were diligent, check to see that the first 3 chars
of the serial number match the model number for the type of iPod.
If you were overly diligent, you could try to check the serial number
against Apple's web site somewhere.

Anyway, let's just say we've got more than enough to say the device
is probably an iPod and is likely the one you want to transfer music
from to an authorized iTunes. The odds of having multiple iPods
connected to one computer are pretty low. It happens, but not much.
That's no big deal, we just have to add a check to ask the user
running the program which iPod they want to transfer from, since the
name of the iPod is the same name in the terminal.

Now all we need to do is script the Finder to move the files into
iTunes!
After I finish learning just enough AppleScript, I will convert it to
RubyOSA...

The file reads thus:

BoardHwName: iPod M26
pszSerialNumber: 5U5*****TK2
ModelNumStr: MA107
FirewireGuid: 0x000A270012AE3CCB
HddFirmwareRev: ADBA41KB
RegionCode: J(0x0002)
PolicyFlags: 0x00000000
buildID: 0x05118000 (5.1.1)
visibleBuildID: 0x01118000 (1.1.1)
boardHwRev: 0x00000000 (0.0 0)
boardHwSwInterfaceRev: 0x000C0005 (0.0.12 5)
bootLoaderImageRev: 0x00000000 (0.0 0)
diskModeImageRev: 0x00000000 (0.0 0)
diagImageRev: 0x00000000 (0.0 0)
osImageRev: 0x00000000 (0.0 0)
iPodFamily: 0x00000000
updaterFamily: 0x00000000




Giles Bowkett

12/2/2007 7:29:00 AM

0

> it steps on itself during the transfer, or files that are not the
> native iTunes format might not contain the track info internally.

I can definitely contradict this. I pulled an .mp3 off one of my iPods
and although it had an iPod filename it knew what the song was called.
mp3s have a system for metadata, I think they're called ID3 tags but
don't quote me on that. I think Apple's proprietary format also uses
this same system for metadata. so when you pull in songs from an iPod
it just goes to the metadata in most cases. of course it's possible to
create mp3s without metadata, which is very likely what you're seeing
if it goes to the weird filename rather than the name of the song,
especially if you're only seeing it on mp3s but not AACs.

Anyway, seems like a nifty project, announce if you release it, sounds
like it'd be fun to play with.

--
Giles Bowkett

Podcast: http://hollywoodgrit.bl...
Blog: http://gilesbowkett.bl...
Portfolio: http://www.gilesg...
Tumblelog: http://giles....

MonkeeSage

12/2/2007 1:37:00 PM

0

On Dec 1, 5:31 pm, John Joyce <dangerwillrobinsondan...@gmail.com>
wrote:
> On Dec 1, 2007, at 4:25 PM, MonkeeSage wrote:
>
>
>
> > On Dec 1, 3:40 pm, John Joyce <dangerwillrobinsondan...@gmail.com>
> > wrote:
> >> On Dec 1, 2007, at 12:10 PM, Tiago Macedo wrote:
>
> >>> An iPod (at least when formatted in FAT32 will contain an
> >>> "iPod_Control" folder on the root.
>
> >>> You can also check the USB device ids:
> >>> Bus 005 Device 003: ID 05ac:1261 Apple Computer, Inc.
> >>> (this is an 80GB Classic Silver)
>
> >>> or just build a wrapper for libgpod (I don't it supports drm'ed
> >>> tracks though)
>
> >>> Tiago Macedo
>
> >> The device ID info is in the right vein for what I'm thinking of.
> >> I know about the "iPod_Control" folder.
> >> It's on every iPod, inside it is the Music folder and that contains
> >> the directories that actually hold the audio files.
> >> I'm just curious, but I'll look into the way the system recognizes
> >> the iPod... there must be some simple trick to go, ok this is an iPod
> >> and not some other device.
>
> > On my system (linux, 2.6.22 kernel), this turns up some interesting
> > results...
>
> > $ sudo grep -R -i ipod /usr/src/linux/*
>
> > ...particularly, the following files look like they have some stuff
> > for identifying ipod devices...
>
> > /usr/src/linux/drivers/ieee1394/sbp2.c
> > /usr/src/linux/drivers/usb/storage/unusual_devs.h
>
> > Regards,
> > Jordan
>
> Interesting, ieee1394 is FireWire, but iPods haven't shipped with
> that in quite some time.
> none the less, if you look in there and happen to see anything
> interesting, let me know please!
> I don't currently have a Linux system running, even it requires
> better hardware than my current crop of old hardware...

Interesting bits...

==snip==

/* iPod 4th generation */ {
.firmware_revision = 0x0a2700,
.model_id = 0x000021,
.workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
},
/* iPod mini */ {
.firmware_revision = 0x0a2700,
.model_id = 0x000023,
.workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
},
/* iPod Photo */ {
.firmware_revision = 0x0a2700,
.model_id = 0x00007e,
.workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
}

========

==snip==

/* Submitted by Sven Anderson <sven-linux@anderson.de>
* There are at least four ProductIDs used for iPods, so I added
0x1202 and
* 0x1204. They just need the US_FL_FIX_CAPACITY. As the bcdDevice
appears
* to change with firmware updates, I changed the range to maximum for
all
* iPod entries.
*/
UNUSUAL_DEV( 0x05ac, 0x1202, 0x0000, 0x9999,
"Apple",
"iPod",
US_SC_DEVICE, US_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY ),

/* Reported by Avi Kivity <avi@argo.co.il> */
UNUSUAL_DEV( 0x05ac, 0x1203, 0x0000, 0x9999,
"Apple",
"iPod",
US_SC_DEVICE, US_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY ),

UNUSUAL_DEV( 0x05ac, 0x1204, 0x0000, 0x9999,
"Apple",
"iPod",
US_SC_DEVICE, US_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ),

UNUSUAL_DEV( 0x05ac, 0x1205, 0x0000, 0x9999,
"Apple",
"iPod",
US_SC_DEVICE, US_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY ),

/*
* Reported by Tyson Vinson <lornoss@gmail.com>
* This particular productId is the iPod Nano
*/
UNUSUAL_DEV( 0x05ac, 0x120a, 0x0000, 0x9999,
"Apple",
"iPod",
US_SC_DEVICE, US_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY ),

========

Don't ask me about what exactly all the code means, I just thought it
looked promising. Ps. You can browse and search the kernel source
online: http://lxr.linu...

Regards,
Jordan