控制sky q box的python库
pyskyq的Python项目详细描述
用于控制skyq框的python库。
简介
这个库旨在最终提供对Sky Q Set Top Box的api访问。它 仅在Python3.7上测试,并使用此版本提供的较新异步支持 Python。
它使用excellenttrio异步库,因此建议您了解这一点。
这仍然是一项正在进行的工作,但这里的工作是可行的。
安装
要安装:
pip install pyskyq
用法
目前,该库提供了三种主要功能。
对盒子上的状态变化做出反应
下面是如何设置异步上下文管理器,该管理器可用于对 更改了框中的事件..
frompyskyqimportget_statusasyncdefreport_box_online():"""Report whether the SkyQ is online or not."""# pylint: disable=not-async-context-managerasyncwithget_status('skyq')asstat:whileTrue:ifstat.online:print('The SkyQ Box is Online ')else:print('The SkyQ Box is Offline')awaittrio.sleep(1)try:print("Type Ctrl-C to exit.")trio.run(report_box_online)exceptKeyboardInterrupt:raiseSystemExit(0)
加载和查询信道数据
要访问通道数据,需要初始化EPG对象。一次 完成后,需要使用 EPG.load_skyq_channel_data()方法。
要访问此数据,请使用EPG.get_channel()。参见方法的文档 获取可用属性的完整列表。
frompyskyqimportEPGasyncdefmain():"""Run main routine, allowing arguments to be passed."""pargs=parse_args(args)epg=EPG('skyq')# replace with hostname / IP of your Sky boxawaitepg.load_skyq_channel_data()# load channel listing from Box.all_72_hour=XMLTVListing('http://www.xmltv.co.uk/feed/6715')asyncwithtrio.open_nursery()asnursery:nursery.start_soon(all_72_hour.fetch)epg.apply_XMLTVListing(all_72_hour)print('Channel Description from the SkyQ Box:')print(epg.get_channel_by_sid(2002).desc)print('Channel XMLTV ID from the XMLTV Feed:')print(epg.get_channel_by_sid(2002).xmltv_id)print('Channel Logo URL from the XMLTV Feed:')print(epg.get_channel_by_sid(2002).xmltv_icon_url)if__name__=="__main__":trio.run(main)
贡献
欢迎捐款。请在GitLabnot github上分叉项目 在那里提出问题和合并请求。
学分
代码和想法来源:
- https://github.com/dalhundal/sky-remote
- https://gladdy.uk/blog/2017/03/13/skyq-upnp-rest-and-websocket-api-interfaces/
感谢这些个人的贡献。