[Bug 57419] kio_audiocd: enconded ogg files have a wrong date

Scott Wheeler wheeler at kde.org
Fri Apr 18 20:13:00 BST 2003


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
     
http://bugs.kde.org/show_bug.cgi?id=57419     
wheeler at kde.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From wheeler at kde.org  2003-04-18 21:12 -------
Subject: kdemultimedia/kioslave/audiocd

CVS commit by wheeler: 

Don't set fields for which no data was found by CDDB.  Also refactored this
code a bit while I was at it.

CCMAIL:57419-done at bugs.kde.org


  M +24 -38    audiocd.cpp   1.72


--- kdemultimedia/kioslave/audiocd/audiocd.cpp  #1.71:1.72
@@ -872,46 +872,32 @@ AudioCDProtocol::get(const KURL & url)
       trackName = d->titles[d->req_track].mid(3);
 
-    vorbis_comment_add_tag
-      (
-       &d->vc,
-       const_cast<char *>("title"),
-       const_cast<char *>(trackName.utf8().data())
-      );
+    typedef QPair<QCString, QString> CommentField;
+    QValueList<CommentField> commentFields;
 
-    vorbis_comment_add_tag
-      (
-       &d->vc,
-       const_cast<char *>("artist"),
-       const_cast<char *>(d->cd_artist.utf8().data())
-      );
+    commentFields.append(CommentField("title", trackName));
+    commentFields.append(CommentField("artist", d->cd_artist));
+    commentFields.append(CommentField("album", d->cd_title));
+    commentFields.append(CommentField("genre", d->cd_category));
+    commentFields.append(CommentField("tracknumber", QString::number(d->req_track+1)));
 
-    vorbis_comment_add_tag
-      (
-       &d->vc,
-       const_cast<char *>("album"),
-       const_cast<char *>(d->cd_title.utf8().data())
-      );
+    if (d->cd_year > 0) {
+      QDateTime dt = QDate(d->cd_year, 1, 1);
+      commentFields.append(CommentField("date", dt.toString(Qt::ISODate).utf8().data()));
+    }
 
-    vorbis_comment_add_tag
-      (
-       &d->vc,
-       const_cast<char *>("genre"),
-       const_cast<char *>(d->cd_category.utf8().data())
-      );
+    for(QValueListIterator<CommentField> it = commentFields.begin(); it != commentFields.end(); ++it) {
 
-    vorbis_comment_add_tag
-      (
-       &d->vc,
-       const_cast<char *>("tracknumber"),
-       const_cast<char *>(QString::number(d->req_track+1).utf8().data())
-      );
+      // if the value is not empty
+      if(!(*it).second.isEmpty()) {
 
-     QDateTime dt = QDate(d->cd_year, 1, 1);
-     vorbis_comment_add_tag
-      (
-       &d->vc,
-       const_cast<char *>("date"),
-       const_cast<char *>(dt.toString(Qt::ISODate).utf8().data())
-      );
+        char *key = qstrdup((*it).first);
+        char *value = qstrdup((*it).second.utf8().data());
+
+        vorbis_comment_add_tag(&d->vc, key, value);
+        
+        delete [] key;
+        delete [] value;
+      }
+    }
   }
 #endif



More information about the kde-multimedia mailing list