Reputation:
I am a classical music fan. My music collection (mp3) has been carefully classified using "composer" (ex. "Surname name (D.O.B-D.O.D"). I frequently get the "artist" from importing the music, ripping or some online data base. Because my mobile music player (Xbox) orders only by "artist", I would like to "swap": album_artist = artist artist = composer and composer would simply remain the same (and same as artist). (Visual Studio 2013, W7, taglib1.9.1):
TagLib::PropertyMap tags = f.file()->properties();
unsigned int longest = 0;
for (TagLib::PropertyMap::ConstIterator i = tags.begin(); i != tags.end(); ++i) {
if (i->first.size() > longest) {
longest = i->first.size();
}
}
cout << "-- TAG (properties) --" << endl;
for (TagLib::PropertyMap::Iterator i = tags.begin(); i != tags.end(); ++i) {
if (i->first == "COMPOSER") {
composer = i->second;
composer_key = i->first;
}
if (i->first == "ARTIST") {
artist.append(i->second);
artist_key = i->first;
}
if (i->first == "ALBUMARTIST") {
album_artist.append(i->second);
album_artist_key = i->first;
}
cout << left << std::setw(longest) << i->first << " - " << '"' << i->second << '"' << endl;
}
if (!tags.replace(album_artist_key, artist))
cout << "album_artist_key is wrong";
else
cout << "replacing " << album_artist_key << " with " << artist << endl;
if (!tags.replace(artist_key, composer))
cout << "artist is wrong";
else
cout << "replacing " << artist_key << " with " << composer << endl;
tag->setArtist(composer.toString());
f.save();
NOTE: this code was modified starting from the tagreader.cpp code found in examples of the library. This compiles, but after execution, all ID3 tags info disappear (corruption?), as seen by windows explorer. So, I did an experiment and commented out everything that makes any change to the tag. Basically, just open the file (FileRef) and do f.save(). This alone causes the tags to disappear. Two questions (I think I got this completely wrong ...)
Upvotes: 2
Views: 376
Reputation: 2419
That's not corruption; Windows Explorer just still can't read ID3v2.4 tags, a standard which came out 15 years ago, and is the default in TagLib. TagLib can, however, also write ID3v2.3 tags.
Upvotes: 1