Skip to content

Commit

Permalink
ensure we use the provider lookup key for loudness measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Sep 12, 2024
1 parent dcb24d1 commit edabfc9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions music_assistant/server/controllers/music.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit edabfc9

Please sign in to comment.