forked from ParitoshBh/KodiLinuxRemote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
toolbox.py
63 lines (53 loc) · 1.63 KB
/
toolbox.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
#!/usr/bin/env python3
import kodi
import settings
s = settings.Settings()
ss = s.GetSettings()
c = s.LoadSettings(ss.parser)
k = kodi.Kodi(**c)
k.Connect()
print()
print('### MOVIES ###')
print()
k.InvokeMethod('VideoLibrary.GetMovies')
print()
print('### MOVIE DETAILS ###')
print()
k.InvokeMethod('VideoLibrary.GetMovieDetails', {'movieid': 1, 'properties': ['title', 'year', 'tagline']})
print()
print('### ADDONS ###')
print()
k.InvokeMethod('Addons.GetAddons')
print()
print('### ADDON DETAILS ###')
print()
k.InvokeMethod('Addons.GetAddonDetails', {'addonid': 'plugin.video.youtube', 'properties': ['extrainfo']})
#k.InvokeMethod('Playlist.Add', {'playlistid': 0, 'item': {'file': ...}})
#k.InvokeMethod('Player.Open', {'item': {'file': 'plugin://plugin.video.youtube/?action=play_video&videoid=PSZuPt74e_c'}})
print()
print('### TYPES ###')
print()
i = k.InvokeMethod('JSONRPC.Introspect')
t = i['types']
for typ in t:
print(typ, t[typ])
print()
print('### METHODS ###')
print()
m = i['methods']
for method in m:
params = m[method]['params']
returns = m[method]['returns']
#print(method, params, '=>', returns)
#required_params = list(filter(lambda x: 'required' in x, params))
#print(method, required_params, '=>', returns)
paramsdocs = []
for param in params:
if '$ref' in param:
paramsdoc = '%s:%s' % (param['name'], param['$ref'])
elif 'type' in param:
paramsdoc = '%s:%s' % (param['name'], param['type'])
if 'required' in param:
paramsdoc += '*'
paramsdocs.append(paramsdoc)
print(method, '(' + ', '.join(paramsdocs) + ')', '=>', returns)