def continue_cb(res): list_items = [] args = {} list_items.insert(0, PExit()) self.content_screen.startLoading() if not self.content_screen.refreshing: self.content_screen.save() else: self.content_screen.refreshing = False if self.is_search(item): parent_content = self.content_screen.getParent() if parent_content: parent_content['refresh'] = True content = { 'parent_it': item, 'lst_items': list_items, 'refresh': False, 'index': kwargs.get('position', 0) } self.content_screen.load(content) self.content_screen.stopLoading() self.content_screen.showList() self.content_screen.workingFinished()
def open_item_success_cb(result): list_items, screen_command, args = result list_items.insert(0, PExit()) if not list_items and screen_command is not None: if screen_command == 'refreshnow': self.content_screen.refreshList() else: if screen_command is not None: if screen_command == 'updatelist': self.content_screen.refreshing = True if not self.content_screen.refreshing: self.content_screen.save() else: self.content_screen.refreshing = False if self.is_search(item): parent_content = self.content_screen.getParent() if parent_content: parent_content['refresh'] = True content = {'parent_it':item, 'lst_items':list_items, 'refresh':False} self.content_screen.load(content) self.content_screen.stopLoading() self.content_screen.showList() self.content_screen.workingFinished()
def continue_cb_normal(res): if not list_items and screen_command is not None: self.content_screen.resolveCommand(screen_command, args) else: list_items.insert(0, PExit()) if screen_command is not None: self.content_screen.resolveCommand( screen_command, args) if not self.content_screen.refreshing: self.content_screen.save() else: self.content_screen.refreshing = False if self.is_search(item): parent_content = self.content_screen.getParent() if parent_content: parent_content['refresh'] = True content = { 'parent_it': item, 'lst_items': list_items, 'refresh': False, 'index': kwargs.get('position', 0) } self.content_screen.load(content) self.content_screen.stopLoading() self.content_screen.showList() self.content_screen.workingFinished()
def __init__(self, session, archivCZSK): provider = ArchivCZSKContentProvider( archivCZSK, os.path.join(settings.PLUGIN_PATH, 'categories')) provider.start() contentHandler = ArchivCZSKContentHandler(session, self, provider) defaultCategory = config.plugins.archivCZSK.defaultCategory.value categoryItem = categoryAddons = None if defaultCategory != 'categories': categoryItem = provider.get_content({'category': defaultCategory}) categoryAddons = provider.get_content( {'category_addons': defaultCategory}) categoryAddons is not None and categoryAddons.insert(0, PExit()) categoryItems = provider.get_content() BaseContentScreen.__init__(self, session, contentHandler, categoryItems) if categoryItem is not None and categoryAddons is not None: self.save() self.load({ 'lst_items': categoryAddons, 'parent_it': categoryItem, 'refresh': False }) self.ctx_items.append((_("Add Category"), None, self.addCategory)) self.provider = provider self.updateGUITimer = eTimer() self.updateGUITimer.callback.append(self.updateAddonGUI) # include DownloadList DownloadList.__init__(self) # include TipList TipBar.__init__(self, [self.CONTEXT_TIP], startOnShown=True) self.onUpdateGUI.append(self.changeAddon) self.onClose.append(self.__onClose) self["image"] = Pixmap() self["title"] = Label("") self["author"] = Label("") self["version"] = Label("") self["about"] = Label("") self["key_red"] = Label("") self["key_green"] = Label(_("Manager")) self["key_yellow"] = Label(_("Live streams")) self["key_blue"] = Label(_("Settings")) self["actions"] = ActionMap( ["archivCZSKActions"], { "ok": self.ok, "cancel": self.cancel, "up": self.up, "down": self.down, "blue": self.openSettings, "green": self.openAddonManagement, "yellow": self.showStreams, "menu": self.menu }, -2) # after layout show update item "GUI" - edit: shamann self.onLayoutFinish.append(self.updateAddonGUI)
def show_playlist(self, item): self.content_screen.save() list_items = [PExit()] list_items.extend(item.playlist[:]) content = {'parent_it':item, 'lst_items':list_items, 'refresh':False} self.content_screen.load(content)
def open_item_success_cb(result): def continue_cb(res): list_items.insert(0, PExit()) self.content_screen.resolveCommand(command, args) self.content_screen.stopLoading() self.open_video_addon(item.addon, list_items) list_items, command, args = result try: #client.add_operation("SHOW_MSG", {'msg': 'some text'}, # 'msgType': 'info|error|warning', #optional # 'msgTimeout': 10, #optional # 'canClose': True #optional # }) if command is not None: cmd = ("%s" % command).lower() params = args if cmd == "show_msg": #dialogStart = datetime.datetime.now() self.content_screen.stopLoading() msgType = 'info' if 'msgType' in args: msgType = ("%s" % args['msgType']).lower() msgTimeout = 15 if 'msgTimeout' in args: msgTimeout = int(args['msgTimeout']) canClose = True if 'canClose' in args: canClose = args['canClose'] if msgType == 'error': return showErrorMessage(self.session, args['msg'], msgTimeout, continue_cb, enableInput=canClose) if msgType == 'warning': return showWarningMessage(self.session, args['msg'], msgTimeout, continue_cb, enableInput=canClose) return showInfoMessage(self.session, args['msg'], msgTimeout, continue_cb, enableInput=canClose) except: log.logError( "Execute HACK command failed (addon handler).\n%s" % traceback.format_exc()) command = None args = {} list_items.insert(0, PExit()) self.content_screen.resolveCommand(command, args) self.content_screen.stopLoading() self.open_video_addon(item.addon, list_items)
def showStreams(self): if not self.working: self.workingStarted() stream_content_provider = StreamContentProvider( config.plugins.archivCZSK.downloadsPath.getValue(), settings.STREAM_PATH) lst_items = stream_content_provider.get_content(None) if not isinstance(lst_items[0], PExit): lst_items.insert(0, PExit()) self.session.openWithCallback(self.workingFinished, StreamContentScreen, stream_content_provider, lst_items)
def open_item_success_cb(result): list_items, screen_command, args = result list_items.insert(0, PExit()) if screen_command is not None: self.content_screen.resolveCommand(screen_command, args) else: self.content_screen.save() content = {'parent_it':item, 'lst_items':list_items, 'refresh':False} self.content_screen.stopLoading() self.content_screen.load(content) self.content_screen.showList() self.content_screen.workingFinished()
def _open_item(self, item, *args, **kwargs): self.content_screen.workingStarted() if not self.content_screen.refreshing: self.content_screen.save() else: self.content_screen.refreshing = False list_items = [PExit()] list_addons = self.content_provider.get_content(item.params) list_items.extend(list_addons) content = {'parent_it':item, 'lst_items':list_items, 'refresh':False} self.content_screen.load(content) self.content_screen.workingFinished()
def open_item_success_cb(result): def continue_cb(res): list_items = [] args = {} list_items.insert(0, PExit()) self.content_screen.startLoading() if not self.content_screen.refreshing: self.content_screen.save() else: self.content_screen.refreshing = False if self.is_search(item): parent_content = self.content_screen.getParent() if parent_content: parent_content['refresh'] = True content = { 'parent_it': item, 'lst_items': list_items, 'refresh': False, 'index': kwargs.get('position', 0) } self.content_screen.load(content) self.content_screen.stopLoading() self.content_screen.showList() self.content_screen.workingFinished() def pairTrakt_cb(res): import json import urllib2 from Plugins.Extensions.archivCZSK.settings import USER_AGENT def post_json(url, data, headers={}): postdata = json.dumps(data) headers['Content-Type'] = 'application/json' req = urllib2.Request(url, postdata, headers) req.add_header('User-Agent', USER_AGENT) response = urllib2.urlopen(req) data = response.read() response.close() return data try: data = json.loads( post_json(params['trakt']['url'], data={ 'code': params['trakt']['code'], 'client_id': params['trakt']['client_id'], 'client_secret': params['trakt']['client_secret'] }, headers={'Content-Type': 'application/json'})) TOKEN = data['access_token'] REFRESH_TOKEN = data['refresh_token'] expire = data['expires_in'] #seconds created = data['created_at'] EXPIRE = expire + created log.logDebug( "Get token return token=%s, rtoken=%s, exp=%s" % (TOKEN, REFRESH_TOKEN, EXPIRE)) #update settings self.content_provider.video_addon.set_setting( params['settings']['token'], '%s' % TOKEN) self.content_provider.video_addon.set_setting( params['settings']['refreshToken'], '%s' % REFRESH_TOKEN) self.content_provider.video_addon.set_setting( params['settings']['expire'], '%s' % EXPIRE) return showInfoMessage(self.session, params['msg']['success'], 20, continue_cb) except: log.logDebug("Pair trakt failed.\n%s" % traceback.format_exc()) return showErrorMessage(self.session, params['msg']['fail'], 20, continue_cb) def continue_cb_normal(res): if not list_items and screen_command is not None: self.content_screen.resolveCommand(screen_command, args) else: list_items.insert(0, PExit()) if screen_command is not None: self.content_screen.resolveCommand( screen_command, args) if not self.content_screen.refreshing: self.content_screen.save() else: self.content_screen.refreshing = False if self.is_search(item): parent_content = self.content_screen.getParent() if parent_content: parent_content['refresh'] = True content = { 'parent_it': item, 'lst_items': list_items, 'refresh': False, 'index': kwargs.get('position', 0) } self.content_screen.load(content) self.content_screen.stopLoading() self.content_screen.showList() self.content_screen.workingFinished() list_items, screen_command, args = result try: #client.add_operation("TRAKT_PAIR", {'trakt': {'url':self.tapi.API+'/token', # 'code':self.code, # 'client_id':self.tapi.CLIENT_ID, # 'client_secret': self.tapi.CLIENT_SECRET}, # 'msg': {'pair': msg, 'success':succ, 'fail':fail}, # 'settings': {'token': 'trakt_token', # 'refreshToken':'trakt_refresh_token', # 'expire':'trakt_token_expire'}}) #client.add_operation("SHOW_MSG", {'msg': 'some text'}, # 'msgType': 'info|error|warning', #optional # 'msgTimeout': 10, #optional # 'canClose': True #optional # }) if screen_command is not None: cmd = ("%s" % screen_command).lower() params = args if cmd == "trakt_pair": self.content_screen.stopLoading() return showInfoMessage(self.session, args['msg']['pair'], -1, pairTrakt_cb) if cmd == "show_msg": #dialogStart = datetime.datetime.now() self.content_screen.stopLoading() msgType = 'info' if 'msgType' in args: msgType = ("%s" % args['msgType']).lower() msgTimeout = 15 if 'msgTimeout' in args: msgTimeout = int(args['msgTimeout']) canClose = True if 'canClose' in args: canClose = args['canClose'] if msgType == 'error': return showErrorMessage(self.session, args['msg'], msgTimeout, continue_cb_normal, enableInput=canClose) if msgType == 'warning': return showWarningMessage(self.session, args['msg'], msgTimeout, continue_cb_normal, enableInput=canClose) return showInfoMessage(self.session, args['msg'], msgTimeout, continue_cb_normal, enableInput=canClose) except: log.logError("Execute HACK command failed.\n%s" % traceback.format_exc()) screen_command = None args = {} if not list_items and screen_command is not None: self.content_screen.resolveCommand(screen_command, args) else: list_items.insert(0, PExit()) if screen_command is not None: self.content_screen.resolveCommand(screen_command, args) if not self.content_screen.refreshing: self.content_screen.save() else: self.content_screen.refreshing = False if self.is_search(item): parent_content = self.content_screen.getParent() if parent_content: parent_content['refresh'] = True content = { 'parent_it': item, 'lst_items': list_items, 'refresh': False, 'index': kwargs.get('position', 0) } self.content_screen.load(content) self.content_screen.stopLoading() self.content_screen.showList() self.content_screen.workingFinished()
def __init__(self, session, archivCZSK): provider = ArchivCZSKContentProvider( archivCZSK, os.path.join(settings.PLUGIN_PATH, 'categories')) provider.start() contentHandler = ArchivCZSKContentHandler(session, self, provider) defaultCategory = config.plugins.archivCZSK.defaultCategory.value categoryItem = categoryAddons = None if defaultCategory != 'categories': categoryItem = provider.get_content({'category': defaultCategory}) categoryAddons = provider.get_content( {'category_addons': defaultCategory}) # dont add PExit() if default category is user created cat. gotParrent = True try: gotParrent = self.getParent() is not None except: pass if gotParrent and (defaultCategory == 'all_addons' or defaultCategory == 'tv_addons' or defaultCategory == 'video_addons'): categoryAddons is not None and categoryAddons.insert( 0, PExit()) categoryItems = provider.get_content() BaseContentScreen.__init__(self, session, contentHandler, categoryItems) if categoryItem is not None and categoryAddons is not None: self.save() self.load({ 'lst_items': categoryAddons, 'parent_it': categoryItem, 'refresh': False }) self.ctx_items.append((_("Add Category"), None, self.addCategory)) self.provider = provider self.updateGUITimer = eTimer() self.updateGUITimer_conn = eConnectCallback( self.updateGUITimer.timeout, self.updateAddonGUI) # include DownloadList DownloadList.__init__(self) # include TipList TipBar.__init__(self, [self.CONTEXT_TIP], startOnShown=True) self.onUpdateGUI.append(self.changeAddon) self.onClose.append(self.__onClose) from Plugins.Extensions.archivCZSK.version import version self.setTitle("ArchivCZSK (" + toString(version) + ")") self["image"] = Pixmap() self["title"] = Label("") self["author"] = Label("") self["version"] = Label("") self["about"] = Label("") self["key_red"] = Label(_("Manager")) self["key_green"] = Label(_("Support us")) self["key_yellow"] = Label("") self["key_blue"] = Label(_("Settings")) self["actions"] = ActionMap( ["archivCZSKActions"], { "ok": self.ok, "cancel": self.cancel, "up": self.up, "down": self.down, "blue": self.openSettings, "green": self.showIconD, "red": self.openAddonManagement, "menu": self.menu }, -2) # after layout show update item "GUI" - edit: shamann self.onLayoutFinish.append(self.updateAddonGUI)
def continue_cb(res): list_items.insert(0, PExit()) self.content_screen.resolveCommand(command, args) self.content_screen.stopLoading() self.open_video_addon(item.addon, list_items)
def open_item_success_cb(result): list_items, command, args = result list_items.insert(0, PExit()) self.content_screen.resolveCommand(command, args) self.content_screen.stopLoading() self.open_video_addon(item.addon, list_items)