三星智能电视WS-API包装
samsungtvws的Python项目详细描述
这个项目是一个库,用于通过TCP/IP连接远程控制三星电视。在
目前,它支持现代(2016年后)电视与以太网或Wi-Fi连接。他们应该都是TizenOs的模特。在
基于https://github.com/marysieek/samsung-tv-api工作
安装
$ pip3 install samsungtvws
或者
^{pr2}$或者。。。!在
$ git clone https://github.com/xchwarze/samsung-tv-ws-api $ pip3 install ./samsung-tv-ws-api
使用
importsysimportosimportloggingimportwakeonlansys.path.append('../')fromsamsungtvwsimportSamsungTVWS# Increase debug levellogging.basicConfig(level=logging.INFO)# Normal constructortv=SamsungTVWS('192.168.xxx.xxx')# Autosave token to file token_file=os.path.dirname(os.path.realpath(__file__))+'/tv-token.txt'tv=SamsungTVWS(host='192.168.xxx.xxx',port=8002,token_file=token_file)# Toggle powertv.shortcuts().power()# Power Onwakeonlan.send_magic_packet('CC:6E:A4:xx:xx:xx')# Open web in browsertv.open_browser('https://duckduckgo.com/')# View installed appsapps=tv.app_list()logging.info(apps)# Open app (Spotify)tv.run_app('3201606009684')# Get app status (Spotify)app=tv.rest_app_status('3201606009684')logging.info(app)# Open app (Spotify)app=tv.rest_app_run('3201606009684')logging.info(app)# Close app (Spotify)app=tv.rest_app_close('3201606009684')logging.info(app)# Install from official store (Spotify)app=tv.rest_app_install('3201606009684')logging.info(app)# Get device info (device name, model, supported features..)info=tv.rest_device_info()logging.info(info)
许可证
麻省理工学院
- 项目
标签: