HOWTO Copy Music from an iPod
Sunday, December 24th, 2006 02:45 amAt some point, my iTunes library location was incorrectly set to the Music folder in my home folder instead of my external hard drive.
tamheals downloaded several albums, ripped a few, and we bought six songs from the iTunes store. At a later time, the setting was changed to the correct location on the external hard drive and the files from the Music folder were re-added to iTunes and copied to that path. I therefore had two (in some cases three) entries per song for these albums. One evening I went through and moved the Music files to the trash and deleted them from the iTunes list, making sure I could still play them. A few weeks later, Tam emptied the trash. Suddenly, all of the files I'd deleted were marked as missing from iTunes. Somehow (presumably user error) the files were no longer on the external hard drive.
The iTunes Store (unlike Calabash) only lets you download each purchased song once and advises you that you can burn them to CD. Burning a CD with six unconnected songs hadn't seemed like an important move. This is not a feature which benefits the consumer in any way
Fortunately, most of the deleted files are on Tam's iPod. Unfortunately, the iPod file system is obfuscated. Fortunately, there's a mp3info Ruby gem and I've been reading the Ruby Cookbook. I wrote the following script to go through all the mp3 files on the iPod and print the title, artist, album, track, and file path. I then went through the songs marked missing in iTunes and copied the file names into a text file, munging each line into a copy statement.
The script doesn't work on .m4a (AAC) files since mp3info can't handle them. Several minutes of googling finds only references to an MP4Tag ruby library by Miles Egan. Links to that page produce a 404. Archive.org has the old page, but didn't archive the tarball. The site seems to have been hijacked. If I get ambitious I may try to find an AAC specification and parse the files myself, but I think I'll accomplish the task with a list of songs I'm looking for and grepping each .m4a file.
Update, two hours later: Files purchased from the iTunes Store have a .m4p extension (rather than .m4a), so recovering the MIA purchased songs was a simple as
( findmp3s.rb )
![[livejournal.com profile]](https://www.dreamwidth.org/img/external/lj-userinfo.gif)
The iTunes Store (unlike Calabash) only lets you download each purchased song once and advises you that you can burn them to CD. Burning a CD with six unconnected songs hadn't seemed like an important move. This is not a feature which benefits the consumer in any way
Fortunately, most of the deleted files are on Tam's iPod. Unfortunately, the iPod file system is obfuscated. Fortunately, there's a mp3info Ruby gem and I've been reading the Ruby Cookbook. I wrote the following script to go through all the mp3 files on the iPod and print the title, artist, album, track, and file path. I then went through the songs marked missing in iTunes and copied the file names into a text file, munging each line into a copy statement.
The script doesn't work on .m4a (AAC) files since mp3info can't handle them. Several minutes of googling finds only references to an MP4Tag ruby library by Miles Egan. Links to that page produce a 404. Archive.org has the old page, but didn't archive the tarball. The site seems to have been hijacked. If I get ambitious I may try to find an AAC specification and parse the files myself, but I think I'll accomplish the task with a list of songs I'm looking for and grepping each .m4a file.
Update, two hours later: Files purchased from the iTunes Store have a .m4p extension (rather than .m4a), so recovering the MIA purchased songs was a simple as
ls -l /Volumes/RhiPod/iTunes_Control/Music/*.m4p
and comparing the file modification dates with those iTunes remembered for the missing songs. I also found faad2 and installed it through DarwinPorts. faad2 is a decoder for AAC files and the -i command line option prints a lot of information, including metadata. I ran it on all the .m4a files and saved the output to a textfile which I can process with the flip-flop (..) operator.( findmp3s.rb )