Vorbis comment: Turn "YEAR" into "DATE" (unless "DATE" exists)
"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.
This commit is contained in:
parent
cce1e2f96d
commit
9a5d366ce0
|
@ -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)
|
||||
|
||||
|
|
|
@ -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 <class StreamType> void VorbisComment::internalParse(StreamType &stream
|
|||
stream.ignore(); // skip framing byte
|
||||
}
|
||||
m_size = static_cast<std::uint32_t>(static_cast<std::uint64_t>(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();
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in New Issue