Source code for minim.api.qobuz._private_api.catalog

from __future__ import annotations
from typing import TYPE_CHECKING

from ..._shared import TTLCache, _copy_docstring
from ._shared import PrivateQobuzResourceAPI
from .search import PrivateSearchAPI

if TYPE_CHECKING:
    from typing import Any

    from ...._types import Collection


[docs] class PrivateCatalogAPI(PrivateQobuzResourceAPI): """ Catalog API endpoints for the private Qobuz API. .. important:: This class is managed by :class:`~minim.api.qobuz.PrivateQobuzAPIClient` and should not be instantiated directly. """ _FEATURED_TYPES = {"albums", "articles", "artists", "playlists"} __slots__ = ()
[docs] @TTLCache.cached_method(ttl="search") def get_num_search_matches( self, query: str, / ) -> dict[str, dict[str, int]]: """ Get the number of Qobuz catalog search results for a query. Parameters ---------- query : str; positional-only Search query. Returns ------- num_matches : dict[str, dict[str, int]] Number of search results for the query. .. admonition:: Sample response :class: response dropdown .. code-block:: { "albums": { "total": <int> }, "artists": { "total": <int> }, "tracks": { "total": <int> } } """ return self._client._request( "GET", "catalog/count", params={"query": self._prepare_string("query", query)}, ).json()
[docs] @_copy_docstring(PrivateSearchAPI.search) def search( self, query: str, /, *, limit: int | None = None, offset: int | None = None, ) -> dict[str, Any]: return self._client.search.search(query, limit=limit, offset=offset)