1
0
mirror of synced 2026-05-22 14:43:19 +00:00

refactor(MetadataCollector): add common types for SingularArtistId & PluralArtistId

This commit is contained in:
ma225tq
2026-02-06 17:32:18 +01:00
committed by Borewit
parent 86b5d9b7c7
commit 7c57bdcbdf
+7 -4
View File
@@ -15,6 +15,9 @@ import { parseLyrics } from '../lrc/LyricsParser.js';
const debug = initDebug('music-metadata:collector');
type SingularArtistId = 'artist' | 'albumartist';
type PluralArtistId = 'artists' | 'albumartists';
const TagPriority: TagType[] = ['matroska', 'APEv2', 'vorbis', 'ID3v2.4', 'ID3v2.3', 'ID3v2.2', 'exif', 'asf', 'iTunes', 'AIFF', 'ID3v1'];
/**
@@ -297,8 +300,8 @@ export class MetadataCollector implements INativeMetadataCollector {
private handleSingularArtistTag(
tagType: TagType | 'artificial',
tag: IGenericTag,
singularId: 'artist' | 'albumartist',
pluralId: 'artists' | 'albumartists'
singularId: SingularArtistId,
pluralId: PluralArtistId
): Promise<void> | void {
if (this.commonOrigin[singularId] === this.originPriority[tagType]) {
// Assume the singular field is used as plural (multiple values from same source)
@@ -319,8 +322,8 @@ export class MetadataCollector implements INativeMetadataCollector {
private handlePluralArtistTag(
tagType: TagType | 'artificial',
tag: IGenericTag,
singularId: 'artist' | 'albumartist',
pluralId: 'artists' | 'albumartists'
singularId: SingularArtistId,
pluralId: PluralArtistId
): void {
if (!this.common[singularId] || this.commonOrigin[singularId] === this.originPriority.artificial) {
if (!this.common[pluralId] || this.common[pluralId].indexOf(tag.value as string) === -1) {