diff --git a/CMakeLists.txt b/CMakeLists.txt index 266b386..ba7d548 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,8 +9,8 @@ set(META_APP_AUTHOR "Martchus") set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") set(META_APP_DESCRIPTION "C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags") set(META_VERSION_MAJOR 9) -set(META_VERSION_MINOR 3) -set(META_VERSION_PATCH 1) +set(META_VERSION_MINOR 4) +set(META_VERSION_PATCH 0) set(META_REQUIRED_CPP_UNIT_VERSION 1.14.0) set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON) diff --git a/vorbis/vorbiscomment.cpp b/vorbis/vorbiscomment.cpp index dde26b7..dc66768 100644 --- a/vorbis/vorbiscomment.cpp +++ b/vorbis/vorbiscomment.cpp @@ -106,6 +106,7 @@ KnownField VorbisComment::internallyGetKnownField(const IdentifierType &id) cons { comment(), KnownField::Comment }, { cover(), KnownField::Cover }, { date(), KnownField::RecordDate }, + { year(), KnownField::RecordDate }, { title(), KnownField::Title }, { genre(), KnownField::Genre }, { trackNumber(), KnownField::TrackPosition }, @@ -181,6 +182,16 @@ template void VorbisComment::internalParse(StreamType &stream stream.ignore(); // skip framing byte } m_size = static_cast(static_cast(stream.tellg()) - startOffset); + // turn "YEAR" into "DATE" (unless "DATE" exists) + // note: "DATE" is an official field and "YEAR" only an inofficial one but present in some files. In consistency with + // MediaInfo and VLC player it is treated like "DATE" here. + if (fields().find(VorbisCommentIds::date()) == fields().end()) { + const auto [first, end] = fields().equal_range(VorbisCommentIds::year()); + for (auto i = first; i != end; ++i) { + fields().insert(std::pair(VorbisCommentIds::date(), std::move(i->second))); + } + fields().erase(first, end); + } } else { diag.emplace_back(DiagLevel::Critical, "Signature is invalid.", context); throw InvalidDataException(); diff --git a/vorbis/vorbiscommentids.h b/vorbis/vorbiscommentids.h index 3a1d66d..1e1a244 100644 --- a/vorbis/vorbiscommentids.h +++ b/vorbis/vorbiscommentids.h @@ -143,6 +143,10 @@ constexpr TAG_PARSER_EXPORT const char *date() { return "DATE"; } +constexpr TAG_PARSER_EXPORT const char *year() +{ + return "YEAR"; // not mentioned in https://xiph.org/vorbis/doc/v-comment.html but seen in the wild +} constexpr TAG_PARSER_EXPORT const char *location() { return "LOCATION";