def parseView(self, lItem): def endOfDirectory(succeeded=True): xbmcplugin.endOfDirectory(handle=self.handle, succeeded=succeeded, cacheToDisc=True) if not lItem: endOfDirectory(False) return None if lItem['type'] == 'search': search_phrase = self.getSearchPhrase() if not search_phrase: common.log("search canceled") endOfDirectory(False) return None else: lItem['type'] = 'rss' lItem['url'] = lItem['url'] % (urllib.quote_plus(search_phrase)) url = lItem['url'] if url == common.Paths.customModulesFile: self.customModulesManager.getCustomModules() tmpList = None result = self.parser.parse(lItem) if result.code == ParsingResult.Code.SUCCESS: tmpList = result.list else: if result.code == ParsingResult.Code.CFGFILE_NOT_FOUND: common.showError("Cfg file not found") elif result.code == ParsingResult.Code.CFGSYNTAX_INVALID: common.showError("Cfg syntax invalid") elif result.code == ParsingResult.Code.WEBREQUEST_FAILED: common.showError("Web request failed") endOfDirectory(False) return None # if it's the main menu, add folder 'Favourites' and 'Custom Modules if url == self.MAIN_MENU_FILE: tmp = ListItem.create() tmp['title'] = '[COLOR green]Favourites[/COLOR]' tmp['type'] = 'rss' tmp['icon'] = os.path.join(common.Paths.imgDir, 'bookmark.png') tmp['url'] = str(common.Paths.favouritesFile) tmpList.items.insert(0, tmp) tmp = ListItem.create() tmp['title'] = '[COLOR red]Custom Modules[/COLOR]' tmp['type'] = 'rss' tmp['url'] = os.path.join(common.Paths.customModulesDir, 'custom.cfg') tmpList.items.insert(0, tmp) # if it's the favourites menu, add item 'Add item' elif url == common.Paths.favouritesFile or url.startswith('favfolders'): if url.startswith('favfolders'): url = os.path.normpath(os.path.join(common.Paths.favouritesFolder, url)) tmp = ListItem.create() tmp['title'] = 'Add item...' tmp['type'] = 'command' tmp['icon'] = os.path.join(common.Paths.imgDir, 'bookmark_add.png') action = 'RunPlugin(%s)' % (self.base + '?mode=' + str(Mode.ADDITEM) + '&url=' + url) tmp['url'] = action tmpList.items.append(tmp) # if it's the custom modules menu, add item 'more...' elif url == common.Paths.customModulesFile: tmp = ListItem.create() tmp['title'] = 'more...' tmp['type'] = 'command' #tmp['icon'] = os.path.join(common.Paths.imgDir, 'bookmark_add.png') action = 'RunPlugin(%s)' % (self.base + '?mode=' + str(Mode.DOWNLOADCUSTOMMODULE) + '&url=') tmp['url'] = action tmpList.items.append(tmp) # Create menu or play, if it's a single video and autoplay is enabled proceed = False count = len(tmpList.items) if count == 0: if url.startswith('favfolders'): proceed = True else: common.showInfo('No stream available') elif count > 0 and not (common.getSetting('autoplay') == 'true' and count == 1 and len(tmpList.getVideos()) == 1): # sort methods sortKeys = tmpList.sort.split('|') setSortMethodsForCurrentXBMCList(self.handle, sortKeys) # Add items to XBMC list for m in tmpList.items: self.addListItem(m, len(tmpList.items)) proceed = True endOfDirectory(proceed) common.log('End of directory') return tmpList
def parseView(self, lItem): def endOfDirectory(succeeded=True): xbmcplugin.endOfDirectory(handle=self.handle, succeeded=succeeded, cacheToDisc=True) if not lItem: endOfDirectory(False) return None if lItem['type'] == 'search': search_phrase = self.getSearchPhrase() if not search_phrase: common.log("search canceled") endOfDirectory(False) return None else: lItem['type'] = 'rss' lItem['url'] = lItem['url'] % ( urllib.quote_plus(search_phrase)) url = lItem['url'] if url == common.Paths.customModulesFile: self.customModulesManager.getCustomModules() tmpList = None result = self.parser.parse(lItem) if result.code == ParsingResult.Code.SUCCESS: tmpList = result.list else: if result.code == ParsingResult.Code.CFGFILE_NOT_FOUND: common.showError("Cfg file not found") elif result.code == ParsingResult.Code.CFGSYNTAX_INVALID: common.showError("Cfg syntax invalid") elif result.code == ParsingResult.Code.WEBREQUEST_FAILED: common.showError("Web request failed") endOfDirectory(False) return None # if it's the main menu, add folder 'Favourites' and 'Custom Modules if url == self.MAIN_MENU_FILE: tmp = ListItem.create() tmp['title'] = 'Favourites' tmp['type'] = 'rss' tmp['icon'] = os.path.join(common.Paths.imgDir, 'bookmark.png') tmp['url'] = str(common.Paths.favouritesFile) tmpList.items.insert(0, tmp) tmp = ListItem.create() tmp['title'] = '[COLOR red]Custom Modules[/COLOR]' tmp['type'] = 'rss' tmp['url'] = os.path.join(common.Paths.customModulesDir, 'custom.cfg') tmpList.items.insert(0, tmp) # if it's the favourites menu, add item 'Add item' elif url == common.Paths.favouritesFile or url.startswith( 'favfolders'): if url.startswith('favfolders'): url = os.path.normpath( os.path.join(common.Paths.favouritesFolder, url)) tmp = ListItem.create() tmp['title'] = 'Add item...' tmp['type'] = 'command' tmp['icon'] = os.path.join(common.Paths.imgDir, 'bookmark_add.png') action = 'RunPlugin(%s)' % (self.base + '?mode=' + str(Mode.ADDITEM) + '&url=' + url) tmp['url'] = action tmpList.items.append(tmp) # if it's the custom modules menu, add item 'more...' elif url == common.Paths.customModulesFile: tmp = ListItem.create() tmp['title'] = 'more...' tmp['type'] = 'command' #tmp['icon'] = os.path.join(common.Paths.imgDir, 'bookmark_add.png') action = 'RunPlugin(%s)' % (self.base + '?mode=' + str( Mode.DOWNLOADCUSTOMMODULE) + '&url=') tmp['url'] = action tmpList.items.append(tmp) # Create menu or play, if it's a single video and autoplay is enabled proceed = False count = len(tmpList.items) if count == 0: if url.startswith('favfolders'): proceed = True else: common.showInfo('No stream available') elif count > 0 and not (common.getSetting('autoplay') == 'true' and count == 1 and len(tmpList.getVideos()) == 1): # sort methods sortKeys = tmpList.sort.split('|') setSortMethodsForCurrentXBMCList(self.handle, sortKeys) # Add items to XBMC list for m in tmpList.items: self.addListItem(m, len(tmpList.items)) proceed = True endOfDirectory(proceed) common.log('End of directory') return tmpList
def parseView(self, lItem): def endOfDirectory(succeeded=True): if self.handle > -1: xbmcplugin.endOfDirectory(handle=self.handle, succeeded=succeeded, cacheToDisc=True) else: common.log('Handle -1') if not lItem: endOfDirectory(False) return None if lItem['type'] == 'search': search_phrase = self.getSearchPhrase() if not search_phrase: common.log("search canceled") endOfDirectory(False) return None else: lItem['type'] = 'rss' lItem['url'] = lItem['url'] % ( urllib.quote_plus(search_phrase)) url = lItem['url'] if url == common.Paths.customModulesFile: self.customModulesManager.getCustomModules() tmpList = None result = self.parser.parse(lItem) if result.code == ParsingResult.Code.SUCCESS: tmpList = result.list elif result.code == ParsingResult.Code.CFGFILE_NOT_FOUND: common.showError("No encuentro el fichero Cfg") endOfDirectory(False) return None elif result.code == ParsingResult.Code.CFGSYNTAX_INVALID: common.showError("sintaxis invalida en Cfg") endOfDirectory(False) return None elif result.code == ParsingResult.Code.WEBREQUEST_FAILED: common.showError("Ha fallado la llamada a la Web") if len(result.list.items) > 0: tmpList = result.list else: endOfDirectory(False) return None # if it's the main menu, add folder 'Favourites' and 'Custom Modules if url == self.MAIN_MENU_FILE: tmp = ListItem.create() tmp['title'] = ' [COLOR blue]ViendoKodi[/COLOR] [COLOR red]Streaming[/COLOR]' tmp['type'] = 'say' tmp['url'] = '' tmp['icon'] = os.path.join(common.Paths.imgDir, 'icon.png') tmpList.items.insert(0, tmp) tmp = ListItem.create() tmp['title'] = '[COLOR red][B] [/B][/COLOR]' tmp['type'] = 'say' tmp['url'] = '' tmp['icon'] = os.path.join(common.Paths.imgDir, 'icon.png') tmpList.items.insert(1, tmp) #tmp = ListItem.create() #tmp['title'] = '[COLOR red]Custom Modules[/COLOR]' #tmp['type'] = 'rss' #tmp['url'] = os.path.join(common.Paths.customModulesDir, 'custom.cfg') #tmpList.items.insert(0, tmp) # if it's the favourites menu, add item 'Add item' elif url == common.Paths.favouritesFile or url.startswith( 'favfolders'): if url.startswith('favfolders'): url = os.path.normpath( os.path.join(common.Paths.favouritesFolder, url)) tmp = ListItem.create() tmp['title'] = 'Add item...' tmp['type'] = 'command' tmp['icon'] = os.path.join(common.Paths.imgDir, 'bookmark_add.png') action = 'RunPlugin(%s)' % (self.base + '?mode=' + str(Mode.ADDITEM) + '&url=' + url) tmp['url'] = action tmpList.items.append(tmp) # Create menu or play, if it's a single video and autoplay is enabled count = len(tmpList.items) if (count == 0 and not url.startswith('favfolders')): common.showInfo('No stream available') #Directory with 0 items endOfDirectory(False) elif not (common.getSetting('autoplay') == 'true' and count == 1 and len(tmpList.getVideos()) == 1): # sort methods sortKeys = tmpList.sort.split('|') setSortMethodsForCurrentXBMCList(self.handle, sortKeys) # Add items to XBMC list for m in tmpList.items: self.addListItem(m, len(tmpList.items)) #Directory with >1 items endOfDirectory(True) else: #Directory with 0 items endOfDirectory(False) return tmpList
def parseView(self, url): lItem = decodeUrl(url) if lItem['type'] == 'search': search_phrase = self.getSearchPhrase() if not search_phrase: common.log("search canceled") self.__endOfDirectory(False) return None lItem['type'] = 'rss' lItem['url'] = lItem['url'] % (urllib.quote_plus(search_phrase)) url = lItem['url'] tmpList = self.parser.parse(lItem) if not tmpList: common.showError("Parsing failed") self.__endOfDirectory(False) return None # Remove duplicates urls = [] for i in range(len(tmpList.items)-1,-1,-1): item = tmpList.items[i] tmpUrl = item['url'] tmpCfg = item['cfg'] if not tmpCfg: tmpCfg = '' if not urls.__contains__(tmpUrl + '|' + tmpCfg): urls.append(tmpUrl + '|' + tmpCfg) else: tmpList.items.remove(item) # SHOW ITEMS IN GUI # if it's the main menu, add folder 'Favourites' if url == self.MAIN_MENU_FILE: # Add Favourites tmp = CListItem() tmp['title'] = 'Favourites' tmp['type'] = 'rss' tmp['url'] = str(common.Paths.favouritesFile) tmpList.items.insert(0,tmp) # if it's the favourites menu, add item 'Add item' elif url == common.Paths.favouritesFile: tmp = CListItem() tmp['title'] = 'Add item...' tmp['type'] = 'command' action = 'RunPlugin(%s)' % (sys.argv[0] + '?mode=' + str(Mode.ADDITEM) + '&url=') tmp['url'] = action tmpList.items.append(tmp) count = len(tmpList.items) if count > 0 and not (common.getSetting('autoplay') == 'true' and count == 1 and len(tmpList.getVideos()) == 1): # sort methods sortKeys = tmpList.sort.split('|') setSortMethodsForCurrentXBMCList(self.handle, sortKeys) # Add items to XBMC list for m in tmpList.items: self.addListItem(m, len(tmpList.items)) self.__endOfDirectory() common.log('End of directory') else: self.__endOfDirectory(False) return tmpList