-
Notifications
You must be signed in to change notification settings - Fork 25
/
actions.py
413 lines (386 loc) · 16 KB
/
actions.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# -*- coding: utf-8 -*-
#
# Copyright (C) 2014 Thomas Amland
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
_actions = [
["Navigation", [
"left" , "Move Left",
"right" , "Move Right",
"up" , "Move Up",
"down" , "Move Down",
"pageup" , "Page Up",
"pagedown" , "Page Down",
"select" , "Select Item",
"highlight" , "Highlight Item",
#"parentdir" , "NAV_BACK", # backward compatibility
#"close" , "NAV_BACK", # backwards compatibility
"parentfolder" , "Parent Directory",
"back" , "Back",
"previousmenu" , "Previous Menu",
"info" , "Show Info",
"contextmenu" , "Context Menu",
"menu" , "Menu",
"firstpage" , "First Page",
"lastpage" , "Last Page",
"nextletter" , "Next Letter",
"prevletter" , "Previous Letter",
]],
["Playback", [
"play" , "Play",
"pause" , "Pause",
"playpause" , "Play/Pause",
"stop" , "Stop",
"skipnext" , "Next",
"skipprevious" , "Previous",
"fastforward" , "Fast Forward",
"rewind" , "Rewind",
"smallstepback" , "Small Step Back",
"stepforward" , "Step Forward",
"stepback" , "Step Back",
"bigstepforward" , "Big Step Forward",
"bigstepback" , "Big Step Back",
"chapterorbigstepforward", "Next Chapter or Big Step Forward",
"chapterorbigstepBack" , "Previous Chapter or Big Step Back",
"osd" , "Show OSD",
"showtime" , "Show current play time",
"playlist" , "Show Playlist",
"fullscreen" , "Toggle Fullscreen",
"aspectratio" , "Change Aspect Ratio",
"showvideomenu" , "Go to DVD Video Menu",
"playercontrol(repeat)" , "Toggle Repeat",
"playercontrol(repeatone)", "Repeat One",
"playercontrol(repeatall)", "Repeat All",
"playercontrol(repeatoff)", "Repeat Off",
"playercontrol(random)" , "Toggle Random",
"playercontrol(randomon)" , "Random On",
"playercontrol(randomoff)", "Random Off",
"createbookmark" , "Create Bookmark",
"createepisodebookmark" , "Create Episode Bookmark",
"togglestereomode" , "Toggle 3D/Stereoscopic mode",
"switchplayer" , "Switch Player",
]],
["Audio", [
"mute" , "Mute",
"volumeup" , "Volume Up",
"volumedown" , "Volume Down",
"audionextlanguage" , "Next Language",
"audiodelay" , "Delay",
"audiodelayminus" , "Delay Minus",
"audiodelayplus" , "Delay Plus",
"audiotoggledigital", "Toggle Digital/Analog",
]],
["Pictures", [
"nextpicture" , "Next Picture",
"previouspicture" , "Previous Picture",
"rotate" , "Rotate Picture",
"rotateccw" , "Rotate Picture CCW",
"zoomout" , "Zoom Out",
"zoomin" , "Zoom In ",
"zoomnormal" , "Zoom level Normal",
"zoomlevel1" , "Zoom level 1",
"zoomlevel2" , "Zoom level 2",
"zoomlevel3" , "Zoom level 3",
"zoomlevel4" , "Zoom level 4",
"zoomlevel5" , "Zoom level 5",
"zoomlevel6" , "Zoom level 6",
"zoomlevel7" , "Zoom level 7",
"zoomlevel8" , "Zoom level 8",
"zoomlevel9" , "Zoom level 9",
]],
["Subtitle", [
"showsubtitles" , "Show Subtitles",
"nextsubtitle" , "Next Subtitle",
"subtitledelay" , "Delay",
"subtitledelayminus", "Delay Minus",
"subtitledelayplus" , "Delay Plus",
"subtitlealign" , "Align",
#"subtitleshiftup" , "SUBTITLE_VSHIFT_UP", #?
#"subtitleshiftdown" , "SUBTITLE_VSHIFT_DOWN", #?
]],
["PVR", [
"channelup" , "Channel Up",
"channeldown" , "Channel Down",
"previouschannelgroup" , "Previous channel group",
"nextchannelgroup" , "Next channel group",
"record" , "Record",
]],
["Item Actions", [
"queue" , "Queue item",
"delete" , "Delete item",
"copy" , "Copy item",
"move" , "Move item",
"moveitemup" , "Move item up",
"moveitemdown" , "Move item down",
"rename" , "Rename item",
"scanitem" , "Scan item",
"togglewatched" , "Toggle watched status",
#"increaserating" , "INCREASE_RATING", #unused
#"decreaserating" , "DECREASE_RATING", #unused
]],
["System", [
"togglefullscreen" , "Toggle Fullscreen",
"minimize" , "Minimize",
"shutdown" , "Shutdown",
"reboot" , "Reboot",
"hibernate" , "Hibernate",
"suspend" , "Suspend",
"restartapp" , "Restart XBMC",
"system.logoff" , "Log off",
"quit" , "Quit XBMC",
]],
["Virtual Keyboard", [
"enter" , "Enter",
"shift" , "Shift",
"symbols" , "Symbols",
"backspace" , "Backspace ",
"number0" , "0",
"number1" , "1",
"number2" , "2",
"number3" , "3",
"number4" , "4",
"number5" , "5",
"number6" , "6",
"number7" , "7",
"number8" , "8",
"number9" , "9",
"red" , "Teletext Red",
"green" , "Teletext Green",
"yellow" , "Teletext Yellow",
"blue" , "Teletext Blue",
]],
["Other", [
"updatelibrary(video)", "Update Video Library",
"updatelibrary(music)", "Update Music Library",
"cleanlibrary(video)", "Clean Video Library",
"cleanlibrary(music)", "Clean Music Library",
"codecinfo" , "Show codec info",
"screenshot" , "Take screenshot",
"reloadkeymaps" , "Reload keymaps",
"increasepar" , "Increase PAR",
"decreasepar" , "Decrease PAR",
"nextresolution" , "Change resolution",
"nextcalibration" , "Next calibration",
"resetcalibration" , "Reset calibration",
"showpreset" , "Show current visualisation preset",
"presetlist" , "Show visualisation preset list",
"nextpreset" , "Next visualisation preset",
"previouspreset" , "Previous visualisation preset",
"lockpreset" , "Lock current visualisation preset ",
"randompreset" , "Switch to a new random preset",
]],
#["Analog", [
# "scrollup" , "SCROLL_UP",
# "scrolldown" , "SCROLL_DOWN",
# "cursorleft" , "CURSOR_LEFT",
# "cursorright" , "CURSOR_RIGHT",
# "analogmove" , "ANALOG_MOVE",
# "analogfastforward" , "ANALOG_FORWARD",
# "analogrewind" , "ANALOG_REWIND",
# "analogseekforward" , "ANALOG_SEEK_FORWARD",
# "analogseekback" , "ANALOG_SEEK_BACK",
# "leftclick" , "MOUSE_LEFT_CLICK",
# "rightclick" , "MOUSE_RIGHT_CLICK",
# "middleclick" , "MOUSE_MIDDLE_CLICK",
# "doubleclick" , "MOUSE_DOUBLE_CLICK",
# "wheelup" , "MOUSE_WHEEL_UP",
# "wheeldown" , "MOUSE_WHEEL_DOWN",
# "mousedrag" , "MOUSE_DRAG",
# "mousemove" , "MOUSE_MOVE",
#]]
#"verticalshiftup" , "VSHIFT_UP",
#"verticalshiftdown" , "VSHIFT_DOWN",
#"increasevisrating" , "VIS_RATE_PRESET_PLUS",
#"decreasevisrating" , "VIS_RATE_PRESET_MINUS",
#"nextscene" , "NEXT_SCENE",
#"previousscene" , "PREV_SCENE",
#"jumpsms2" , "JUMP_SMS2",
#"jumpsms3" , "JUMP_SMS3",
#"jumpsms4" , "JUMP_SMS4",
#"jumpsms5" , "JUMP_SMS5",
#"jumpsms6" , "JUMP_SMS6",
#"jumpsms7" , "JUMP_SMS7",
#"jumpsms8" , "JUMP_SMS8",
#"jumpsms9" , "JUMP_SMS9",
#"filter" , "FILTER",
#"filterclear" , "FILTER_CLEAR",
#"filtersms2" , "FILTER_SMS2",
#"filtersms3" , "FILTER_SMS3",
#"filtersms4" , "FILTER_SMS4",
#"filtersms5" , "FILTER_SMS5",
#"filtersms6" , "FILTER_SMS6",
#"filtersms7" , "FILTER_SMS7",
#"filtersms8" , "FILTER_SMS8",
#"filtersms9" , "FILTER_SMS9",
#"guiprofile" , "GUIPROFILE_BEGIN",
#"volampup" , "VOLAMP_UP",
#"volampdown" , "VOLAMP_DOWN",
#"mplayerosd" , "SHOW_MPLAYER_OSD", #?
#"hidesubmenu" , "OSD_HIDESUBMENU", #depricated
#"osdleft" , "OSD_SHOW_LEFT",
#"osdright" , "OSD_SHOW_RIGHT",
#"osdup" , "OSD_SHOW_UP",
#"osddown" , "OSD_SHOW_DOWN",
#"osdselect" , "OSD_SHOW_SELECT",
#"osdvalueplus" , "OSD_SHOW_VALUE_PLUS",
#"osdvalueminus" , "OSD_SHOW_VALUE_MIN",
]
_activate_window = [
"settings" , "Settings",
"picturessettings" , "Pictures Settings",
"programssettings" , "Programs Settings",
"weathersettings" , "Weather Settings",
"musicsettings" , "Music Settings",
"systemsettings" , "System Settings",
"videossettings" , "Videos Settings",
"servicesettings" , "Service Settings",
"appearancesettings" , "Appearance Settings",
"pvrsettings" , "PVR Settings",
"skinsettings" , "Skin Settings",
"addonbrowser" , "Addon Browser",
"addonsettings" , "Addon Settings",
"profilesettings" , "Profile Settings",
"locksettings" , "Lock Settings",
"contentsettings" , "Content Settings",
"profiles" , "Profiles",
"systeminfo" , "System info",
"testpattern" , "Test Pattern",
"screencalibration" , "Screen Calibration",
"loginscreen" , "Login Screen",
"filebrowser" , "Filebrowser",
"networksetup" , "Networksetup",
"accesspoints" , "Access Points",
"mediasource" , "Mediasource Dialog",
"startwindow" , "Start",
"favourites" , "Favourites",
"contextmenu" , "Context Menu",
"peripherals" , "Peripheral manager",
"peripheralsettings" , "Peripherals settings",
"mediafilter" , "Media filter",
"visualisationpresetlist" , "Vis. Preset List",
"filestackingdialog" , "Filestacking Dialog",
"smartplaylisteditor" , "Smart Playlist Editor",
"smartplaylistrule" , "Smart Playlist Rule",
"shutdownmenu" , "Shutdown Menu",
"fullscreeninfo" , "Fullscreen Info",
"subtitlesearch" , "Subtitle Search",
"weather" , "Weather",
"screensaver" , "Screensaver",
"pictureinfo" , "Picture Info",
"addoninformation" , "Addon Info",
"musicplaylist" , "Music Playlist",
"musicfiles" , "Music Files",
"musiclibrary" , "Music Library",
"musicplaylisteditor" , "Music Playlist Editor",
"musicinformation" , "Music Info",
"musicoverlay" , "Music Overlay",
"songinformation" , "Song Info",
"karaoke" , "Karaoke Lyrics",
"karaokeselector" , "Karaoke Song Selector",
"karaokelargeselector" , "Karaoke Selector",
"movieinformation" , "Video Info",
"videofiles" , "Video Files",
"videooverlay" , "Video Overlay",
"videomenu" , "Video Menu",
"videoosd" , "Video OSD",
"videotimeseek" , "Video Time Seek",
"videobookmarks" , "Video Bookmarks",
"videoplaylist" , "Video Playlist",
"pvrguideinfo" , "PVR Guide Info",
"pvrrecordinginfo" , "PVR Recording Info",
"pvrtimersetting" , "PVR Timer Setting",
"pvrgroupmanager" , "PVR Group Manager",
"pvrchannelmanager" , "PVR Channel Manager",
"pvrguidesearch" , "PVR Guide Search",
"pvrchannelscan" , "PVR Channel Scan",
"pvrupdateprogress" , "PVR Update Progress",
"pvrosdchannels" , "PVR OSD Channels",
"pvrosdguide" , "PVR OSD Guide",
"pvrosddirector" , "PVR OSD Director",
"pvrosdcutter" , "PVR OSD Cutter",
"tvchannels" , "TV Channels",
"tvrecordings" , "TV Recordings",
"tvguide" , "TV Guide",
"tvtimers" , "TV Timers",
"tvsearch" , "TV Search",
"radiochannels" , "Radio Channels",
"radiorecordings" , "Radio Recordings",
"radioguide" , "Radio Guide",
"radiotimers " , "Radio Timers",
"radiosearch" , "Radio Search",
"videos,movies" , "Movies",
"videos,movietitles" , "Movie Titles",
"videos,tvshows " , "TV Shows",
"videos,tvshowtitles " , "TV Show Titles",
"videos,musicvideos" , "Music Videos",
"videos,recentlyaddedmovies" , "Recently Added Movies",
"videos,recentlyaddedepisodes" , "Recently Added Episodes",
"videos,recentlyaddedmusicvideos" , "Recently Added Music Videos"
]
_windows = [
"global" , "Global",
"fullscreenvideo" , "Fullscreen Video",
"fullscreenlivetv" , "Fullscreen Live TV",
"home" , "Home",
"programs" , "Programs",
"videos" , "Videos",
"music" , "Music",
"pictures" , "Pictures",
"pvr" , "PVR",
"filemanager" , "Filemanager",
"pvrosdteletext" , "OSD Teletext",
"virtualkeyboard" , "Virtual Keyboard",
"playercontrols" , "Player Controls",
"seekbar" , "Seek bar",
"musicosd" , "Music OSD",
"osdvideosettings" , "Video OSD Settings",
"osdaudiosettings" , "Audio OSD Settings",
"visualisation" , "Visualisation",
"slideshow" , "Slideshow"
]
from collections_backport import OrderedDict
from utils import rpc
import xbmc
def action_dict(actions, action_names):
"""Create dict of action->name sorted by name"""
return OrderedDict(sorted(zip(actions, action_names), key=lambda t: t[1]))
def _get_run_addon_actions():
addons = []
addon_types = ['xbmc.python.pluginsource', 'xbmc.python.script']
for addon_type in addon_types:
response = rpc('Addons.GetAddons', type=addon_type, properties=['name', 'enabled'])
res = response['result']
if 'addons' in res:
addons.extend([a for a in res['addons'] if a['enabled']])
actions = ['runaddon(%s)' % a['addonid'] for a in addons]
names = ['Launch %s' % a['name'] for a in addons]
return action_dict(actions, names)
def _get_activate_window_actions():
all_windows = _activate_window + _windows[2:] #don't include "global"
actions = ["activatewindow(%s)" % w_id for w_id in all_windows[0::2]]
names = ["Open %s" % w for w in all_windows[1::2]]
return action_dict(actions, names)
def _get_action_dict():
""" Map actions to 'category name'->'action id'->'action name' dict"""
d = OrderedDict()
for elem in _actions:
category = elem[0]
actions = elem[1][0::2]
names = elem[1][1::2]
d[category] = OrderedDict(zip(actions, names))
d["Windows"] = _get_activate_window_actions()
d["Add-ons"] = _get_run_addon_actions()
return d
ACTIONS = _get_action_dict()
WINDOWS = OrderedDict(zip(_windows[0::2], _windows[1::2]))