Exemple #1
0
 def setupChannelList(self, channelItems):
     heading = '%s / %s'%(utils.ADDON_NAME,self.pluginName)
     self.busy = utils.adaptiveDialog(0, size=len(channelItems), string1=utils.LANGUAGE(30006), header=heading)
     for i in range(self.maxChannels):
         if utils.adaptiveDialog((i*100//len(channelItems)), self.busy, string1=utils.LANGUAGE(30006)) == False: break
         try:
             item                         = channelItems[i]
             item['guidedata']            = sorted(item['guidedata'], key=lambda x:x.get('starttime',''), reverse=False)
             item['guidedata']            = item['guidedata'][:self.maxGuidedata]#truncate guidedata to a manageable amount.
             self.channels[i].name        = item['channelname']
             self.channels[i].logo        = (item.get('channellogo','')        or '')
             self.channels[i].number      = (item.get('channelnumber','')      or i + 1)
             self.channels[i].isFavorite  = (item.get('isfavorite','')         or False)
             self.channels[i].guidedata   = (item['guidedata']                 or '')
             self.channels[i].listSize    = len(self.channels[i].guidedata)
             self.channels[i].listItems   = [utils.buildListItem(data) for data in item['guidedata']]
             self.channels[i].isValid     = True #todo
             totalTime = 0
             for idx, tmpdata in enumerate(self.channels[i].guidedata): totalTime = totalTime + int((tmpdata.get('runtime','') or tmpdata.get('duration','')))
             self.channels[i].totalTime = totalTime
             utils.log('setupChannelList, channel %s, name = %s'%(i+1,str(self.channels[i].name)))
             utils.log('setupChannelList, channel %s, number = %s'%(i+1,str(self.channels[i].number)))
             utils.log('setupChannelList, channel %s, logo = %s'%(i+1,str(self.channels[i].logo)))
             utils.log('setupChannelList, channel %s, isFavorite = %s'%(i+1,str(self.channels[i].isFavorite)))
             utils.log('setupChannelList, channel %s, listSize = %s'%(i+1,str(self.channels[i].listSize)))
             utils.log('setupChannelList, channel %s, totalTime = %s'%(i+1,str(self.channels[i].totalTime)))
         except Exception as e: utils.log("setupChannelList, failed! idx (%s), error (%s), item (%s)"%(i, e, item), xbmc.LOGERROR)
     utils.adaptiveDialog(100, self.busy, string1=utils.LANGUAGE(30007))
Exemple #2
0
    def validateChannels(self, channelItems):
        channelnames = []
        heading = '%s / %s' % (utils.ADDON_NAME, self.pluginName)
        self.busy = utils.adaptiveDialog(0,
                                         size=len(channelItems),
                                         string1=utils.LANGUAGE(30004),
                                         header=heading)

        for i, item in enumerate(channelItems):
            utils.adaptiveDialog((i * 50 // len(channelItems)),
                                 self.busy,
                                 string1=utils.LANGUAGE(30004))
            if len(item.get('guidedata', '')) > 0:
                channelnames.append(item['channelname'])

        counter = collections.Counter(channelnames)
        self.maxChannels = len(counter)
        self.channelNames = list(set(counter.elements()))
        for i in range(self.maxChannels):
            utils.adaptiveDialog((i * 50 // self.maxChannels),
                                 self.busy,
                                 string1=utils.LANGUAGE(30004))
            self.channels.append(Channel())
        utils.adaptiveDialog(100, self.busy, string1=utils.LANGUAGE(30005))

        if self.maxChannels is None or self.maxChannels == 0:
            utils.log('validateChannels, No channels Found')
            return False

        utils.log('validateChannels, maxChannels  = ' + str(self.maxChannels))
        utils.log('validateChannels, maxGuidedata = ' + str(self.maxGuidedata))
        utils.log('validateChannels, channelNames = ' + str(self.channelNames))
        return True
Exemple #3
0
 def prepareListItem(self, channelPath):
     utils.log('prepareListItem, channelPath = ' + str(channelPath))
     channelnames   = []
     channelResults = utils.RPCHelper().getFileList(channelPath, life=datetime.timedelta(seconds=(self.refreshIntvl-600)))
     heading = '%s / %s'%(utils.ADDON_NAME,self.pluginName)
     self.busy = utils.adaptiveDialog(0, size=len(channelResults), string1=utils.LANGUAGE(30004), header=heading)
     for i, item in enumerate(channelResults):
         utils.adaptiveDialog((i*100//len(channelResults))//2, self.busy, string1=utils.LANGUAGE(30004))
         if len(item.get('channelname','')) > 0: channelnames.append(item['channelname'])
                                         
     channelNum   = 0
     channelItems = []
     counter      = collections.Counter(channelnames)
     channelnames = list(set(counter.elements()))
     for channel in sorted(channelnames):
         utils.adaptiveDialog((i*50//len(channelnames)), self.busy, string1=utils.LANGUAGE(30004))
         newChannel  = {}
         guidedata   = []
         starttime   = time.time()
         channelName = channel
         channelNum  = channelNum + 1
         newChannel['channelname']   = channelName
         for item in channelResults:
             if channel == item['channelname']:
                 starttime = int(item.get('starttime','') or starttime)
                 starttime = starttime + (int(item.get('duration','')) or int(item.get('runtime','')))
                 item['starttime'] = starttime
                 newChannel['channelnumber'] = (item.get('channelnumber','')      or channelNum)
                 newChannel['channellogo']   = (item.get('channellogo','')        or self.pluginIcon)
                 guidedata.append(item)
         if len(guidedata) > 0:
             newChannel['guidedata'] = guidedata
             channelItems.append(newChannel)
     utils.adaptiveDialog(100, self.busy, string1=utils.LANGUAGE(30005))
     return self.prepareJson(channelItems)