From 77275028aea26b21fab89a59c63dbc7b47f27ca7 Mon Sep 17 00:00:00 2001 From: OzGav Date: Mon, 29 Sep 2025 15:53:39 +1000 Subject: [PATCH] Remove unsupported library methods (#2440) --- .../providers/podcast-index/__init__.py | 2 - .../providers/podcast-index/constants.py | 1 - .../providers/podcast-index/provider.py | 74 +------------------ 3 files changed, 1 insertion(+), 76 deletions(-) diff --git a/music_assistant/providers/podcast-index/__init__.py b/music_assistant/providers/podcast-index/__init__.py index c5e55654..599d4821 100644 --- a/music_assistant/providers/podcast-index/__init__.py +++ b/music_assistant/providers/podcast-index/__init__.py @@ -20,8 +20,6 @@ if TYPE_CHECKING: SUPPORTED_FEATURES = { ProviderFeature.SEARCH, ProviderFeature.BROWSE, - ProviderFeature.LIBRARY_PODCASTS, - ProviderFeature.LIBRARY_PODCASTS_EDIT, } diff --git a/music_assistant/providers/podcast-index/constants.py b/music_assistant/providers/podcast-index/constants.py index 7587d190..46eb24d0 100644 --- a/music_assistant/providers/podcast-index/constants.py +++ b/music_assistant/providers/podcast-index/constants.py @@ -12,4 +12,3 @@ API_BASE_URL = "https://api.podcastindex.org/api/1.0" BROWSE_TRENDING = "trending" BROWSE_RECENT = "recent" BROWSE_CATEGORIES = "categories" -BROWSE_MY_SUBSCRIPTIONS = "my_subscriptions" diff --git a/music_assistant/providers/podcast-index/provider.py b/music_assistant/providers/podcast-index/provider.py index 76a677f3..aca7f106 100644 --- a/music_assistant/providers/podcast-index/provider.py +++ b/music_assistant/providers/podcast-index/provider.py @@ -2,7 +2,6 @@ from __future__ import annotations -import asyncio from collections.abc import AsyncGenerator, Sequence from typing import Any, cast @@ -30,7 +29,6 @@ from music_assistant.models.music_provider import MusicProvider from .constants import ( BROWSE_CATEGORIES, - BROWSE_MY_SUBSCRIPTIONS, BROWSE_RECENT, BROWSE_TRENDING, CONF_API_KEY, @@ -104,12 +102,6 @@ class PodcastIndexProvider(MusicProvider): if path == base: # Return main browse categories return [ - BrowseFolder( - item_id=BROWSE_MY_SUBSCRIPTIONS, - provider=self.domain, - path=f"{base}{BROWSE_MY_SUBSCRIPTIONS}", - name="My Subscriptions", - ), BrowseFolder( item_id=BROWSE_TRENDING, provider=self.domain, @@ -135,9 +127,7 @@ class PodcastIndexProvider(MusicProvider): subpath_parts = path[len(base) :].split("/") subpath = subpath_parts[0] if subpath_parts else "" - if subpath == BROWSE_MY_SUBSCRIPTIONS: - return await self._browse_subscriptions() - elif subpath == BROWSE_TRENDING: + if subpath == BROWSE_TRENDING: return await self._browse_trending() elif subpath == BROWSE_RECENT: return await self._browse_recent_episodes() @@ -152,57 +142,6 @@ class PodcastIndexProvider(MusicProvider): return [] - async def get_library_podcasts(self) -> AsyncGenerator[Podcast, None]: - """ - Retrieve subscribed podcasts from the provider. - - Uses MA's cache system and concurrent fetching to minimize API calls - and improve performance for multiple subscriptions. - """ - stored_podcasts = cast("list[str]", self.config.get_value(CONF_STORED_PODCASTS)) - - if not stored_podcasts: - return - - async def fetch_podcast(feed_url: str) -> Podcast | None: - """Fetch a single podcast.""" - try: - # Fetch from API - response = await self._api_request("podcasts/byfeedurl", params={"url": feed_url}) - if response.get("feed"): - return parse_podcast_from_feed( - response["feed"], self.lookup_key, self.domain, self.instance_id - ) - - except (ProviderUnavailableError, InvalidDataError) as err: - self.logger.warning("Failed to get podcast %s: %s", feed_url, err) - except Exception as err: - self.logger.warning("Unexpected error getting podcast %s: %s", feed_url, err) - return None - - # Fetch podcasts concurrently with retry - semaphore = asyncio.Semaphore(3) # Max 3 concurrent requests - - async def fetch_with_semaphore_and_retry(feed_url: str) -> Podcast | None: - async with semaphore: - # Try once - result = await fetch_podcast(feed_url) - if result: - return result - - # Retry once after 10 seconds - await asyncio.sleep(10) - return await fetch_podcast(feed_url) - - # Gather all podcast fetches concurrently with retry - tasks = [fetch_with_semaphore_and_retry(feed_url) for feed_url in stored_podcasts] - podcasts = await asyncio.gather(*tasks, return_exceptions=True) - - # Yield successfully fetched podcasts - for podcast in podcasts: - if isinstance(podcast, Podcast): - yield podcast - async def library_add(self, item: MediaItemType) -> bool: """ Add podcast to library. @@ -476,17 +415,6 @@ class PodcastIndexProvider(MusicProvider): ) return None - async def _browse_subscriptions(self) -> list[Podcast]: - """Browse user subscriptions.""" - try: - return [podcast async for podcast in self.get_library_podcasts()] - except (ProviderUnavailableError, InvalidDataError): - # Re-raise these specific errors - raise - except Exception as err: - self.logger.warning("Unexpected error browsing subscriptions: %s", err, exc_info=True) - return [] - @use_cache(7200) # Cache for 2 hours async def _browse_trending(self) -> list[Podcast]: """Browse trending podcasts.""" -- 2.34.1