Add artist and release mbids to listenbrainz scobbles (#2048)
authorIan Campbell <ijc@users.noreply.github.com>
Tue, 25 Mar 2025 15:46:44 +0000 (15:46 +0000)
committerGitHub <noreply@github.com>
Tue, 25 Mar 2025 15:46:44 +0000 (16:46 +0100)
* Chore: bump models to 1.1.41

Set various new fields to None

* Add artist and release mbids to listenbrainz scobbles

https://github.com/music-assistant/models/pull/63 adds the relevant fields to
`MediaItemPlaybackProgressReport`.

music_assistant/controllers/player_queues.py
music_assistant/providers/audiobookshelf/parsers.py
music_assistant/providers/filesystem_local/__init__.py
music_assistant/providers/listenbrainz_scrobble/__init__.py
music_assistant/providers/opensubsonic/sonic_provider.py
music_assistant/providers/test/__init__.py
pyproject.toml
requirements_all.txt
tests/core/test_scrobbler.py

index a68620a45d90a585c2d19919f44030c1927f3000..d7d1ecce9cc4939ef506ba9840b8dd4a060de034 100644 (file)
@@ -1952,6 +1952,8 @@ class PlayerQueuesController(CoreController):
                 is_playing=is_playing,
             )
         )
+
+        album = getattr(item_to_report.media_item, "album", None)
         # signal 'media item played' event,
         # which is useful for plugins that want to do scrobbling
         self.mass.signal_event(
@@ -1962,11 +1964,13 @@ class PlayerQueuesController(CoreController):
                 media_type=item_to_report.media_item.media_type,
                 name=item_to_report.media_item.name,
                 artist=getattr(item_to_report.media_item, "artist_str", None),
-                album=(
-                    album.name
-                    if (album := getattr(item_to_report.media_item, "album", None))
+                artist_mbids=(
+                    [a.mbid for a in artists if a.mbid]
+                    if (artists := getattr(item_to_report.media_item, "artists", None))
                     else None
                 ),
+                album=(album.name if album else None),
+                album_mbid=(album.mbid if album else None),
                 image_url=(
                     self.mass.metadata.get_image_url(item_to_report.media_item.image, size=512)
                     if item_to_report.media_item.image
index c1f2258b0fa5705bb7575aab5577fe8a7ddfec47..9ca6d1af714d799045c7973a67ac42ab60bb9dc5 100644 (file)
@@ -113,6 +113,7 @@ def parse_podcast_episode(
         provider=lookup_key,
         name=episode.title,
         duration=int(episode.duration),
+        publish_date=None,
         position=position,
         podcast=ItemMapping(
             item_id=prov_podcast_id,
index d4194b1c849037803d33a02810bf2232f1ba5fa5..1034b2be3381417d555601623aac830abd876550 100644 (file)
@@ -1188,6 +1188,7 @@ class LocalFileSystemProvider(MusicProvider):
             provider=self.instance_id,
             name=tags.title,
             sort_name=tags.title_sort,
+            publish_date=None,
             provider_mappings={
                 ProviderMapping(
                     item_id=file_item.relative_path,
index c3823f5d2724c41dff214688e61654f0f75b32f9..f560ed6f257174a44538fe353bf16a1622c49743 100644 (file)
@@ -108,7 +108,9 @@ class ListenBrainzEventHandler(ScrobblerHelper):
         return Listen(
             track_name=report.name,
             artist_name=report.artist,
+            artist_mbids=report.artist_mbids,
             release_name=report.album,
+            release_mbid=report.album_mbid,
             recording_mbid=report.mbid,
             listening_from="music-assistant",
         )
index 30af636900227724c6af2f2fcc23d2a06aed5f6c..8eeb6fb01951e8d68e502fa60639b984674ea484 100644 (file)
@@ -349,6 +349,7 @@ class OpenSonicProvider(MusicProvider):
             name=sonic_episode.title,
             position=pos,
             podcast=self._parse_podcast(sonic_channel),
+            publish_date=None,
             provider_mappings={
                 ProviderMapping(
                     item_id=eid,
index a5687fb13256735f8daf3b3fa9c11df69dd3755b..494f17f849c77d1030fa4d20d04cf36cd6812b7b 100644 (file)
@@ -315,6 +315,7 @@ class TestProvider(MusicProvider):
             provider=self.lookup_key,
             name=f"Test PodcastEpisode {podcast_id}-{episode_idx}",
             duration=60,
+            publish_date=None,
             podcast=ItemMapping(
                 item_id=podcast_id,
                 provider=self.lookup_key,
index a5eb21227c7d56fdeda280954c9490bf919e72eb..cdc0cfe7876239329f0fd5426807c392fa66cd36 100644 (file)
@@ -24,7 +24,7 @@ dependencies = [
   "ifaddr==0.2.0",
   "mashumaro==3.15",
   "music-assistant-frontend==2.14.0",
-  "music-assistant-models==1.1.40",
+  "music-assistant-models==1.1.41",
   "mutagen==1.47.0",
   "orjson==3.10.15",
   "pillow==11.1.0",
index cdf69720fa458a78673b67d844c081c44add0918..e2d1a44fe42239ae15f75f5c0704407c0b9a744c 100644 (file)
@@ -27,7 +27,7 @@ ifaddr==0.2.0
 liblistenbrainz==0.5.6
 mashumaro==3.15
 music-assistant-frontend==2.14.0
-music-assistant-models==1.1.40
+music-assistant-models==1.1.41
 mutagen==1.47.0
 orjson==3.10.15
 pillow==11.1.0
index 21d8d6ebaaad24ff36dfda1aef49e09a0b20e6f2..2f73c48e62e512035205b1fdee89cd240179a396 100644 (file)
@@ -97,7 +97,9 @@ def create_report(
             media_type=MediaType.TRACK,
             name="track",
             artist=None,
+            artist_mbids=None,
             album=None,
+            album_mbid=None,
             image_url=None,
             duration=duration,
             mbid="",