Bug 141679 - Repeated genre in ID3v2.3 tag
Summary: Repeated genre in ID3v2.3 tag
Status: RESOLVED FIXED
Alias: None
Product: taglib
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Scott Wheeler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-14 14:00 UTC by Xavier Duret
Modified: 2007-04-01 22:54 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
ID3v2.3 genre repeat fix (997 bytes, patch)
2007-02-14 14:04 UTC, Xavier Duret
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xavier Duret 2007-02-14 14:00:15 UTC
Version:           svn 633141 (using KDE Devel)
Installed from:    Compiled sources

In ID3V2.3 tags, Taglib converts frames like "(1)Rock" into "Rock Rock".
Comment 1 Xavier Duret 2007-02-14 14:04:22 UTC
Created attachment 19685 [details]
ID3v2.3 genre repeat fix

This is a simple fix for frames like:
(1)Rock
It does not solve the problems of "refinement" that is to say frames like
(4)Eurodisco
which should be parsed as "Eurodisco" and not "Disco Eurodisco".
Comment 2 Scott Wheeler 2007-04-01 22:54:19 UTC
SVN commit 648998 by wheeler:

Switch to using a list of genres and checking for membership in there to avoid repeated values.

Based on a patch from Xavier Duret.

BUG:141679


 M  +8 -14     id3v2tag.cpp  


--- trunk/kdesupport/taglib/taglib/mpeg/id3v2/id3v2tag.cpp #648997:648998
@@ -141,10 +141,9 @@
 
   StringList fields = f->fieldList();
 
-  String genreString;
-  bool hasNumber = false;
+  StringList genres;
 
-  for(StringList::ConstIterator it = fields.begin(); it != fields.end(); ++it) {
+  for(StringList::Iterator it = fields.begin(); it != fields.end(); ++it) {
 
     bool isNumber = true;
 
@@ -155,22 +154,17 @@
       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));
-      }
+      if(number >= 0 && number <= 255)
+        *it = ID3v1::genre(number);
     }
-    else {
-      genreString.append(*it);
-    }
+
+    if(std::find(genres.begin(), genres.end(), *it) == genres.end())
+      genres.append(*it);
   }
 
-  return genreString;
+  return genres.toString();
 }
 
 TagLib::uint ID3v2::Tag::year() const