def addseasons(self): seasonlist = [] seasons = [] self.episodes = {} for ep, value in self.seasons.items(): season = value.split('x')[0] if season not in seasonlist: item = xbmcgui.ListItem(season) seasonlist.append(season) seasons.append(item) if season in seasonlist: if season not in self.episodes: self.episodes[season] = [] item = xbmcgui.ListItem('%s - Ep. %s' % (value, ep)) item.setProperty('episode', ep) self.episodes[season].append(item) logger.log('EPISODES', self.episodes[season]) self.episodes[season].sort(key=lambda it: int(it.getProperty('episode'))) seasons.sort(key=lambda it: int(it.getLabel())) self.getControl(MSEASONS).reset() self.getControl(MSEASONS).addItems(seasons)
def update(self, channel, valid, results): if self.exit: return logger.debug('Search on channel', channel) if self.item.mode != 'all' and 'valid' not in self.results: self.results['valid'] = 0 item = xbmcgui.ListItem('valid') item.setProperties({ 'thumb': 'valid.png', 'position': '0', 'results': '0' }) self.channels.append(item) pos = self.CHANNELS.getSelectedPosition() self.CHANNELS.addItems(self.channels) self.CHANNELS.selectItem(pos) self.setFocusId(CHANNELS) if valid: item = self.CHANNELS.getListItem(0) resultsList = item.getProperty('items') for result in valid: resultsList += result.tourl() + '|' item.setProperty('items', resultsList) self.channels[0].setProperty('results', str(len(resultsList.split('|')))) if self.CHANNELS.getSelectedPosition() == 0: items = [] for result in valid: if result: items.append(self.makeItem(result.tourl())) pos = self.RESULTS.getSelectedPosition() self.RESULTS.addItems(items) self.RESULTS.selectItem(pos) if results: resultsList = '' channelParams = channeltools.get_channel_parameters(channel) name = channelParams['title'] if name not in self.results: item = xbmcgui.ListItem(name) item.setProperties({ 'thumb': channelParams['thumbnail'], 'position': '0', 'results': str(len(results)) }) for result in results: resultsList += result.tourl() + '|' item.setProperty('items', resultsList) self.results[name] = len(self.results) self.channels.append(item) else: item = self.CHANNELS.getListItem(self.results[name]) resultsList = item.getProperty('items') for result in results: resultsList += result.tourl() + '|' item.setProperty('items', resultsList) logger.log(self.channels[int(self.results[name])]) self.channels[int(self.results[name])].setProperty( 'results', str(len(resultsList.split('|')) - 1)) pos = self.CHANNELS.getSelectedPosition() self.CHANNELS.reset() self.CHANNELS.addItems(self.channels) self.CHANNELS.selectItem(pos) if len(self.channels) == 1: self.setFocusId(CHANNELS) channelResults = self.CHANNELS.getListItem( self.results[name]).getProperty('items').split('|') items = [] for result in channelResults: if result: items.append(self.makeItem(result)) self.RESULTS.reset() self.RESULTS.addItems(items) percent = (float(self.count) / len(self.searchActions)) * 100 self.LOADING.setVisible(False) self.PROGRESS.setPercent(percent) self.COUNT.setText('%s/%s [%s"]' % (self.count, len( self.searchActions), int(time.time() - self.time))) if percent == 100: self.channels = [] self.moduleDict = {} self.searchActions = [] if percent == 100 and not self.results: self.PROGRESS.setVisible(False) self.NORESULTS.setVisible(True)
def update(self, channel, valid, results): self.LOADING.setVisible(False) if self.exit: return logger.debug('Search on channel', channel) if self.item.mode != 'all' and 'valid' not in self.results: self.results['valid'] = 0 item = xbmcgui.ListItem('valid') item.setProperties({'thumb': 'valid.png', 'position': '0', 'results': '0'}) self.channels.append(item) pos = self.CHANNELS.getSelectedPosition() self.CHANNELS.addItems(self.channels) self.CHANNELS.selectItem(pos) self.setFocusId(RESULTS) if valid and self.CHANNELS.size(): item = self.CHANNELS.getListItem(0) resultsList = item.getProperty('items') for result in valid: resultsList += result.tourl() + '|' item.setProperty('items', resultsList) self.channels[0].setProperty('results', str(len(resultsList.split('|')) - 1 )) if self.CHANNELS.getSelectedPosition() == 0: items = [] for result in valid: if result: items.append(self.makeItem(result.tourl())) pos = self.RESULTS.getSelectedPosition() self.RESULTS.addItems(items) if pos < 0: self.setFocusId(RESULTS) pos = 0 self.RESULTS.selectItem(pos) if results: resultsList = '' channelParams = channeltools.get_channel_parameters(channel) name = channelParams['title'] if name not in self.results: item = xbmcgui.ListItem(name) item.setProperties({'thumb': channelParams['thumbnail'], 'position': '0', 'results': str(len(results)) }) for result in results: resultsList += result.tourl() + '|' item.setProperty('items',resultsList) self.results[name] = len(self.results) self.channels.append(item) else: item = self.CHANNELS.getListItem(self.results[name]) resultsList = item.getProperty('items') for result in results: resultsList += result.tourl() + '|' item.setProperty('items',resultsList) logger.log(self.channels[int(self.results[name])]) self.channels[int(self.results[name])].setProperty('results', str(len(resultsList.split('|')) - 1)) pos = self.CHANNELS.getSelectedPosition() self.CHANNELS.reset() self.CHANNELS.addItems(self.channels) self.CHANNELS.selectItem(pos) if len(self.channels) == 1: self.setFocusId(CHANNELS) channelResults = self.CHANNELS.getListItem(self.results[name]).getProperty('items').split('|') items = [] for result in channelResults: if result: items.append(self.makeItem(result)) self.RESULTS.reset() self.RESULTS.addItems(items)