diff --git a/addon.xml b/addon.xml index 67ab941a..7e9e9880 100644 --- a/addon.xml +++ b/addon.xml @@ -4,7 +4,7 @@ - + video audio image diff --git a/resources/lib/command_pipeline.py b/resources/lib/command_pipeline.py index 64bda2e4..6b889445 100644 --- a/resources/lib/command_pipeline.py +++ b/resources/lib/command_pipeline.py @@ -57,6 +57,8 @@ class Monitor_Window(Thread): elif value.startswith('CONTEXT_menu?'): queue.put('dummy?mode=context_menu&%s' % value.replace('CONTEXT_menu?', '')) + elif value.startswith('NAVIGATE'): + queue.put(value.replace('NAVIGATE-', '')) else: raise NotImplementedError('%s not implemented' % value) else: diff --git a/resources/lib/json_rpc.py b/resources/lib/json_rpc.py index 82a96b40..22501d51 100644 --- a/resources/lib/json_rpc.py +++ b/resources/lib/json_rpc.py @@ -496,3 +496,11 @@ def ping(): Pings the JSON RPC interface """ return JsonRPC('JSONRPC.Ping').execute() + + +def activate_window(window, parameters): + """ + Pass the parameters as str/unicode to open the corresponding window + """ + return JsonRPC('GUI.ActivateWindow').execute({'window': window, + 'parameters': [parameters]}) diff --git a/resources/lib/kodidb_functions.py b/resources/lib/kodidb_functions.py index bb90493c..7ed8d678 100644 --- a/resources/lib/kodidb_functions.py +++ b/resources/lib/kodidb_functions.py @@ -223,6 +223,24 @@ class KodiDBMethods(object): self.cursor.execute('DELETE FROM stacktimes WHERE idFile = ?', (file[0],)) + def show_id_from_path(self, path): + """ + Returns the idShow for path [unicode] or None + """ + self.cursor.execute('SELECT idPath FROM path WHERE strPath = ? LIMIT 1', + (path, )) + try: + path_id = self.cursor.fetchone()[0] + except TypeError: + return + query = 'SELECT idShow FROM tvshowlinkpath WHERE idPath = ? LIMIT 1' + self.cursor.execute(query, (path_id, )) + try: + show_id = self.cursor.fetchone()[0] + except TypeError: + show_id = None + return show_id + def remove_file(self, file_id): """ Removes the entry for file_id from the files table. Will also delete diff --git a/resources/lib/playback_starter.py b/resources/lib/playback_starter.py index 4bb2e0b4..7e8b01f8 100644 --- a/resources/lib/playback_starter.py +++ b/resources/lib/playback_starter.py @@ -7,6 +7,9 @@ from urlparse import parse_qsl import playback from context_entry import ContextMenu import state +import json_rpc as js +from pickler import pickle_me, Playback_Successful +import kodidb_functions as kodidb ############################################################################### @@ -20,7 +23,19 @@ class Playback_Starter(Thread): Processes new plays """ def triage(self, item): - _, params = item.split('?', 1) + try: + _, params = item.split('?', 1) + except ValueError: + # e.g. when plugin://...tvshows is called for entire season + with kodidb.GetKodiDB('video') as kodi_db: + show_id = kodi_db.show_id_from_path(item) + if show_id: + js.activate_window('videos', + 'videodb://tvshows/titles/%s' % show_id) + else: + LOG.error('Could not find tv show id for %s', item) + pickle_me(Playback_Successful()) + return params = dict(parse_qsl(params)) mode = params.get('mode') LOG.debug('Received mode: %s, params: %s', mode, params)