def items(self, url=None, data=None): self.subs = self.getSubs() if data is None and url is not None: data = self._json(url) result = [] if data is not None and data.get("menu"): for m in data["menu"]: try: if 'visible' in m and not sctop.getCondVisibility( m['visible']): continue if m['type'] == 'dir': item = self._dir_item(m) elif m['type'] == 'video': item = self._video_item(m) else: item = self._video_item(m) result.append(item) except Exception: pass if 'system' in data: self.system(data["system"]) else: result = [{'title': 'i failed', 'url': 'failed', 'type': 'dir'}] self.parent.endOfDirectory(succeeded=False) #util.debug('--------------------- DONE -----------------') return result
def items(self, url=None, data=None): self.subs = self.getSubs() if data is None and url is not None: data = self._json(url) result = [] if data is not None and data.get("menu"): for m in data["menu"]: try: if 'visible' in m and not sctop.getCondVisibility( m['visible']): # util.debug('[SC] item invisible %s' % m.title) continue if m['type'] == 'dir': # util.debug('[SC] dir item') item = self._dir_item(m) elif m['type'] == 'video': # util.debug('[SC] video item') item = self._video_item(m) else: # util.debug('[SC] default video item') item = self._video_item(m) # util.debug('[SC] pridavam polozku do vysledku') result.append(item) except Exception: util.debug('[SC] item error: %s' % str(traceback.format_exc())) pass try: skeys = sctop.win.getProperty('sc.filter._keys') if skeys != '': fremove = json.loads(skeys) if fremove is not None: for i in fremove: util.debug('[SC] remove filter %s' % str(i)) sctop.win.clearProperty('sc.filter.%s' % str(i)) sctop.win.clearProperty('sc.filter._keys') except: sctop.win.clearProperty('sc.filter._keys') pass if 'system' in data: self.system(data["system"]) if 'filter' in data: try: fkeys = [] for k, v in data['filter'].items(): if k != 'meta': fkeys.append(k) util.debug('[SC] filter %s: %s' % (str(k), str(v))) sctop.win.setProperty('sc.filter.%s' % str(k), str(v)) sctop.win.setProperty('sc.filter._keys', json.dumps(fkeys)) except: sctop.win.clearProperty('sc.filter._keys') util.debug('[SC] filter err %s' % str(traceback.format_exc())) else: result = [{'title': 'i failed', 'url': 'failed', 'type': 'dir'}] self.parent.endOfDirectory(succeeded=False) # util.debug('[SC] vraciam result: %s' % str(result)) return result
def onAction(self, action): '''Respond to Kodi actions e.g. exit''' if action.getId() in ( 9, 10, 92, 216, 247, 257, 275, 61467, 61448, ): self.close_dialog(True) # an item in the list is clicked if (action.getId() == 7 or action.getId() == 100) and getCondVisibility( "Control.HasFocus(3) | Control.HasFocus(6)"): if self.multiselect: # select/deselect the item item = self.list_control.getSelectedItem() if item.isSelected(): item.select(selected=False) else: item.select(selected=True) else: # no multiselect so just close the dialog (and return results) self.close_dialog()
def get_data_cached(self, url, post=False): try: url.index('/json/') self._oldapi() except Exception: pass headers = { 'X-UID': self.uid, 'X-LANG': self.tr['language'], 'X-VER': sctop.API_VERSION, 'Accept' : 'application/vnd.bbaron.kodi-plugin-v%s+json' % (sctop.API_VERSION), } url = self._url(url) code = None try: if post != False: util.debug("POST URL: %s %s" % (url, str(post))) (ret, code) = sctop.post(url, post, headers, "extend") self.handleHttpError(code) return ret util.info("GET x URL: %s" % url) ret = False if sctop.getSettingAsBool('usecache') is not False: util.debug("[SC] skusam cache") ret = self.cache.get(str(url)) if not ret: util.debug("[SC] url BEZ cache %s" % str(url)) (ret, code, info) = sctop.request(url, headers, "info") util.debug("[SC] code: %s %s" % (str(code), str(info))) self.handleHttpError(code, data=ret, i=info) if code == 200: ttl = datetime.timedelta(hours=2) try: util.debug("[SC] info: %s " % str(info) ) if 'x-ttl' in info: ttl = datetime.timedelta(seconds=int(info.get('x-ttl'))) util.debug("[SC] mame TTL: %s" % str(ttl)) except: pass try: self.cache.cache.set(str(url), ret, expiration=ttl) except: self.cache.set(str(url), ret) else: util.debug("[SC] url z cache %s" % str(url)) util.debug("[SC] return data") return ret except Exception as e: inet = sctop.getCondVisibility('System.InternetState') util.debug("[SC] inet scinema status: %s | %s" % (str(inet), str(e))) if inet is False or inet == 0: HANDLE = int(sys.argv[1]) xbmcplugin.endOfDirectory(HANDLE, succeeded=False) sctop.dialog.ok("internet", 'Skontrolujte pripojenie na internet') return False util.error('[SC] ERROR URL: --------- %s --------' % str(traceback.format_exc()) ) if code is None: sctop.dialog.ok("error", url) return False