Module pyatv.helpers

Various helper methods.

Functions

async def auto_connect(handler: Callable[[AppleTV], None], timeout: int = 5, not_found: Callable[[], None] = None, loop: Optional[asyncio.events.AbstractEventLoop] = None) -> None

Connect to first discovered device.

This is a convenience method that auto discovers devices, picks the first device found, connects to it and passes it to a user provided handler. An optional error handler can be provided that is called when no device was found. Very inflexible in many cases, but can be handys sometimes when trying things.

Note: both handler and not_found must be coroutines

def get_unique_id(service_type: str, service_name: str, properties: Mapping[str, str]) -> Optional[str]

Return unique identifier from a Zeroconf service.

service_type is the Zeroconf service type (e.g. _mediaremotetv._tcp.local), service_name name of the service (e.g. Office or Living Room) and properties all key-value properties belonging to the service.

The unique identifier is returned if available, otherwise None is returned.

async def is_streamable(filename: str) -> bool

Return if a file is streamable by pyatv.

This method will return if the file format of the given file is supported and streamable by pyatv. It will never raise an exception, e.g. because the file is missing or lack of permissions.