Downgrade numerical genres back to ID3v2.3 format

Closes #631
This commit is contained in:
Scott Wheeler
2020-10-12 08:46:51 +02:00
parent 2db13ad8cf
commit e116824380
2 changed files with 30 additions and 2 deletions

View File

@ -495,6 +495,7 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const
ID3v2::TextIdentificationFrame *frameTDRC = 0;
ID3v2::TextIdentificationFrame *frameTIPL = 0;
ID3v2::TextIdentificationFrame *frameTMCL = 0;
ID3v2::TextIdentificationFrame *frameTCON = 0;
for(FrameList::ConstIterator it = d->frameList.begin(); it != d->frameList.end(); it++) {
ID3v2::Frame *frame = *it;
@ -516,6 +517,8 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const
frameTIPL = dynamic_cast<ID3v2::TextIdentificationFrame *>(frame);
else if(frameID == "TMCL")
frameTMCL = dynamic_cast<ID3v2::TextIdentificationFrame *>(frame);
else if(frame && frameID == "TCON")
frameTCON = dynamic_cast<ID3v2::TextIdentificationFrame *>(frame);
else
frames->append(frame);
}
@ -582,6 +585,22 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const
frames->append(frameIPLS);
newFrames->append(frameIPLS);
}
if(frameTCON) {
StringList genres = frameTCON->fieldList();
String combined;
for(StringList::ConstIterator it = genres.begin(); it != genres.end(); ++it) {
bool ok = false;
int number = it->toInt(&ok);
combined += (ok && number >= 0 && number <= 255) ? ('(' + *it + ')') : *it;
}
frameTCON = new ID3v2::TextIdentificationFrame("TCON", String::Latin1);
frameTCON->setText(combined);
frames->append(frameTCON);
newFrames->append(frameTCON);
}
}
ByteVector ID3v2::Tag::render(int version) const