Skip to content

search

Types for wrapping search results from providers.

CLASS DESCRIPTION
SearchResult

A wrapper for search results that tracks their provider origin.

T module-attribute

T = TypeVar('T', bound=BaseLibraryItem)

SearchResult dataclass

SearchResult(
    provider: str,
    result: T,
    original: T | None = None,
    _match: MatchResult = None,
)

Bases: Generic[T]

A wrapper for search results that tracks their provider origin.

This generic class wraps any BaseLibraryItem subtype (Song, Album, Artist, etc.) and associates it with the provider it came from. It also supports transparent attribute access to the wrapped result.

ATTRIBUTE DESCRIPTION
provider

Name of the provider that returned this result (e.g., "spotify", "youtube_music").

TYPE: str

result

The actual library item returned by the search.

TYPE: T

original

Optional reference to the original item being searched for, useful for matching.

TYPE: T | None

Example

result = SearchResult(provider="spotify", result=song) result.name # Delegates to song.name "Never Gonna Give You Up" result.resource_type ResourceType.SONG

provider instance-attribute

provider: str

result instance-attribute

result: T

original class-attribute instance-attribute

original: T | None = None

resource_type property

resource_type: ResourceType

Returns the resource type of the wrapped result.

match property

match

__getattr__

__getattr__(name: str)

Delegate attribute access to the wrapped result object.

Source code in src/downmixer/types/search.py
56
57
58
def __getattr__(self, name: str):
    """Delegate attribute access to the wrapped result object."""
    return getattr(self.result, name)

__dir__

__dir__()

Include wrapped result's attributes in dir() for better introspection/IDE completion.

Source code in src/downmixer/types/search.py
60
61
62
def __dir__(self):
    """Include wrapped result's attributes in dir() for better introspection/IDE completion."""
    return sorted(set(super().__dir__() + list(dir(self.result))))