Stupid iTunes

pudge on 2003-02-13T02:58:12

I have been getting a lot of complaints about ID3v2 tags of certain MP3s not being able to be read by MP3::Info. In pretty much every case, the file was written by iTunes. It turns out that iTunes is saving comments in a tag "COM ". My regex was looking for tags matching /^[A-Z0-9]{4}$/. Because, that is what, you know, EVERY TAG NAME MATCHES. ID3v2.3.0 and ID3v2.4.0 specify that the comment field is "COMM", not "COM ". I guess they did this so their own comments wouldn't interfere with the user's comments, or something; you can have multiple comments fields. But that space broke MP3::Info. And it is certainly broken:

The frame ID is made out of the characters capital A-Z and 0-9. Identifiers beginning with "X", "Y" and "Z" are for experimental frames and free for everyone to use, without the need to set the experimental bit in the tag header. Bear in mind that someone else might have used the same identifier as you. All other identifiers are either used or reserved for future use.


-- ID3 tag version 2.4.0 - Main Structure: 4. ID3v2 frame overview

So 1. it must not have a space there and 2. it must begin with X, Y, or Z if it is different from the standard set of frame IDs.

Oh well, I tracked it down, all better. Will upload sometime soon (more fixes to make).


Actually, not all comments.

blech on 2003-02-13T10:31:17

iTunes doesn't store all comments in the 'COM ' tag. It stores textual comments (ie the ones edited via the command-I tag inspector) in a proper 'COMM' header. What it does store in 'COM ' is the CDDB2 discid.

I suspect that's why it defaults to id3v2.2, where tag IDs are three letters (and 'COM' is therefore valid). Why it *doesn't* convert this particular 'COM ' to 'COMM' I don't know.

This also explains why it only occurs on some mp3s, as only mp3s ripped by a CDDB2 client writing id3v2.2 tags which are later converted by iTunes exhibit this behaviour. (Unsuprisingly, this means it's almost always mp3s ripped by iTunes itself.)

(I found this out while playing with acme's MP3::ID3Lib a couple of weeks ago. I should have written it up then. Sorry.)

Re:Actually, not all comments.

pudge on 2003-02-13T14:50:23

You didn't write it up! Eye keel j00! No, that's OK, it didn't take me long to find it. But yes, I noticed that it stored the user-specified comment in COMM. It's quite broken.

I am adding a new type of "mode" for get_mp3tag() which returns all the ID3v2 information it can. It is dissimilar from the plain get_mp3tag in that it returns more than just the ID3v1 frame types, and different from the older "raw_v2" mode in that it does the text encoding (and other manipulative) stuff to the data. It also converts the frame ID to the English name, so "COM " has to have its own English name:
[pudge@bourque mp3]$ perl -MMP3::Info -MData::Dumper -wle '$Data::Dumper::Indent = 0; print Dumper get_mp3tag(shift,2,2)' freddie\ copy.mp3
$VAR1 = {
  'Encoded by' => 'SoundJam v2.5.2',
  'Comments' => 'testing',
  'Album/Movie/Show title' => 'In Yo\' Face: The History Of Funk, Vol 1',
  'Broken iTunes comments' => [
    {'SoundJam_CDDB_1' => 'E10C780F+3194+15+182+13090+34542+47535+65042+78652+93250+108142+123545+140710+1 63947+177250+193442+209585+223610'},
    {'SoundJam_CDDB_TrackNumber' => '9'}
  ],
  'TAGVERSION' => 'ID3v2.4.0',
  'Content type' => 'Funk',
  'Title/songname/content description' => 'Freddie\'s Dead (Theme from Superfly)',
  'Track number/Position in set' => '9/15',
  'Composer' => 'testing2',
  'Lead performer(s)/Soloist(s)' => 'Mayfield, Curtis'
};
I suppose I could have put the "COM " stuff in with "COMM," but I prefer to be slightly vindictive. Of course, if this were ID3v2.2.0, the regular comment and the broken iTunes comments would be together:
  'Comments' => [
    {'SoundJam_CDDB_1' => 'E10C780F+3194+15+182+13090+34542+47535+65042+78652+93250+108142+123545+140710+1 63947+177250+193442+209585+223610'},
    {'SoundJam_CDDB_TrackNumber' => '9'}
    'testing',
  ],
(The user-defined comment doesn't have a description, so it is not a hashref, just a plain string.)

While we are on the subject ... it looks like I am not going to do ID3v2 writing for this version of MP3::Info. I have a bunch of other patches, and I am going to get those polished up and out the door first, then come back to ID3v2 writing. I hate having to put too many changes into one release if I can help it ...

Compilation field

jerakeen on 2003-02-13T10:44:13

I've been writing stuff to put music imported by iTunes in the right directories to match the rest of the collection, and found the 'TCP' frame, that contains the 'compilation' value (for various artists albums, you can't store the album in a folder by artist, so if this is set, I store it under 'various artists'. Can't find that in the spec anywhere either..