fix: properly fetch music library from Emby servers
This commit is contained in:
@@ -113,6 +113,7 @@ export interface JellyfinLibraryItemExtended extends JellyfinLibraryItem {
|
||||
Tvdb?: string;
|
||||
AniDB?: string;
|
||||
MusicBrainzReleaseGroup: string | undefined;
|
||||
MusicBrainzAlbum?: string;
|
||||
MusicBrainzArtistId?: string;
|
||||
};
|
||||
MediaSources?: JellyfinMediaSource[];
|
||||
|
||||
@@ -2,6 +2,7 @@ import animeList from '@server/api/animelist';
|
||||
import type { JellyfinLibraryItem } from '@server/api/jellyfin';
|
||||
import JellyfinAPI from '@server/api/jellyfin';
|
||||
import { getMetadataProvider } from '@server/api/metadata';
|
||||
import MusicBrainz from '@server/api/musicbrainz';
|
||||
import TheMovieDb from '@server/api/themoviedb';
|
||||
import { ANIME_KEYWORD_ID } from '@server/api/themoviedb/constants';
|
||||
import type {
|
||||
@@ -693,6 +694,7 @@ class JellyfinScanner {
|
||||
|
||||
private async processMusic(jellyfinitem: JellyfinLibraryItem) {
|
||||
const mediaRepository = getRepository(Media);
|
||||
const musicBrainz = new MusicBrainz();
|
||||
|
||||
try {
|
||||
const metadata = await this.jfClient.getItemData(jellyfinitem.Id);
|
||||
@@ -706,10 +708,25 @@ class JellyfinScanner {
|
||||
return;
|
||||
}
|
||||
|
||||
// Use MusicBrainzReleaseGroup as the foreign ID
|
||||
newMedia.mbId = metadata.ProviderIds?.MusicBrainzReleaseGroup;
|
||||
|
||||
// Only proceed if we have a valid ID
|
||||
if (!newMedia.mbId && metadata.ProviderIds?.MusicBrainzAlbum) {
|
||||
try {
|
||||
const releaseGroupId = await musicBrainz.getReleaseGroup({
|
||||
releaseId: metadata.ProviderIds.MusicBrainzAlbum,
|
||||
});
|
||||
if (releaseGroupId) {
|
||||
newMedia.mbId = releaseGroupId;
|
||||
}
|
||||
} catch (e) {
|
||||
this.log('Failed to get release group ID', 'error', {
|
||||
title: metadata.Name,
|
||||
releaseId: metadata.ProviderIds.MusicBrainzAlbum,
|
||||
error: e.message,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!newMedia.mbId) {
|
||||
this.log(
|
||||
'No MusicBrainz Album ID found for this title. Skipping.',
|
||||
|
||||
Reference in New Issue
Block a user