-
Notifications
You must be signed in to change notification settings - Fork 0
/
remote.py
46 lines (40 loc) · 987 Bytes
/
remote.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from pyxbmc import xbmc
import argparse
import sys
import pprint
commands = {
"play": "play",
"pause": "pause",
"stop": "stop",
"left": "nav_left",
"right": "nav_right",
"up": "nav_up",
"down": "nav_down",
"back": "nav_back",
"select": "nav_select",
"menu": "nav_menu",
"osd": "nav_show_osd",
"ping": "ping"
}
parser = argparse.ArgumentParser(description="remote.py")
parser.add_argument("host",
help="The XBMC host and port")
parser.add_argument("command",
help="The command to send",
choices=sorted(commands.keys()))
args = parser.parse_args()
connection = xbmc.XBMC(args.host)
r = getattr(connection, commands[args.command])()
worked = False
if r == True:
worked = True
elif r == False or r is None:
worked = False
elif "result" in r and r["result"] == "OK":
worked = True
elif "result" in r and r["result"] == "pong":
worked = True
if worked:
print("Worked")
else:
print("Failed")