[scan] Use MusicBrainz and other tags to set songalbumid

Credit to @whatdoineed2do for finding tags and suggesting this change.
This commit is contained in:
ejurgensen 2019-05-13 19:11:39 +02:00
parent b3bfb0a5f6
commit 35a585c23e

View File

@ -128,6 +128,18 @@ parse_date(struct media_file_info *mfi, char *date_string)
return ret;
}
static int
parse_albumid(struct media_file_info *mfi, char *id_string)
{
// Already set by a previous tag that we give higher priority
if (mfi->songalbumid)
return 0;
// Limit hash length to 63 bits, due to signed type in sqlite
mfi->songalbumid = murmur_hash64(id_string, strlen(id_string), 0) >> 1;
return 1;
}
/* Lookup is case-insensitive, first occurrence takes precedence */
static const struct metadata_map md_map_generic[] =
{
@ -152,6 +164,16 @@ static const struct metadata_map md_map_generic[] =
{ "album-sort", 0, mfi_offsetof(album_sort), NULL },
{ "compilation", 1, mfi_offsetof(compilation), NULL },
// These tags are used to determine if files belong to a common compilation
// or album, ref. https://picard.musicbrainz.org/docs/tags
{ "MusicBrainz Album Id", 1, mfi_offsetof(songalbumid), parse_albumid },
{ "MusicBrainz Release Group Id", 1, mfi_offsetof(songalbumid), parse_albumid },
{ "MusicBrainz DiscID", 1, mfi_offsetof(songalbumid), parse_albumid },
{ "CDDB DiscID", 1, mfi_offsetof(songalbumid), parse_albumid },
{ "iTunes_CDDB_IDs", 1, mfi_offsetof(songalbumid), parse_albumid },
{ "CATALOGNUMBER", 1, mfi_offsetof(songalbumid), parse_albumid },
{ "BARCODE", 1, mfi_offsetof(songalbumid), parse_albumid },
{ NULL, 0, 0, NULL }
};