Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

Commit

Permalink
Don't write empty genres to tags.
Browse files Browse the repository at this point in the history
Issue #1765
  • Loading branch information
CDrummond committed Feb 6, 2022
1 parent 9544f55 commit b2d740d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
31. If using table-style play queue, then only sort one column at a time.
32. Stop user MPD instance from GUI thread when terminating, to ensure state
can be saved.
33. Don't write empty genres to tags.

2.4.2
-----
Expand Down
31 changes: 23 additions & 8 deletions tags/tags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,13 @@ static bool writeID3v2Tags(TagLib::ID3v2::Tag *tag, const Song &from, const Song
tag->setGenre(qString2TString(to.firstGenre().trimmed()));
} else {
for(int i=0; i<Song::constNumGenres; ++i) {
TagLib::ID3v2::TextIdentificationFrame *frame = new TagLib::ID3v2::TextIdentificationFrame("TCON");
tag->addFrame(frame);
DBUG << "add genre" << to.genres[i].trimmed();
frame->setText(qString2TString(to.genres[i].trimmed()));
QString genre = to.genres[i].trimmed();
if (!genre.isEmpty()) {
TagLib::ID3v2::TextIdentificationFrame *frame = new TagLib::ID3v2::TextIdentificationFrame("TCON");
tag->addFrame(frame);
DBUG << "add genre" << genre;
frame->setText(qString2TString(genre));
}
}
}
changed=true;
Expand Down Expand Up @@ -670,7 +673,10 @@ static bool writeAPETags(TagLib::APE::Tag *tag, const Song &from, const Song &to
tag->setGenre(qString2TString(to.firstGenre().trimmed()));
} else {
for(int i=0; i<Song::constNumGenres; ++i) {
tag->addValue("GENRE", qString2TString(to.genres[i].trimmed()), false);
QString genre = to.genres[i].trimmed();
if (!genre.isEmpty()) {
tag->addValue("GENRE", qString2TString(genre), false);
}
}
}
changed=true;
Expand Down Expand Up @@ -904,7 +910,10 @@ static bool writeVorbisCommentTags(TagLib::Ogg::XiphComment *tag, const Song &fr
tag->setGenre(qString2TString(to.firstGenre().trimmed()));
} else {
for(int i=0; i<Song::constNumGenres; ++i) {
tag->addField("GENRE", qString2TString(to.genres[i].trimmed()), false);
QString genre = to.genres[i].trimmed();
if (!genre.isEmpty()) {
tag->addField("GENRE", qString2TString(genre), false);
}
}
}
changed=true;
Expand Down Expand Up @@ -1079,7 +1088,10 @@ static bool writeMP4Tags(TagLib::MP4::Tag *tag, const Song &from, const Song &to
} else {
TagLib::StringList tagGenres;
for(int i=0; i<Song::constNumGenres; ++i) {
tagGenres.append(qString2TString(to.genres[i].trimmed()));
QString genre = to.genres[i].trimmed();
if (!genre.isEmpty()) {
tagGenres.append(qString2TString(genre));
}
}
tag->setItem("\251gen",tagGenres);
}
Expand Down Expand Up @@ -1195,7 +1207,10 @@ static bool writeASFTags(TagLib::ASF::Tag *tag, const Song &from, const Song &to
tag->setGenre(qString2TString(to.firstGenre().trimmed()));
} else {
for(int i=0; i<Song::constNumGenres; ++i) {
tag->addAttribute("WM/Genre", qString2TString(to.genres[i].trimmed()));
QString genre = to.genres[i].trimmed();
if (!genre.isEmpty()) {
tag->addAttribute("WM/Genre", qString2TString(genre));
}
}
}
changed=true;
Expand Down

0 comments on commit b2d740d

Please sign in to comment.