pyatv: Apple TV Remote Control Library — pyatv 0.3.4 documentation

# pyatv: Apple TV Remote Control Library

## Features

- Automatic discovery of devices (zeroconf/Bonjour)
- Push updates
- Remote control pairing
- AirPlay stream URL (including tvOS 10.2+)
- Playback controls (play, pause, next, stop, etc.)
- Navigation controls (select, menu, top_menu, arrow keys)
- Fetch artwork in PNG format
- Currently playing (e.g. title, artist, album, total time, etc.)
- Change media position
- Shuffle and repeat

## Library Installation

Use pip:

    $ pip install pyatv

NOTE: You need some system packages, run this on debian or similar:

> $ sudo apt-get install build-essential libssl-dev libffi-dev python-dev

## Getting Started

Connecting to the first automatically discovered device:

    import asyncio
    from pyatv import helpers

    @asyncio.coroutine
    def print_what_is_playing(atv):
        playing = yield from atv.metadata.playing()
        print('Currently playing:')
        print(playing)

    helpers.auto_connect(print_what_is_playing)

Connecting to a specific device:

    import pyatv
    import asyncio

    NAME = 'My Apple TV'
    ADDRESS = '10.0.10.22'
    LOGIN_ID = '00000000-1111-2222-3333-444444444444'
    DETAILS = pyatv.AppleTVDevice(NAME, ADDRESS, LOGIN_ID)

    @asyncio.coroutine
    def print_what_is_playing(loop, details):
        print('Connecting to {}'.format(details.address))
        atv = pyatv.connect_to_apple_tv(details, loop)

        try:
            playing = yield from atv.metadata.playing()
            print('Currently playing:')
            print(playing)
        except:
            yield from atv.logout()

    loop = asyncio.get_event_loop()
    loop.run_until_complete(print_what_is_playing(loop, DETAILS))

What is LOGIN_ID and where to find it? See this page.

## Dependencies

- python>=3.4.2
- zeroconf>=0.17.7
- aiohttp>=1.3.5
- cryptography>=1.8.1
- curve25519-donna>=1.3, <2
- ed25519>=1.4, <2
- srptools>=0.1.1

## Contributing

If you want to contribute, see developing for more information.

## Authors and License

`pyatv` is mainly written by Pierre Ståhl and is availble under the MIT license. You may freely modify and redistribute this package under that license.

If you do make changes, feel free to send a pull request on GitHub.

## Contents

Contents:

- Protocol
  - DAAP and DMAP
  - Supported Requests
  - References
- Finding Devices
  - No home sharing
  - Code Example
  - Finding a single device
- Pairing with a device
  - How does it work
  - Code Example: Pairing
  - References
- Connecting
  - Custom aiohttp session
  - Code Example: Auto discovery
  - Code Example: Manual details
- Controlling a device
  - Performing a command
  - Commands with arguments
- Retrieving metadata
  - What is currently playing
  - Artwork
  - Device ID
  - Hash
  - Push updates
- AirPlay Support
  - Device Authentication
  - Playing media
  - References
- API
  - Module contents
  - Submodules
  - pyatv.const module
  - pyatv.exceptions module
  - pyatv.helpers module
  - pyatv.interface module
- Reference application: atvremote
  - Discovering devices
  - Pairing with a device
  - Specifying a device
  - Push updates
  - AirPlay Device Authentication
  - Working with commands
  - Logging and debugging
- Developing pyatv
  - Development environment
  - Running the tests
  - Linting
  - Requirements for pull requests
- Testing
  - Unit Testing
  - Functional Testing
- Troubleshooting
  - Scanning does not find any devices
- FAQ
  - General Questions
  - Technical Questions

# Indices and tables

- Index
- Module Index
- Search Page