forked from stefan-sherwood/nvidia_shield_remote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnvidia_cli.py
executable file
·96 lines (88 loc) · 2.59 KB
/
nvidia_cli.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#! /usr/bin/env python
import sys
import nvidia
### Specify your Shield TV's IP & Port here to avoid needing to specify on CLI
### e.g. SHIELD_IP_PORT = "192.168.1.130:5555"
#SHIELD_IP_PORT = "192.168.1.130:5555"
SHIELD_IP_PORT = None
### Set up device
device = nvidia.shield( SHIELD_IP_PORT ) # device name (or IP address) and port
### Check if Shield's IP & Port are set
if not SHIELD_IP_PORT:
print("Please udpate nvidia_cli.py with your Shield's IP and port")
quit()
### Geneic help menu
def help_menu():
print(" -c <command>\n")
print(" -a <app>\n")
### If no parameters are specified, print error and exit
if (len(sys.argv)) == 1:
print("\nInvalid syntax, please use: python ./nvidia_cli.py -c <command> OR python ./nvidia_cly.py -a <app>\n")
help_menu()
quit()
### If one parameter specified, check if valid [-c, -a, or -h] and print help otherwise print error and exit
if (len(sys.argv)) == 2:
if sys.argv[1] == "-h" or sys.argv[1] == "-H":
print("\nExample: python ./nvidia_cli.py -c home OR python ./nvidia_cly.py -a netflix\n")
help_menu()
quit()
elif sys.argv[1] == "-c" or sys.argv[1] == "-C":
print("\nSyntax error, python ./nvidia_cli.py -c <command>\n")
print("""Valid command options:
'power'
'sleep'
'wake'
'home'
'back'
'search'
'up'
'down'
'left'
'right'
'center'
'volume up'
'volume down'
'rewind'
'ff'
'play/pause'
'previous'
'next'\n""")
quit()
elif sys.argv[1] == "-a" or sys.argv[1] == "-A":
print("\nSyntax error, python ./nvidia_cli.py -a <app>\n")
print("""Valid app options:
'hbo'
'prime'
'music'
'youtube'
'ted'
'hulu'
'netflix'
'youtubetv'
'disney'
'kodi'
'twitch'
'plex'
'cbs'
'pbs'
'amazonmusic'
'pandora'
'spotify'
'games'\n""")
quit()
else:
print("\nInvalid syntax, please use: python ./nvidia_cli.py -c <command> OR python ./nvidia_cly.py -a <app>\n")
help_menu()
quit()
### If three parameters specific, check if valid (-c or -a) and execute command or print error and exit
if (len(sys.argv)) == 3:
if sys.argv[1] == "-c" or sys.argv[1] == "-C":
nv_command = sys.argv[2]
device.press(nv_command)
elif sys.argv[1] == "-a" or sys.argv[1] == "-A":
nv_command = sys.argv[2]
device.launch(nv_command)
else:
print("\nInvalid syntax, please use: python ./nvidia_cli.py -c <command> OR python ./nvidia_cly.py -a <app>\n")
help_menu()
quit()