Remove scrobble from Subsonic provider (#1904)
authorEric Munson <eric@munsonfam.org>
Thu, 23 Jan 2025 22:20:56 +0000 (17:20 -0500)
committerGitHub <noreply@github.com>
Thu, 23 Jan 2025 22:20:56 +0000 (23:20 +0100)
music_assistant/providers/opensubsonic/sonic_provider.py

index 22e45665849d2353b1d82d138d53cb1917203129..ecc72dd92db8ade8f71518ec8c374473de6a925d 100644 (file)
@@ -751,7 +751,6 @@ class OpenSonicProvider(MusicProvider):
                 item.content_type,
             )
 
-            self.mass.create_task(self._report_playback_started(item_id))
         elif media_type == MediaType.PODCAST_EPISODE:
             item = await self._get_podcast_episode(item_id)
 
@@ -760,13 +759,20 @@ class OpenSonicProvider(MusicProvider):
                 item.id,
                 item.content_type,
             )
-            self.mass.create_task(self._report_playback_started(item.id))
         else:
             msg = f"Unsupported media type encountered '{media_type}'"
             raise UnsupportedFeaturedException(msg)
 
         mime_type = item.content_type
-        if mime_type.endswith("mpeg"):
+        # For mp4 or m4a files, better to let ffmpeg detect the codec in use so mark them unknown
+        if mime_type.endswith("mp4"):
+            self.logger.warning(
+                "Due to the streaming method used by the subsonic API, M4A files "
+                "may fail. See provider documentation for more information."
+            )
+            mime_type = "?"
+        # For mp3 files, ffmpeg wants to be told 'mp3' instead of 'audio/mpeg'
+        elif mime_type.endswith("mpeg"):
             mime_type = item.suffix
 
         return StreamDetails(
@@ -780,10 +786,6 @@ class OpenSonicProvider(MusicProvider):
             duration=item.duration if item.duration else 0,
         )
 
-    async def _report_playback_started(self, item_id: str) -> None:
-        self.logger.debug("scrobble for now playing called for %s", item_id)
-        await self._run_async(self._conn.scrobble, sid=item_id, submission=False)
-
     async def on_played(
         self,
         media_type: MediaType,
@@ -804,8 +806,8 @@ class OpenSonicProvider(MusicProvider):
         When fully_played is set to false and position is 0,
         the user marked the item as unplayed in the UI.
         """
-        self.logger.debug("scrobble for listen count called for %s", item_id)
-        await self._run_async(self._conn.scrobble, sid=item_id, submission=True)
+        # Leave this function as the place where we will create a bookmark for podcasts when they
+        # are stopped early and delete the bookmark when they are finished.
 
     async def get_audio_stream(
         self, streamdetails: StreamDetails, seek_position: int = 0