|
|
|
@ -864,21 +864,31 @@ bool TagEditor::WriteTags(Song &s) |
|
|
|
MPEG::File file(path_to_file.c_str()); |
|
|
|
MPEG::File file(path_to_file.c_str()); |
|
|
|
ID3v2::Tag *tag = file.ID3v2Tag(); |
|
|
|
ID3v2::Tag *tag = file.ID3v2Tag(); |
|
|
|
String::Type encoding = String::UTF8; |
|
|
|
String::Type encoding = String::UTF8; |
|
|
|
|
|
|
|
|
|
|
|
ByteVector Composer("TCOM"); |
|
|
|
ByteVector Composer("TCOM"); |
|
|
|
ByteVector Performer("TOPE"); |
|
|
|
ByteVector Performer("TOPE"); |
|
|
|
ByteVector Disc("TPOS"); |
|
|
|
ByteVector Disc("TPOS"); |
|
|
|
ID3v2::Frame *ComposerFrame = new ID3v2::TextIdentificationFrame(Composer, encoding); |
|
|
|
|
|
|
|
ID3v2::Frame *PerformerFrame = new ID3v2::TextIdentificationFrame(Performer, encoding); |
|
|
|
TagLib::StringList list; |
|
|
|
ID3v2::Frame *DiscFrame = new ID3v2::TextIdentificationFrame(Disc, encoding); |
|
|
|
|
|
|
|
ComposerFrame->setText(ToWString(s.GetComposer())); |
|
|
|
GetTagList(list, s.GetComposer()); |
|
|
|
PerformerFrame->setText(ToWString(s.GetPerformer())); |
|
|
|
|
|
|
|
DiscFrame->setText(ToWString(s.GetDisc())); |
|
|
|
|
|
|
|
tag->removeFrames(Composer); |
|
|
|
tag->removeFrames(Composer); |
|
|
|
|
|
|
|
ID3v2::TextIdentificationFrame *ComposerFrame = new ID3v2::TextIdentificationFrame(Composer, encoding); |
|
|
|
|
|
|
|
ComposerFrame->setText(list); |
|
|
|
tag->addFrame(ComposerFrame); |
|
|
|
tag->addFrame(ComposerFrame); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GetTagList(list, s.GetPerformer()); |
|
|
|
tag->removeFrames(Performer); |
|
|
|
tag->removeFrames(Performer); |
|
|
|
|
|
|
|
ID3v2::TextIdentificationFrame *PerformerFrame = new ID3v2::TextIdentificationFrame(Performer, encoding); |
|
|
|
|
|
|
|
PerformerFrame->setText(list); |
|
|
|
tag->addFrame(PerformerFrame); |
|
|
|
tag->addFrame(PerformerFrame); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GetTagList(list, s.GetDisc()); |
|
|
|
tag->removeFrames(Disc); |
|
|
|
tag->removeFrames(Disc); |
|
|
|
|
|
|
|
ID3v2::TextIdentificationFrame *DiscFrame = new ID3v2::TextIdentificationFrame(Disc, encoding); |
|
|
|
|
|
|
|
DiscFrame->setText(list); |
|
|
|
tag->addFrame(DiscFrame); |
|
|
|
tag->addFrame(DiscFrame); |
|
|
|
|
|
|
|
|
|
|
|
if (!file.save()) |
|
|
|
if (!file.save()) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -977,6 +987,18 @@ void TagEditor::LowerAllLetters(Song &s) |
|
|
|
s.SetComment(conv); |
|
|
|
s.SetComment(conv); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TagEditor::GetTagList(TagLib::StringList &list, const std::string &s) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
list.clear(); |
|
|
|
|
|
|
|
for (size_t i = 0; i != string::npos; i = s.find(",", i)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (i) |
|
|
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
size_t j = s.find(",", i); |
|
|
|
|
|
|
|
list.append(s.substr(i, j-i)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::string TagEditor::TagToString(const MPD::Song &s, void *data) |
|
|
|
std::string TagEditor::TagToString(const MPD::Song &s, void *data) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::string result; |
|
|
|
std::string result; |
|
|
|
|