// should be separated by " / " instead of " ". For the moment to keep
// the behavior the same as released versions it is being left with " ".
- if(!d->frameListMap["TCON"].isEmpty() &&
- dynamic_cast<TextIdentificationFrame *>(d->frameListMap["TCON"].front()))
+ if(d->frameListMap["TCON"].isEmpty() ||
+ !dynamic_cast<TextIdentificationFrame *>(d->frameListMap["TCON"].front()))
{
- Frame *frame = d->frameListMap["TCON"].front();
-
- // ID3v2.4 lists genres as the fields in its frames field list. If the field
- // is simply a number it can be assumed that it is an ID3v1 genre number.
- // Here was assume that if an ID3v1 string is present that it should be
- // appended to the genre string. Multiple fields will be appended as the
- // string is built.
-
- if(d->header.majorVersion() == 4) {
- TextIdentificationFrame *f = static_cast<TextIdentificationFrame *>(frame);
- StringList fields = f->fieldList();
-
- String genreString;
- bool hasNumber = false;
-
- for(StringList::ConstIterator it = fields.begin(); it != fields.end(); ++it) {
- bool isNumber = true;
- for(String::ConstIterator charIt = (*it).begin();
- isNumber && charIt != (*it).end();
- ++charIt)
- {
- isNumber = *charIt >= '0' && *charIt <= '9';
- }
-
- if(!genreString.isEmpty())
- genreString.append(' ');
-
- if(isNumber) {
- int number = (*it).toInt();
- if(number >= 0 && number <= 255) {
- hasNumber = true;
- genreString.append(ID3v1::genre(number));
- }
- }
- else
- genreString.append(*it);
- }
- if(hasNumber)
- return genreString;
+ return String::null;
+ }
+
+ // ID3v2.4 lists genres as the fields in its frames field list. If the field
+ // is simply a number it can be assumed that it is an ID3v1 genre number.
+ // Here was assume that if an ID3v1 string is present that it should be
+ // appended to the genre string. Multiple fields will be appended as the
+ // string is built.
+
+ TextIdentificationFrame *f = static_cast<TextIdentificationFrame *>(
+ d->frameListMap["TCON"].front());
+
+ StringList fields = f->fieldList();
+
+ String genreString;
+ bool hasNumber = false;
+
+ for(StringList::ConstIterator it = fields.begin(); it != fields.end(); ++it) {
+
+ bool isNumber = true;
+
+ for(String::ConstIterator charIt = (*it).begin();
+ isNumber && charIt != (*it).end();
+ ++charIt)
+ {
+ isNumber = *charIt >= '0' && *charIt <= '9';
}
- String s = frame->toString();
-
- // ID3v2.3 "content type" can contain a ID3v1 genre number in parenthesis at
- // the beginning of the field. If this is all that the field contains, do a
- // translation from that number to the name and return that. If there is a
- // string folloing the ID3v1 genre number, that is considered to be
- // authoritative and we return that instead. Or finally, the field may
- // simply be free text, in which case we just return the value.
-
- int closing = s.find(")");
- if(s.substr(0, 1) == "(" && closing > 0) {
- if(closing == int(s.size() - 1))
- return ID3v1::genre(s.substr(1, s.size() - 2).toInt());
- else
- return s.substr(closing + 1);
+ if(!genreString.isEmpty())
+ genreString.append(' ');
+
+ if(isNumber) {
+ int number = (*it).toInt();
+ if(number >= 0 && number <= 255) {
+ hasNumber = true;
+ genreString.append(ID3v1::genre(number));
+ }
+ }
+ else {
+ genreString.append(*it);
}
- return s;
}
- return String::null;
+
+ return genreString;
}
TagLib::uint ID3v2::Tag::year() const