扫描LAN中的任何Roku设备并获取设备、应用程序、activeapp和播放器信息。
roku-scanner的Python项目详细描述
Roku扫描仪1.0.4
扫描LAN以查找任何连接的Roku并返回可用的设备信息。在
先决条件
- Python3.8+
- PIP-应该与python一起安装,如果不是here
安装
pip3 install roku-scanner
使用
CLI
^{pr2}$选项
JSON格式的设备数据输出。在
python3 -m roku_scanner --json
漂亮的打印JSON。只能与json标志一起使用。在
python3 -m roku_scanner --json --pretty
增加发现搜索时间的超时。默认值为2秒。建议使用少于10秒的时间。在
python3 -m roku_scanner --timeout 5
将搜索目标更改为针对所有设备,而不仅仅是Roku设备。这将导致将非roku设备添加到发现数据中。与现在一样(1.0.4),对于非Roku设备,只返回发现数据。在
python3 -m roku_scanner --search-target-all
详细日志记录
python3 -m roku_scanner --verbose
从输出中排除数据。在
python3 -m roku_scanner --exclude device-info
排除选项
- 设备信息
- 应用程序
- 活动应用程序
- 媒体播放器
输出示例
导入示例
发现和设备数据获取
发现Roku并获取他们的设备数据。在
fromroku_scanner.scannerimportScannerfromroku_scanner.rokuimportRokuscanner=Scanner()scanner.discover()found_devices=scanner.discovered_devicesfordeviceinfound_devices:roku_location=device.get('LOCATION')roku=Roku(location=roku_location,discovery_data=device)roku.fetch_data()detailed_device_data=roku.dataprint(detailed_device_data)
JSON
正在获取JSON格式的设备数据。在
fromroku_scanner.scannerimportScannerfromroku_scanner.rokuimportRokuscanner=Scanner()scanner.discover()found_devices=scanner.discovered_devicesfordeviceinfound_devices:roku_location=device.get('LOCATION')roku=Roku(location=roku_location,discovery_data=device)roku.fetch_data()json_data=roku.as_json()
XML
正在获取XML格式的设备数据。在
fromroku_scanner.scannerimportScannerfromroku_scanner.rokuimportRokuscanner=Scanner()scanner.discover()found_devices=scanner.discovered_devicesfordeviceinfound_devices:roku_location=device.get('LOCATION')roku=Roku(location=roku_location,discovery_data=device)roku.fetch_data()xml_data=roku.as_xml()
在扫描仪中搜索目标
将scanner的搜索目标更改为搜索所有设备,这将使用UPnP返回Roku设备和任何其他设备
fromroku_scanner.scannerimportScannerscanner=Scanner(search_target='upnp:rootdevice')scanner.discover()all_types_of_devices=scanner.discovered_devices
测试
pytest tests/
规范标准
Roku扫描仪遵循PEP 8标准。在
版本控制
Roku扫描仪使用SemVer进行版本控制。有关可用版本,请参阅tags on this repository。在
作者
- Christian Cecilia-初始工作
另请参阅参与本项目的contributors人员名单。在
- 项目
标签: