Module pyatv.helpers

Various helper methods.


async def auto_connect(handler: Callable[[AppleTV], None], timeout: int = 5, not_found: Optional[Callable[[], None]] = None, loop: Optional[] = 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.

def is_device_supported(conf: BaseConfig) -> bool

Return if pyatv supports this device.

This method will return False if all of its services are either PairingRequirement.Unsupported or PairingRequirement.Disabled. In all other cases it will return True. Do note that even if this method returns True, pairing (or that existing credentials are provided) might still be needed.

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.