From 6ccae5f0d2b7383d8cb603ecdde4233b12e597b6 Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Mon, 23 Dec 2024 12:52:33 -0500 Subject: [PATCH] musikr.metadata: fix mp4 parsing --- musikr/src/main/cpp/JVMMetadataBuilder.cpp | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/musikr/src/main/cpp/JVMMetadataBuilder.cpp b/musikr/src/main/cpp/JVMMetadataBuilder.cpp index 04f34e54b..109f284e8 100644 --- a/musikr/src/main/cpp/JVMMetadataBuilder.cpp +++ b/musikr/src/main/cpp/JVMMetadataBuilder.cpp @@ -18,9 +18,13 @@ #include "JVMMetadataBuilder.h" +#include "log.h" + #include #include +#include + JVMMetadataBuilder::JVMMetadataBuilder(JNIEnv *env) : env(env), id3v2(env), xiph( env), mp4(env), cover(), properties(nullptr) { } @@ -60,19 +64,17 @@ void JVMMetadataBuilder::setXiph(const TagLib::Ogg::XiphComment &tag) { } void JVMMetadataBuilder::setMp4(const TagLib::MP4::Tag &tag) { - for (auto item : tag.itemMap()) { - auto itemName = TagLib::String(item.first); + auto map = tag.itemMap(); + for (auto item : map) { + auto itemName = item.first; auto itemValue = item.second; auto type = itemValue.type(); - - // TODO: Handle internal atoms - // Only read out the atoms for the reasonable tags we are expecting. // None of the crazy binary atoms. if (type == TagLib::MP4::Item::Type::StringList) { auto value = itemValue.toStringList(); mp4.add(itemName, value); - return; + continue; } // Assume that taggers will be unhinged and store track numbers @@ -80,17 +82,17 @@ void JVMMetadataBuilder::setMp4(const TagLib::MP4::Tag &tag) { if (type == TagLib::MP4::Item::Type::Int) { auto value = std::to_string(itemValue.toInt()); id3v2.add(itemName, value); - return; + continue; } if (type == TagLib::MP4::Item::Type::UInt) { auto value = std::to_string(itemValue.toUInt()); id3v2.add(itemName, value); - return; + continue; } if (type == TagLib::MP4::Item::Type::LongLong) { auto value = std::to_string(itemValue.toLongLong()); id3v2.add(itemName, value); - return; + continue; } if (type == TagLib::MP4::Item::Type::IntPair) { // It's inefficient going from the integer representation back into @@ -99,9 +101,8 @@ void JVMMetadataBuilder::setMp4(const TagLib::MP4::Tag &tag) { auto value = std::to_string(itemValue.toIntPair().first) + "/" + std::to_string(itemValue.toIntPair().second); id3v2.add(itemName, value); - return; + continue; } - // Nothing else makes sense to handle as far as I can tell. } }