def loadChannels(self): if self.channels is None: self.channels = Channel.mergeChannels(self.domainCache.getChannels()) self.channels.sort(key=Channel.getSortableChannelNumber) self.channelsById = odict() for c in self.channels: self.channelsById[c.getChannelId()] = c
def loadGuide(self): """ Method to load and display the tv guide information. If this is the first time being called, it initializes the tv guide parameters. """ log.debug('Loading tv guide..') if self.prevFocus: for c in self.gridCells: if c.control == self.prevFocus: self.prevButtonInfo = c self.prevFocus = None break if not self.initialized: self.channel_x = 60 self.channel_h = 40 self.channel_w = 340 - 120 + WIDTH_CHANNEL_ICON self.channel_dx = 5 self.time_y = 140 self.time_h = 40 self.guide_x = 310 self.guide_dx = 12 self.guide_dy = 1 self.guide_y = self.time_y + self.time_h + self.guide_dy self.guide_w = 1220 - 280 self.guide_h = 530 - 140 - self.time_h - self.guide_dy # calculate pixels per hour used repeatedly self.widthPerHour = self.guide_w / self.hoursPerPage # calculate channels per page based on guide height # self.channelsPerPage = int(self.guide_h / (self.guide_dy+self.channel_h) ) log.debug("channelSpan=%d" % self.channelsPerPage) # allocate the remainder to vertical spacing between channels # TODO: Fix gaps betweek rows: #remainder = self.guide_h // (self.guide_dy+self.channel_h) remainder = 0 log.debug('remainder = ' + str(remainder)) self.guide_dy += (remainder / self.channelsPerPage) # retrieve, consolidate, and sort channels self.channels = Channel.mergeChannels(self.domainCache.getChannels()) self.channels.sort(key=Channel.getSortableChannelNumber) self.pager = Pager(len(self.channels), self.channelsPerPage) self.setChannel(int(self.settings.get('tv_guide_last_selected'))) self.setTime(datetime.now() - timedelta(minutes=30)) self.initialized = True self._render() if not self.prevButtonInfo: # set focus to the first control on the screen if len(self.gridCells) > 0: self.prevFocus = self.gridCells[0].control self.setFocus(self.prevFocus) else: raise Exception, self.translator.get(m.NO_EPG_DATA)
def loadGuide(self, skipChannels=False): """ Method to load and display the tv guide information. If this is the first time being called, it initializes the tv guide parameters. """ log.debug('Loading tv guide..') if self.prevFocus: for c in self.gridCells: if c.control == self.prevFocus: self.prevButtonInfo = c self.prevFocus = None break if not self.initialized: self.channel_x = 60 self.channel_h = 40 self.channel_w = 340 - 120 + WIDTH_CHANNEL_ICON self.channel_dx = 5 self.time_y = 140 self.time_h = 40 self.guide_x = 310 self.guide_dx = 12 self.guide_dy = 1 self.guide_y = self.time_y + self.time_h + self.guide_dy self.guide_w = 1220 - 280 self.guide_h = 530 - 140 - self.time_h - self.guide_dy # calculate pixels per hour used repeatedly self.widthPerHour = self.guide_w / self.hoursPerPage # calculate channels per page based on guide height # self.channelsPerPage = int(self.guide_h / (self.guide_dy+self.channel_h) ) log.debug("channelSpan=%d" % self.channelsPerPage) # allocate the remainder to vertical spacing between channels # TODO: Fix gaps betweek rows: #remainder = self.guide_h // (self.guide_dy+self.channel_h) remainder = 0 log.debug('remainder = ' + str(remainder)) self.guide_dy += (remainder / self.channelsPerPage) # retrieve, consolidate, and sort channels self.channels = Channel.mergeChannels( self.domainCache.getChannels()) self.channels.sort(key=Channel.getSortableChannelNumber) self.pager = Pager(len(self.channels), self.channelsPerPage) self.setChannel(int(self.settings.get('tv_guide_last_selected'))) self.setTime(datetime.now() - timedelta(minutes=30)) self.initialized = True self._render(skipChannels) if not self.prevButtonInfo: # set focus to the first control on the screen if len(self.gridCells) > 0: self.prevFocus = self.gridCells[0].control self.setFocus(self.prevFocus) else: raise Exception, self.translator.get(m.NO_EPG_DATA)