From f41d333788c8e227c2f3b4dd37790e01a3595f48 Mon Sep 17 00:00:00 2001 From: Chris Throup Date: Mon, 21 Jan 2013 08:56:56 +0000 Subject: [PATCH] Read and write extra metadata for MP4 tags. Fixes issue 222. Now writes album artist, disc number, composer, compilation and bpm. Now reads disc number and composer. Previously read album artist. Unconfirmed read for compilation and bpm. --- ext/clementine-tagreader/tagreaderworker.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ext/clementine-tagreader/tagreaderworker.cpp b/ext/clementine-tagreader/tagreaderworker.cpp index 4b8c29c40..e8f91d076 100644 --- a/ext/clementine-tagreader/tagreaderworker.cpp +++ b/ext/clementine-tagreader/tagreaderworker.cpp @@ -260,6 +260,14 @@ void TagReaderWorker::ReadFile(const QString& filename, if (items.find("covr") != items.end()) { song->set_art_automatic(kEmbeddedCover); } + + if(items.contains("disk")) { + disc = TStringToQString(TagLib::String::number(items["disk"].toIntPair().first)); + } + + if(items.contains("\251wrt")) { + Decode(items["\251wrt"].toStringList().toString(", "), NULL, song->mutable_composer()); + } } } else if (tag) { Decode(tag->comment(), NULL, song->mutable_comment()); @@ -464,6 +472,13 @@ bool TagReaderWorker::SaveFile(const QString& filename, tag->addField("BPM", QStringToTaglibString(song.bpm() <= 0 -1 ? QString() : QString::number(song.bpm())), true); tag->addField("DISCNUMBER", QStringToTaglibString(song.disc() <= 0 -1 ? QString() : QString::number(song.disc())), true); tag->addField("COMPILATION", StdStringToTaglibString(song.compilation() ? "1" : "0"), true); + } else if (TagLib::MP4::File* file = dynamic_cast(fileref->file())) { + TagLib::MP4::Tag* tag = file->tag(); + tag->itemListMap()["disk"] = TagLib::MP4::Item(song.disc() <= 0 -1 ? 0 : song.disc(), 0); + tag->itemListMap()["tmpo"] = TagLib::StringList(song.bpm() <= 0 -1 ? "0" : TagLib::String::number(song.bpm())); + tag->itemListMap()["\251wrt"] = TagLib::StringList(song.composer()); + tag->itemListMap()["aART"] = TagLib::StringList(song.albumartist()); + tag->itemListMap()["cpil"] = TagLib::StringList(song.compilation() ? "1" : "0"); } bool ret = fileref->save();