控制sky q box的python库

pyskyq的Python项目详细描述


Build Statusdocspypipythonlicense

用于控制skyq框的python库。

简介

这个库旨在最终提供对Sky Q Set Top Box的api访问。它 仅在Python3.7上测试,并使用此版本提供的较新异步支持 Python。

它使用excellenttrio异步库,因此建议您了解这一点。

这仍然是一项正在进行的工作,但这里的工作是可行的。

安装

要安装:

pip install pyskyq

用法

目前,该库提供了三种主要功能。

按遥控器上的按钮

下面是如何模拟在skyq遥控器上按下按钮。参见文档 对于类remotecommands对于可以按下的各种按钮。

frompyskyqimportRemote,RCMDpress_remote('skyq',RCMD.play)

对盒子上的状态变化做出反应

下面是如何设置异步上下文管理器,该管理器可用于对 更改了框中的事件..

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上分叉项目 在那里提出问题和合并请求。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java为什么在公共类和main()方法中总是一个变量总是需要是“final”   jspjava。lang.NullPointerException:永远不会执行servlet?   Java编译器:“级联”ifs的优化和最佳实践?   使用GenericRecords时,java Flink Avro序列化显示“不可序列化”错误   java从war文件中读取清单文件会在tomcat 7中产生错误   java Android位图压缩不足,导致OutOfMemoryError崩溃   Struts 2框架中java Jasper报告序列号的生成   文件javajar路径扫描器   在哪里可以找到Java中的文档向量和哈希表?   java纹理坐标不能正常工作?   Java:按“Q”键后终止while循环   Java中的双大于号(>>)?   c#为流畅的界面生成器添加分支   java如何确定线程池中的线程数