Now correctly detects embedded WMA covers
This commit is contained in:
@@ -51,7 +51,7 @@ getAlbum(const MetadataMap& metadataMap)
|
|||||||
|
|
||||||
res = Album{*album, ""};
|
res = Album{*album, ""};
|
||||||
|
|
||||||
auto albumMBID {findFirstValueOf(metadataMap, {"MUSICBRAINZ ALBUM ID", "MUSICBRAINZ_ALBUMID"})};
|
auto albumMBID {findFirstValueOf(metadataMap, {"MUSICBRAINZ ALBUM ID", "MUSICBRAINZ_ALBUMID", "MUSICBRAINZ/ALBUM ID"})};
|
||||||
if (!albumMBID)
|
if (!albumMBID)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ getAlbumArtists(const MetadataMap& metadataMap)
|
|||||||
|
|
||||||
Artist artist {*name, ""};
|
Artist artist {*name, ""};
|
||||||
|
|
||||||
auto mbid {findFirstValueOf(metadataMap, {"MUSICBRAINZ ALBUM ARTIST ID"})};
|
auto mbid {findFirstValueOf(metadataMap, {"MUSICBRAINZ ALBUM ARTIST ID", "MUSICBRAINZ/ALBUM ARTIST ID"})};
|
||||||
if (mbid)
|
if (mbid)
|
||||||
artist.musicBrainzArtistID = *mbid;
|
artist.musicBrainzArtistID = *mbid;
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ getArtists(const MetadataMap& metadataMap)
|
|||||||
|
|
||||||
std::vector<std::string> artistMBIDs;
|
std::vector<std::string> artistMBIDs;
|
||||||
{
|
{
|
||||||
auto mbids {findFirstValueOf(metadataMap, {"MUSICBRAINZ ARTIST ID", "MUSICBRAINZ_ARTISTID"})};
|
auto mbids {findFirstValueOf(metadataMap, {"MUSICBRAINZ ARTIST ID", "MUSICBRAINZ_ARTISTID", "MUSICBRAINZ/ARTIST ID"})};
|
||||||
if (mbids)
|
if (mbids)
|
||||||
artistMBIDs = splitString(*mbids, "/");
|
artistMBIDs = splitString(*mbids, "/");
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,8 @@ AvFormat::parse(const std::filesystem::path& p, bool debug)
|
|||||||
}
|
}
|
||||||
else if (tag == "MUSICBRAINZ RELEASE TRACK ID"
|
else if (tag == "MUSICBRAINZ RELEASE TRACK ID"
|
||||||
|| tag == "MUSICBRAINZ_RELEASETRACKID"
|
|| tag == "MUSICBRAINZ_RELEASETRACKID"
|
||||||
|| tag == "MUSICBRAINZ_TRACKID")
|
|| tag == "MUSICBRAINZ_TRACKID"
|
||||||
|
|| tag == "MUSICBRAINZ/TRACK ID")
|
||||||
{
|
{
|
||||||
track.musicBrainzTrackID = value;
|
track.musicBrainzTrackID = value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include <taglib/fileref.h>
|
#include <taglib/fileref.h>
|
||||||
#include <taglib/tag.h>
|
#include <taglib/tag.h>
|
||||||
#include <taglib/tpropertymap.h>
|
#include <taglib/tpropertymap.h>
|
||||||
|
#include <taglib/asffile.h>
|
||||||
#include <taglib/mpegfile.h>
|
#include <taglib/mpegfile.h>
|
||||||
#include <taglib/id3v2tag.h>
|
#include <taglib/id3v2tag.h>
|
||||||
|
|
||||||
@@ -177,8 +178,15 @@ TagLibParser::parse(const std::filesystem::path& p, bool debug)
|
|||||||
|
|
||||||
// Not that good embedded pictures handling
|
// Not that good embedded pictures handling
|
||||||
|
|
||||||
|
// WMA
|
||||||
|
if (TagLib::ASF::File *asfFile {dynamic_cast<TagLib::ASF::File*>(f.file())})
|
||||||
|
{
|
||||||
|
const TagLib::ASF::Tag* tag {static_cast<TagLib::ASF::Tag*>(asfFile->tag())};
|
||||||
|
if (tag && tag->attributeListMap().contains("WM/Picture"))
|
||||||
|
track.hasCover = true;
|
||||||
|
}
|
||||||
// MP3
|
// MP3
|
||||||
if (TagLib::MPEG::File *mp3File {dynamic_cast<TagLib::MPEG::File*>(f.file())})
|
else if (TagLib::MPEG::File *mp3File {dynamic_cast<TagLib::MPEG::File*>(f.file())})
|
||||||
{
|
{
|
||||||
if (mp3File->ID3v2Tag())
|
if (mp3File->ID3v2Tag())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,12 +38,16 @@ void parse(MetaData::Parser& parser, const std::filesystem::path& file)
|
|||||||
|
|
||||||
parser.setClusterTypeNames( {"MOOD", "GENRE"} );
|
parser.setClusterTypeNames( {"MOOD", "GENRE"} );
|
||||||
|
|
||||||
|
const auto start {std::chrono::steady_clock::now()};
|
||||||
std::optional<Track> track {parser.parse(file, true)};
|
std::optional<Track> track {parser.parse(file, true)};
|
||||||
if (!track)
|
if (!track)
|
||||||
{
|
{
|
||||||
std::cerr << "Parsing failed" << std::endl;
|
std::cerr << "Parsing failed" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const auto end {std::chrono::steady_clock::now()};
|
||||||
|
|
||||||
|
std::cout << "Parsing time: " << std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() / 1000. << "ms" << std::endl;
|
||||||
|
|
||||||
std::cout << "Track metadata:" << std::endl;
|
std::cout << "Track metadata:" << std::endl;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user