Skip to content

CCecilia/Roku-Scanner

Repository files navigation

Roku-Scanner 1.0.4

Scans LAN for any connected Roku's and returns available device information.

Prerequisites

Installation

pip3 install roku-scanner

Usage

CLI

python3 -m roku_scanner

Options

Device data output in JSON.

python3 -m roku_scanner --json

Pretty print JSON. Can only be used with json flag.

python3 -m roku_scanner --json --pretty

Increasing timeout on discovery search time. Default is 2 secs. It's advised to use a time less than 10 secs.

python3 -m roku_scanner --timeout 5

Change search target to target all devices and not only Roku devices. This will result in non roku devices being added to discovery data. As now(1.0.4) only discovery data is returned for non Roku devices.

python3 -m roku_scanner --search-target-all

Verbose Logging

python3 -m roku_scanner --verbose

Excluding data from output.

python3 -m roku_scanner --exclude device-info

Exclusion Options

  • device-info
  • apps
  • active-app
  • media-player

Output Examples

Import Examples

Discovery and device data fetching

Discovering Roku's and fetching their device data.

from roku_scanner.scanner import Scanner
from roku_scanner.roku import Roku

scanner = Scanner()
scanner.discover()

found_devices = scanner.discovered_devices

for device in found_devices:
    roku_location = device.get('LOCATION')
    roku = Roku(location=roku_location, discovery_data=device)
    roku.fetch_data()
    detailed_device_data = roku.data
    print(detailed_device_data)

JSON

Getting device data in JSON.

from roku_scanner.scanner import Scanner
from roku_scanner.roku import Roku

scanner = Scanner()
scanner.discover()

found_devices = scanner.discovered_devices

for device in found_devices:
    roku_location = device.get('LOCATION')
    roku = Roku(location=roku_location, discovery_data=device)
    roku.fetch_data()
    json_data = roku.as_json()

XML

Getting device data as XML.

from roku_scanner.scanner import Scanner
from roku_scanner.roku import Roku

scanner = Scanner()
scanner.discover()

found_devices = scanner.discovered_devices

for device in found_devices:
    roku_location = device.get('LOCATION')
    roku = Roku(location=roku_location, discovery_data=device)
    roku.fetch_data()
    xml_data = roku.as_xml()

Search Target in Scanner

Changes search target for scanner to search for all devices, this will return Roku devices and any other using UPnP

from roku_scanner.scanner import Scanner

scanner = Scanner(search_target='upnp:rootdevice')
scanner.discover()
all_types_of_devices = scanner.discovered_devices

Testing

pytest tests/

Code Standard

Roku-Scanner follows PEP 8 standard.

Versioning

Roku-Scanner uses SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Christian Cecilia - Initial work

See also the list of contributors who participated in this project.