def add_newplugin(self): """ Get list of available plugins and allow user to choose which to views to add """ method = "Addons.GetAddons" properties = ["name", "thumbnail"] params_a = {"type": "xbmc.addon.video", "properties": properties} params_b = {"type": "xbmc.addon.audio", "properties": properties} params_c = {"type": "xbmc.addon.image", "properties": properties} response_a = utils.get_jsonrpc(method, params_a).get('result', {}).get('addons') or [] response_b = utils.get_jsonrpc(method, params_b).get('result', {}).get('addons') or [] response_c = utils.get_jsonrpc(method, params_c).get('result', {}).get('addons') or [] response = response_a + response_b + response_c dialog_list, dialog_ids = [], [] for i in response: dialog_item = xbmcgui.ListItem(label=i.get('name'), label2='{}'.format(i.get('addonid'))) dialog_item.setArt({'icon': i.get('thumbnail'), 'thumb': i.get('thumbnail')}) dialog_list.append(dialog_item) dialog_ids.append(i.get('addonid')) idx = xbmcgui.Dialog().select(ADDON.getLocalizedString(32009), dialog_list, useDetails=True) if idx == -1: return pluginname = dialog_ids[idx] contentids = [i for i in sorted(self.meta.get('rules', {}))] idx = xbmcgui.Dialog().select(ADDON.getLocalizedString(32010), contentids) if idx == -1: return self.add_newplugin() # Go back to previous dialog contentid = contentids[idx] return self.add_pluginview(pluginname=pluginname, contentid=contentid)
def run(self): while not self.kodimonitor.abortRequested() and not self.exit and self.timeout > 0: self.kodimonitor.waitForAbort(self.poll) self.timeout -= self.poll if xbmc.getCondVisibility("Window.IsVisible(DialogKeyboard.xml)"): utils.get_jsonrpc("Input.SendText", {"text": self.text, "done": True}) self.exit = True
def run(self): while not xbmc.Monitor().abortRequested() and not self.exit and self.timeout > 0: xbmc.Monitor().waitForAbort(self.poll) self.timeout -= self.poll if self.text and xbmc.getCondVisibility("Window.IsVisible(DialogKeyboard.xml)"): utils.get_jsonrpc("Input.SendText", {"text": self.text, "done": True}) self.exit = True elif self.action and xbmc.getCondVisibility("Window.IsVisible(DialogSelect.xml) | Window.IsVisible(DialogConfirm.xml)"): utils.get_jsonrpc(self.action) self.exit = True
def set_dbidwatched_rpc(self, dbid=None, dbtype=None): if not dbid or not dbtype: return method = "VideoLibrary.Get{}Details".format(dbtype.capitalize()) params = {"{}id".format(dbtype): dbid, "properties": ["playcount"]} json_info = utils.get_jsonrpc(method=method, params=params) playcount = json_info.get('result', {}).get('{}details'.format(dbtype), {}).get('playcount', 0) playcount = utils.try_parse_int(playcount) + 1 method = "VideoLibrary.Set{}Details".format(dbtype.capitalize()) params = {"{}id".format(dbtype): dbid, "playcount": playcount} return utils.get_jsonrpc(method=method, params=params)
def kodi_setting(self): method = "Settings.GetSettingValue" params = {"setting": self.params.get('kodi_setting')} response = utils.get_jsonrpc(method, params) self.home.setProperty( self.params.get('property', 'TMDbHelper.KodiSetting'), u'{}'.format(response.get('result', {}).get('value', '')))
def get_addondetails(self, addonid=None, prop=None): """ Get details of a plugin """ if not addonid or not prop: return method = "Addons.GetAddonDetails" params = {"addonid": addonid, "properties": [prop]} return utils.get_jsonrpc(method, params).get('result', {}).get('addon', {}).get(prop)
def get_directory(self, url): method = "Files.GetDirectory" params = { "directory": url, "media": "files", "properties": [ "title", "year", "originaltitle", "imdbnumber", "premiered", "streamdetails", "size", "firstaired", "season", "episode", "showtitle", "file", "tvshowid", "thumbnail" ] } response = utils.get_jsonrpc(method, params) return response.get('result', {}).get('files', [{}]) or [{}]
def get_library(self, dbtype=None, properties=None, filterr=None): if dbtype == "movie": method = "VideoLibrary.GetMovies" elif dbtype == "tvshow": method = "VideoLibrary.GetTVShows" elif dbtype == "episode": method = "VideoLibrary.GetEpisodes" else: return params = {"properties": properties or ["title"]} if filterr: params['filter'] = filterr response = utils.get_jsonrpc(method, params) return response.get('result')
def get_item_details(self, dbid=None, method=None, key=None, properties=None): if not dbid or not method or not key or not properties: return {} param_name = "{0}id".format(key) params = { param_name: utils.try_parse_int(dbid), "properties": properties } details = utils.get_jsonrpc(method, params) if not details or not isinstance(details, dict): return {} details = details.get('result', {}).get('{0}details'.format(key)) return self.get_niceitem(details, key)
def get_database(self, dbtype=None, tvshowid=None): if not dbtype: return if dbtype == "movie": method = "VideoLibrary.GetMovies" params = { "properties": [ "title", "imdbnumber", "originaltitle", "uniqueid", "year", "file" ] } if dbtype == "tvshow": method = "VideoLibrary.GetTVShows" params = { "properties": ["title", "imdbnumber", "originaltitle", "uniqueid", "year"] } if dbtype == "episode": method = "VideoLibrary.GetEpisodes" params = { "tvshowid": tvshowid, "properties": ["title", "showtitle", "season", "episode", "file"] } dbid_name = '{0}id'.format(dbtype) key_to_get = '{0}s'.format(dbtype) response = utils.get_jsonrpc(method, params) self.dbtype = dbtype self.database = [{ 'imdb_id': item.get('uniqueid', {}).get('imdb'), 'tmdb_id': item.get('uniqueid', {}).get('tmdb'), 'tvdb_id': item.get('uniqueid', {}).get('tvdb'), 'dbid': item.get(dbid_name), 'title': item.get('title'), 'originaltitle': item.get('originaltitle'), 'showtitle': item.get('showtitle'), 'season': item.get('season'), 'episode': item.get('episode'), 'year': item.get('year'), 'file': item.get('file') } for item in response.get('result', {}).get(key_to_get, [])]