From edabfc91b77ab17bffdb1ea6ec79283f509fa44d Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Thu, 12 Sep 2024 10:44:57 +0200 Subject: [PATCH] ensure we use the provider lookup key for loudness measurements --- music_assistant/server/controllers/music.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/music_assistant/server/controllers/music.py b/music_assistant/server/controllers/music.py index e96384119..23fd7835f 100644 --- a/music_assistant/server/controllers/music.py +++ b/music_assistant/server/controllers/music.py @@ -670,10 +670,12 @@ async def set_loudness( media_type: MediaType = MediaType.TRACK, ) -> None: """Store (EBU-R128) Integrated Loudness Measurement for a mediaitem in db.""" + if not (provider := self.mass.get_provider(provider_instance_id_or_domain)): + return values = { "item_id": item_id, "media_type": media_type.value, - "provider": provider_instance_id_or_domain, + "provider": provider.lookup_key, "loudness": loudness, } if album_loudness is not None: @@ -687,12 +689,14 @@ async def get_loudness( media_type: MediaType = MediaType.TRACK, ) -> tuple[float, float] | None: """Get (EBU-R128) Integrated Loudness Measurement for a mediaitem in db.""" + if not (provider := self.mass.get_provider(provider_instance_id_or_domain)): + return None db_row = await self.database.get_row( DB_TABLE_LOUDNESS_MEASUREMENTS, { "item_id": item_id, "media_type": media_type.value, - "provider": provider_instance_id_or_domain, + "provider": provider.lookup_key, }, ) if db_row and db_row["loudness"] != inf and db_row["loudness"] != -inf: