Fix issues with cached streamdetails
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Sat, 20 Dec 2025 00:22:39 +0000 (01:22 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Sat, 20 Dec 2025 00:22:39 +0000 (01:22 +0100)
music_assistant/controllers/player_queues.py
music_assistant/helpers/api.py
music_assistant/providers/podcast_index/provider.py
music_assistant/providers/podcastfeed/__init__.py
music_assistant/providers/soundcloud/__init__.py

index 6bcbbe8e7d89d99af0250e2c9c308058f751dc2e..288c10af5ccde4fbe43c9f1d0748198fb1588515 100644 (file)
@@ -1059,9 +1059,10 @@ class PlayerQueuesController(CoreController):
                 if queue.enqueued_media_items:
                     # we need to restore the MediaItem objects for the enqueued media items
                     # Items from cache may be dicts that need deserialization
-
                     restored_enqueued_items: list[MediaItemType] = []
-                    cached_items: list[Any] = cast("list[Any]", queue.enqueued_media_items)
+                    cached_items: list[dict[str, Any] | MediaItemType] = cast(
+                        "list[dict[str, Any] | MediaItemType]", queue.enqueued_media_items
+                    )
                     for item in cached_items:
                         if isinstance(item, dict):
                             restored_item = media_from_dict(item)
index ddd240f93deefbd1fdd19054a8d7d7cde7603435..83e30b5f11de9fca18226b2fbf19c676dde41e0a 100644 (file)
@@ -13,6 +13,7 @@ from types import NoneType, UnionType
 from typing import Any, TypeVar, Union, get_args, get_origin, get_type_hints
 
 from mashumaro.exceptions import MissingField
+from music_assistant_models.media_items.media_item import MediaItem
 
 from music_assistant.helpers.util import try_parse_bool
 
@@ -340,9 +341,12 @@ def parse_value(  # noqa: PLR0911
             return value
 
     if isinstance(value, dict) and hasattr(value_type, "from_dict"):
+        # Only validate media_type for actual MediaItem subclasses, not for other classes
+        # like StreamDetails that have a media_type field for a different purpose
         if (
             "media_type" in value
             and value_type.__name__ != "ItemMapping"
+            and issubclass(value_type, MediaItem)
             and value["media_type"] != value_type.media_type
         ):
             msg = "Invalid MediaType"
index 413b3ef4c10e6f30e6b7ba0c78fd5ef2d0943c2f..d39265b8fa974d355a1b5671c87f103afb8e14af 100644 (file)
@@ -314,7 +314,6 @@ class PodcastIndexProvider(MusicProvider):
 
         raise MediaNotFoundError(f"Episode {prov_episode_id} not found")
 
-    @use_cache(86400)
     async def get_stream_details(self, item_id: str, media_type: MediaType) -> StreamDetails:
         """
         Get stream details for a podcast episode.
index 039590d7c100218202db6fac44f505cf61c6cc70..d97b95c03438676bbac8bbca1534186ce5f9a128 100644 (file)
@@ -170,7 +170,6 @@ class PodcastMusicprovider(MusicProvider):
             if mass_episode := self._parse_episode(episode, idx):
                 yield mass_episode
 
-    @use_cache(3600)  # Cache for 1 hour
     async def get_stream_details(self, item_id: str, media_type: MediaType) -> StreamDetails:
         """Get streamdetails for a track/radio."""
         for episode in self.parsed_podcast["episodes"]:
index 955d175580dfc555fee38839f47483cfa4df5604..ddc59a61d13e7cc49f198f161a2035faaa595e07 100644 (file)
@@ -367,7 +367,6 @@ class SoundcloudMusicProvider(MusicProvider):
 
         return tracks
 
-    @use_cache(3600 * 3)  # Cache for 3 hours
     async def get_stream_details(self, item_id: str, media_type: MediaType) -> StreamDetails:
         """Return the content details for the given track when it will be streamed."""
         url: str = await self._soundcloud.get_stream_url(track_id=item_id, presets=["mp3"])