def buildMovieListEntry(self, serviceref, info, begin, data): switch = config.usage.show_icons_in_movielist.value ext = config.movielist.useextlist.value width = self.l.getItemSize().width() pathName = serviceref.getPath() res = [ None ] if serviceref.flags & eServiceReference.mustDescent: if self.screenwidth and self.screenwidth == 1920: # Directory iconSize = 37 else: iconSize = 22 # Name is full path name if info is None: # Special case: "parent" txt = ".." else: p = os.path.split(pathName) if not p[1]: # if path ends in '/', p is blank. p = os.path.split(p[0]) txt = p[1] if txt == ".Trash": if self.screenwidth and self.screenwidth == 1920: res.append(MultiContentEntryPixmapAlphaBlend(pos=(3,5), size=(iconSize,37), png=self.iconTrash)) res.append(MultiContentEntryText(pos=(40+20, 5), size=(width-166, self.itemHeight), font = 0, flags = RT_HALIGN_LEFT, text = _("Deleted items"))) res.append(MultiContentEntryText(pos=(width-145, 0), size=(145, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT|RT_VALIGN_CENTER, text=_("Trashcan"))) return res else: res.append(MultiContentEntryPixmapAlphaBlend(pos=(0,2), size=(iconSize,24), png=self.iconTrash)) res.append(MultiContentEntryText(pos=(iconSize+10, 0), size=(width-166, self.itemHeight), font = 0, flags = RT_HALIGN_LEFT, text = _("Deleted items"))) res.append(MultiContentEntryText(pos=(width-150, 0), size=(145, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT|RT_VALIGN_CENTER, text=_("Trashcan"))) return res if self.screenwidth and self.screenwidth == 1920: res.append(MultiContentEntryPixmapAlphaBlend(pos=(3,5), size=(iconSize,iconSize), png=self.iconFolder)) res.append(MultiContentEntryText(pos=(40+20, 5), size=(width-166, self.itemHeight), font = 0, flags = RT_HALIGN_LEFT, text = txt)) res.append(MultiContentEntryText(pos=(width-145, 0), size=(145, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT|RT_VALIGN_CENTER, text=_("Directory"))) return res else: res.append(MultiContentEntryPixmapAlphaBlend(pos=(0,2), size=(iconSize,iconSize), png=self.iconFolder)) res.append(MultiContentEntryText(pos=(iconSize+10, 0), size=(width-166, self.itemHeight), font = 0, flags = RT_HALIGN_LEFT, text = txt)) res.append(MultiContentEntryText(pos=(width-150, 0), size=(145, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT|RT_VALIGN_CENTER, text=_("Directory"))) return res if (data == -1) or (data is None): data = MovieListData() cur_idx = self.l.getCurrentSelectionIndex() x = self.list[cur_idx] # x = ref,info,begin,... data.len = 0 #dont recalc movielist to speedup loading the list self.list[cur_idx] = (x[0], x[1], x[2], data) #update entry in list... so next time we don't need to recalc data.txt = info.getName(serviceref) if config.movielist.hide_extensions.value: fileName, fileExtension = os.path.splitext(data.txt) if fileExtension in KNOWN_EXTENSIONS: data.txt = fileName data.icon = None data.part = None if os.path.split(pathName)[1] in self.runningTimers: if switch == 'i': if (self.playInBackground or self.playInForeground) and serviceref == (self.playInBackground or self.playInForeground): data.icon = self.iconMoviePlayRec else: data.icon = self.iconMovieRec elif switch == 'p' or switch == 's': data.part = 100 if (self.playInBackground or self.playInForeground) and serviceref == (self.playInBackground or self.playInForeground): data.partcol = 0xffc71d else: data.partcol = 0xff001d elif (self.playInBackground or self.playInForeground) and serviceref == (self.playInBackground or self.playInForeground): data.icon = self.iconMoviePlay else: data.part = moviePlayState(pathName + '.cuts', serviceref, data.len) if switch == 'i': if data.part is not None and data.part > 0: data.icon = self.iconPart[data.part // 25] else: if config.usage.movielist_unseen.value: data.icon = self.iconUnwatched elif switch == 'p' or switch == 's': if data.part is not None and data.part > 0: data.partcol = 0xffc71d else: if config.usage.movielist_unseen.value: data.part = 100 data.partcol = 0x206333 len = data.len if len > 0: len = "%d:%02d" % (len / 60, len % 60) else: len = "" iconSize = 0 if switch == 'i': if self.screenwidth and self.screenwidth == 1920: iconSize = 42 res.append(MultiContentEntryPixmapAlphaBlend(pos=(2,3), size=(iconSize,iconSize), png=data.icon)) else: iconSize = 22 res.append(MultiContentEntryPixmapAlphaBlend(pos=(0,1), size=(iconSize,20), png=data.icon)) elif switch == 'p': if self.screenwidth and self.screenwidth == 1920: iconSize = 42 else: iconSize = 48 if data.part is not None and data.part > 0: if self.screenwidth and self.screenwidth == 1920: res.append(MultiContentEntryProgress(pos=(0,10), size=(iconSize+5,16), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) else: res.append(MultiContentEntryProgress(pos=(0,5), size=(iconSize-2,16), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) else: if self.screenwidth and self.screenwidth == 1920: res.append(MultiContentEntryPixmapAlphaBlend(pos=(0,1), size=(iconSize,iconSize), png=data.icon)) else: res.append(MultiContentEntryPixmapAlphaBlend(pos=(0,1), size=(iconSize,20), png=data.icon)) elif switch == 's': if self.screenwidth and self.screenwidth == 1920: iconSize = 42 else: iconSize = 22 if data.part is not None and data.part > 0: if self.screenwidth and self.screenwidth == 1920: res.append(MultiContentEntryProgress(pos=(0,10), size=(iconSize+5,16), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) else: res.append(MultiContentEntryProgress(pos=(0,5), size=(iconSize-2,16), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) else: if self.screenwidth and self.screenwidth == 1920: res.append(MultiContentEntryPixmapAlphaBlend(pos=(0,1), size=(iconSize,iconSize), png=data.icon)) else: res.append(MultiContentEntryPixmapAlphaBlend(pos=(0,1), size=(iconSize,20), png=data.icon)) begin_string = "" if begin > 0: begin_string = ', '.join(FuzzyTime(begin, inPast = True)) if ext != '0': ih = self.itemHeight / 2 else: ih = self.itemHeight lenSize = ih * 3 # 25 -> 75 dateSize = ih * 145 / 25 # 25 -> 145 if ext != '0': getrec = info.getName(serviceref) fileName, fileExtension = os.path.splitext(getrec) desc = None picon = None service = None try: serviceHandler = eServiceCenter.getInstance() info = serviceHandler.info(serviceref) desc = info.getInfoString(serviceref, iServiceInformation.sDescription) # get description ref = info.getInfoString(serviceref, iServiceInformation.sServiceref) # get reference service = ServiceReference(ref).getServiceName() # get service name except Exception, e: print('[MovieList] load extended infos get failed: ', e) if ext == '2': try: picon = getPiconName(ref) picon = loadPNG(picon) except Exception, e: print('[MovieList] load picon get failed: ', e)
def buildTimerEntry(self, timer, processed): height = self.l.getItemSize().height() width = self.l.getItemSize().width() res = [None] serviceName = timer.service_ref.getServiceName() serviceNameWidth = getTextBoundarySize(self.instance, self.serviceNameFont, self.l.getItemSize(), serviceName).width() if 200 > width - serviceNameWidth - self.iconWidth - self.iconMargin: serviceNameWidth = width - 200 - self.iconWidth - self.iconMargin res.append( (eListboxPythonMultiContent.TYPE_TEXT, width - serviceNameWidth, 0, serviceNameWidth, self.rowSplit, 0, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, serviceName)) res.append( (eListboxPythonMultiContent.TYPE_TEXT, self.iconWidth + self.iconMargin, 0, width - serviceNameWidth - self.iconWidth - self.iconMargin, self.rowSplit, 2, RT_HALIGN_LEFT | RT_VALIGN_BOTTOM, timer.name)) begin = FuzzyTime(timer.begin) if timer.repeated: days = (_("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun")) repeatedtext = [] flags = timer.repeated for x in (0, 1, 2, 3, 4, 5, 6): if flags & 1 == 1: repeatedtext.append(days[x]) flags >>= 1 if repeatedtext == [ _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun") ]: repeatedtext = _('Everyday') elif repeatedtext == [ _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri") ]: repeatedtext = _('Weekday') elif repeatedtext == [_("Sat"), _("Sun")]: repeatedtext = _('Weekend') else: repeatedtext = ", ".join(repeatedtext) if self.iconRepeat: res.append( (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, self.iconMargin / 2, self.rowSplit + (self.itemHeight - self.rowSplit - self.iconHeight) / 2, self.iconWidth, self.iconHeight, self.iconRepeat)) else: repeatedtext = begin[0] # date if timer.justplay: extra_text = _("(ZAP)") if timer.pipzap: extra_text = _("(ZAP as PiP)") text = repeatedtext + ((" %s " + extra_text) % (begin[1])) else: text = repeatedtext + ((" %s ... %s (%d " + _("mins") + ")") % (begin[1], FuzzyTime(timer.end)[1], (timer.end - timer.begin) / 60)) icon = None if not processed: if timer.state == TimerEntry.StateWaiting: state = _("waiting") if timer.isAutoTimer: icon = self.iconAutoTimer else: icon = self.iconWait elif timer.state == TimerEntry.StatePrepared: state = _("about to start") icon = self.iconPrepared elif timer.state == TimerEntry.StateRunning: if timer.justplay: state = _("zapped") icon = self.iconZapped else: state = _("recording...") icon = self.iconRecording elif timer.state == TimerEntry.StateEnded: state = _("done!") icon = self.iconDone else: state = _("<unknown>") icon = None elif timer.disabled: state = _("disabled") icon = self.iconDisabled elif timer.failed: state = _("failed") icon = self.iconFailed else: state = _("done!") icon = self.iconDone icon and res.append( (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, self.iconMargin / 2, (self.rowSplit - self.iconHeight) / 2, self.iconWidth, self.iconHeight, icon)) orbpos = self.getOrbitalPos(timer.service_ref) orbposWidth = getTextBoundarySize(self.instance, self.font, self.l.getItemSize(), orbpos).width() res.append( (eListboxPythonMultiContent.TYPE_TEXT, self.satPosLeft, self.rowSplit, orbposWidth, self.itemHeight - self.rowSplit, 1, RT_HALIGN_LEFT | RT_VALIGN_TOP, orbpos)) res.append((eListboxPythonMultiContent.TYPE_TEXT, self.iconWidth + self.iconMargin, self.rowSplit, self.satPosLeft - self.iconWidth - self.iconMargin, self.itemHeight - self.rowSplit, 1, RT_HALIGN_LEFT | RT_VALIGN_TOP, state)) res.append((eListboxPythonMultiContent.TYPE_TEXT, self.satPosLeft + orbposWidth, self.rowSplit, width - self.satPosLeft - orbposWidth, self.itemHeight - self.rowSplit, 1, RT_HALIGN_RIGHT | RT_VALIGN_TOP, text)) line = LoadPixmap(resolveFilename(SCOPE_ACTIVE_SKIN, "div-h.png")) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 0, height - 2, width, 2, line)) return res
def getMovieDetails(sRef=None): service = ServiceReference(sRef) if service is not None: serviceref = service.ref length_minutes = 0 txtdesc = "" fullpath = serviceref.getPath() filename = '/'.join(fullpath.split("/")[1:]) filename = '/' + filename name, ext = os.path.splitext(filename) serviceHandler = eServiceCenter.getInstance() info = serviceHandler.info(serviceref) sourceRef = ServiceReference( info.getInfoString( serviceref, iServiceInformation.sServiceref)) rtime = info.getInfo( serviceref, iServiceInformation.sTimeCreate) movie = { 'filename': filename, 'filename_stripped': filename.split("/")[-1], 'serviceref': serviceref.toString(), 'length': "?:??", 'lastseen': 0, 'filesize_readable': '', 'recordingtime': rtime, 'begintime': 'undefined', 'eventname': service.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''), 'servicename': sourceRef.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''), 'tags': info.getInfoString(serviceref, iServiceInformation.sTags), 'fullname': serviceref.toString(), } if rtime > 0: fuzzy_rtime = FuzzyTime(rtime) movie['begintime'] = fuzzy_rtime[0] + ", " + fuzzy_rtime[1] try: length_minutes = info.getLength(serviceref) except: # noqa: E722 pass if length_minutes: movie['length'] = "%d:%02d" % (length_minutes / 60, length_minutes % 60) movie['lastseen'] = _moviePlayState(filename + '.cuts', serviceref, length_minutes) or 0 txtfile = name + '.txt' if ext.lower() != '.ts' and os.path.isfile(txtfile): with open(txtfile, "rb") as handle: txtdesc = six.ensure_str(b''.join(handle.readlines())) event = info.getEvent(serviceref) extended_description = event and event.getExtendedDescription() or "" if extended_description == '' and txtdesc != '': extended_description = txtdesc movie['descriptionExtended'] = ConvertDesc(extended_description) desc = info.getInfoString(serviceref, iServiceInformation.sDescription) movie['description'] = ConvertDesc(desc) size = 0 sz = '' try: size = os.stat(filename).st_size if size > 1073741824: sz = "%.2f %s" % ((size / 1073741824.), _("GB")) elif size > 1048576: sz = "%.2f %s" % ((size / 1048576.), _("MB")) elif size > 1024: sz = "%.2f %s" % ((size / 1024.), _("kB")) except: # noqa: E722 pass movie['filesize'] = size movie['filesize_readable'] = sz return { "result": True, "movie": movie } else: return { "result": False, }
def buildListboxEntry(self, timer): if not timer.enabled: icon = self.iconDisabled else: icon = self.iconEnabled if timer.justplay: rectypeicon = self.iconZapped else: rectypeicon = self.iconRecording height = self.l.getItemSize().height() width = self.l.getItemSize().width() iconMargin = self.iconMargin statusIconHeight = self.statusIconHeight statusIconWidth = self.statusIconWidth typeIconHeight = self.typeIconHeight typeIconWidth = self.typeIconWidth rowHeight = self.rowHeight rowSplit1 = self.rowSplit1 rowSplit2 = self.rowSplit2 channels = [] bouquets = [] for t in timer.services: channels.append(ServiceReference(t).getServiceName()) for t in timer.bouquets: bouquets.append(ServiceReference(t).getServiceName()) if len(channels) > 0: channel = _("[S] ") channel += ", ".join(channels) elif len(bouquets) > 0: channel = _("[B] ") channel += ", ".join(bouquets) else: channel = _('All channels') res = [None] if icon: if skinparms: x, y, w, h = parameters.get( "AutotimerEnabledIcon", (iconMargin, 0, statusIconHeight, statusIconWidth)) else: x, y, w, h = (iconMargin, 0, statusIconHeight, statusIconWidth) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, x, y, w, h, icon)) if rectypeicon: if skinparms: x, y, w, h = parameters.get( "AutotimerRecordIcon", (iconMargin + statusIconWidth + iconMargin, 3, statusIconHeight, typeIconWidth)) else: x, y, w, h = (iconMargin + statusIconWidth + iconMargin, 3, statusIconHeight, typeIconWidth) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, x, y, w, h, rectypeicon)) if timer.hasTimespan(): nowt = time() now = localtime(nowt) begintime = int( mktime((now.tm_year, now.tm_mon, now.tm_mday, timer.timespan[0][0], timer.timespan[0][1], 0, now.tm_wday, now.tm_yday, now.tm_isdst))) endtime = int( mktime((now.tm_year, now.tm_mon, now.tm_mday, timer.timespan[1][0], timer.timespan[1][1], 0, now.tm_wday, now.tm_yday, now.tm_isdst))) timespan = ((" %s ... %s") % (FuzzyTime(begintime)[1], FuzzyTime(endtime)[1])) else: timespan = _(" Any time") res.append( (eListboxPythonMultiContent.TYPE_TEXT, float(width) / 10 * 4.5, 2, width - float(width) / 10 * 4.5, rowHeight, 1, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, timespan)) if TextBoundary: timespanWidth = getTextBoundarySize(self.instance, self.EventNameFont, self.l.getItemSize(), timespan).width() else: timespanWidth = float(width) / 10 * 2 res.append( (eListboxPythonMultiContent.TYPE_TEXT, statusIconWidth + typeIconWidth + iconMargin * 3, 2, width - statusIconWidth - typeIconWidth - iconMargin * 3 - timespanWidth, rowHeight, 1, RT_HALIGN_LEFT | RT_VALIGN_BOTTOM, timer.name)) if timer.hasTimeframe(): begin = strftime("%a, %d %b", localtime(timer.getTimeframeBegin())) end = strftime("%a, %d %b", localtime(timer.getTimeframeEnd())) timeframe = (("%s ... %s") % (begin, end)) res.append( (eListboxPythonMultiContent.TYPE_TEXT, iconMargin, rowSplit1, float(width) / 10 * 4.5, rowHeight, 2, RT_HALIGN_LEFT | RT_VALIGN_TOP, timeframe)) if timer.include[3]: total = len(timer.include[3]) count = 0 days = [] while count + 1 <= total: day = timer.include[3][count] day = { '0': _("Mon"), '1': _("Tue"), '2': _("Wed"), '3': _("Thur"), '4': _("Fri"), '5': _("Sat"), '6': _("Sun"), "weekend": _("Weekend"), "weekday": _("Weekday") }[day] days.append(day) count += 1 days = ', '.join(days) else: days = _("Everyday") res.append( (eListboxPythonMultiContent.TYPE_TEXT, float(width) / 10 * 5.5, rowSplit1, width - float(width) / 10 * 5.5, rowHeight, 2, RT_HALIGN_RIGHT | RT_VALIGN_TOP, days)) res.append((eListboxPythonMultiContent.TYPE_TEXT, iconMargin, rowSplit2, width - (iconMargin * 2), rowHeight, 0, RT_HALIGN_LEFT | RT_VALIGN_TOP, channel)) try: devide = LoadPixmap( resolveFilename(SCOPE_CURRENT_SKIN, "div-h.png")) except: devide = LoadPixmap( resolveFilename(SCOPE_CURRENT_SKIN, "div-h.png")) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 0, height - 2, width, 2, devide)) return res
def buildMovieListEntry(self, serviceref, info, begin, data): switch = config.usage.show_icons_in_movielist.getValue() width = self.l.getItemSize().width() pathName = serviceref.getPath() res = [None] if serviceref.flags & eServiceReference.mustDescent: # Directory iconSize = 22 # Name is full path name if info is None: # Special case: "parent" txt = ".." else: p = os.path.split(pathName) if not p[1]: # if path ends in '/', p is blank. p = os.path.split(p[0]) txt = p[1] if txt == ".Trash": res.append( MultiContentEntryPixmapAlphaTest(pos=(0, 2), size=(iconSize, 24), png=self.iconTrash)) res.append( MultiContentEntryText(pos=(iconSize + 2, 0), size=(width - 166, self.itemHeight), font=0, flags=RT_HALIGN_LEFT, text=_("Deleted items"))) res.append( MultiContentEntryText(pos=(width - 145, 0), size=(145, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=_("Trashcan"))) return res res.append( MultiContentEntryPixmapAlphaTest(pos=(0, 2), size=(iconSize, iconSize), png=self.iconFolder)) res.append( MultiContentEntryText(pos=(iconSize + 2, 0), size=(width - 166, self.itemHeight), font=0, flags=RT_HALIGN_LEFT, text=txt)) res.append( MultiContentEntryText(pos=(width - 145, 0), size=(145, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=_("Directory"))) return res if (data == -1) or (data is None): data = MovieListData() cur_idx = self.l.getCurrentSelectionIndex() x = self.list[cur_idx] # x = ref,info,begin,... data.len = 0 #dont recalc movielist to speedup loading the list self.list[cur_idx] = ( x[0], x[1], x[2], data ) #update entry in list... so next time we don't need to recalc data.txt = info.getName(serviceref) if config.movielist.hide_extensions.getValue(): fileName, fileExtension = os.path.splitext(data.txt) if fileExtension in KNOWN_EXTENSIONS: data.txt = fileName data.icon = None data.part = None if os.path.split(pathName)[1] in self.runningTimers: if switch == 'i': if (self.playInBackground or self.playInForeground ) and serviceref == (self.playInBackground or self.playInForeground): data.icon = self.iconMoviePlayRec else: data.icon = self.iconMovieRec elif switch == 'p' or switch == 's': data.part = 100 if (self.playInBackground or self.playInForeground ) and serviceref == (self.playInBackground or self.playInForeground): data.partcol = 0xffc71d else: data.partcol = 0xff001d elif (self.playInBackground or self.playInForeground) and serviceref == ( self.playInBackground or self.playInForeground): data.icon = self.iconMoviePlay else: data.part = moviePlayState(pathName + '.cuts', serviceref, data.len) if switch == 'i': if data.part is not None and data.part > 0: data.icon = self.iconPart[data.part // 25] else: if config.usage.movielist_unseen.getValue(): data.icon = self.iconUnwatched elif switch == 'p' or switch == 's': if data.part is not None and data.part > 0: data.partcol = 0xffc71d else: if config.usage.movielist_unseen.getValue(): data.part = 100 data.partcol = 0x206333 len = data.len if len > 0: len = "%d:%02d" % (len / 60, len % 60) else: len = "" iconSize = 0 if switch == 'i': iconSize = 22 res.append( MultiContentEntryPixmapAlphaTest(pos=(0, 1), size=(iconSize, 20), png=data.icon)) elif switch == 'p': iconSize = 48 if data.part is not None and data.part > 0: res.append( MultiContentEntryProgress(pos=(0, 5), size=(iconSize - 2, 16), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) else: res.append( MultiContentEntryPixmapAlphaTest(pos=(0, 1), size=(iconSize, 20), png=data.icon)) elif switch == 's': iconSize = 22 if data.part is not None and data.part > 0: res.append( MultiContentEntryProgress(pos=(0, 5), size=(iconSize - 2, 16), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) else: res.append( MultiContentEntryPixmapAlphaTest(pos=(0, 1), size=(iconSize, 20), png=data.icon)) begin_string = "" if begin > 0: begin_string = ' '.join(FuzzyTime(begin, inPast=True)) ih = self.itemHeight lenSize = ih * 3 # 25 -> 75 dateSize = ih * 145 / 25 # 25 -> 145 res.append( MultiContentEntryText(pos=(iconSize, 0), size=(width - iconSize - dateSize, ih), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) res.append( MultiContentEntryText(pos=(width - dateSize, 0), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=begin_string)) return res
def JobMessage(self): if self.callback is not None: if self.simulateOnly == True: self.callback(self.autotimers, self.skipped) else: total = (self.new+self.modified+len(self.conflicting)+len(self.existing)+len(self.similars)) _result = (total, self.new, self.modified, self.autotimers, self.conflicting, self.similars, self.existing, self.skipped) self.callback(_result) elif self.autoPoll: if self.conflicting and config.plugins.autotimer.notifconflict.value: AddPopup( _("%d conflict(s) encountered when trying to add new timers:\n%s") % (len(self.conflicting), '\n'.join([_("%s: %s at %s") % (x[4], x[0], FuzzyTime(x[2])) for x in self.conflicting])), MessageBox.TYPE_INFO, config.plugins.autotimer.popup_timeout.value, CONFLICTNOTIFICATIONID ) elif self.similars and config.plugins.autotimer.notifsimilar.value: AddPopup( _("%d conflict(s) solved with similar timer(s):\n%s") % (len(self.similars), '\n'.join([_("%s: %s at %s") % (x[4], x[0], FuzzyTime(x[2])) for x in self.similars])), MessageBox.TYPE_INFO, config.plugins.autotimer.popup_timeout.value, SIMILARNOTIFICATIONID ) else: AddPopup( _("Found a total of %d matching Events.\n%d Timer were added and\n%d modified,\n%d conflicts encountered,\n%d unchanged,\n%d similars added.") % ((self.new+self.modified+len(self.conflicting)+len(self.existing)+len(self.similars)), self.new, self.modified, len(self.conflicting), len(self.existing), len(self.similars)), MessageBox.TYPE_INFO, config.plugins.autotimer.popup_timeout.value, NOTIFICATIONID )
def buildMovieListEntry(self, serviceref, info, begin, data): showPicons = "picon" in config.usage.movielist_servicename_mode.getValue( ) switch = config.usage.show_icons_in_movielist.getValue() piconWidth = config.usage.movielist_piconwidth.getValue( ) if showPicons else 0 durationWidth = self.durationWidth if config.usage.load_length_of_movies_in_moviellist.getValue( ) else 0 width = self.l.getItemSize().width() dateWidth = self.dateWidth if not config.movielist.use_fuzzy_dates.getValue(): dateWidth += 30 iconSize = self.iconsWidth if switch == 'p': iconSize = self.pbarLargeWidth ih = self.itemHeight col0iconSize = piconWidth if showPicons else iconSize space = self.spaceIconeText r = self.spaceRight pathName = serviceref.getPath() res = [None] if serviceref.flags & eServiceReference.mustDescent: # Directory # Name is full path name if info is None: # Special case: "parent" txt = ".." else: p = os.path.split(pathName) if not p[1]: # if path ends in '/', p is blank. p = os.path.split(p[0]) txt = p[1] if txt == ".Trash": res.append( MultiContentEntryPixmapAlphaBlend( pos=((col0iconSize - self.iconTrash.size().width()) / 2, (self.itemHeight - self.iconFolder.size().height()) / 2), size=(iconSize, self.iconTrash.size().height()), png=self.iconTrash)) res.append( MultiContentEntryText( pos=(col0iconSize + space, 0), size=(width - 145, self.itemHeight), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=_("Deleted items"))) res.append( MultiContentEntryText(pos=(width - 185 - r, 0), size=(185, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=_("Trash can"))) return res if not config.movielist.show_underlines.value: txt = txt.replace('_', ' ').strip() res.append( MultiContentEntryPixmapAlphaBlend( pos=((col0iconSize - self.iconFolder.size().width()) / 2, (self.itemHeight - self.iconFolder.size().height()) / 2), size=(iconSize, iconSize), png=self.iconFolder)) res.append( MultiContentEntryText(pos=(col0iconSize + space, 0), size=(width - 145, self.itemHeight), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=txt)) res.append( MultiContentEntryText(pos=(width - 145 - r, 0), size=(145, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=_("Directory"))) return res if data == -1 or data is None: data = MovieListData() cur_idx = self.l.getCurrentSelectionIndex() x = self.list[cur_idx] # x = ref,info,begin,... if config.usage.load_length_of_movies_in_moviellist.getValue(): data.len = x[1].getLength(x[0]) #recalc the movie length... else: data.len = 0 #dont recalc movielist to speedup loading the list self.list[cur_idx] = ( x[0], x[1], x[2], data ) #update entry in list... so next time we don't need to recalc if config.movielist.show_underlines.value: data.txt = info.getName(serviceref) else: data.txt = info.getName(serviceref).replace('_', ' ').strip() if config.movielist.hide_extensions.getValue(): fileName, fileExtension = os.path.splitext(data.txt) if fileExtension in KNOWN_EXTENSIONS: data.txt = fileName data.icon = None data.part = None if os.path.split(pathName)[1] in self.runningTimers: if switch == 'i': if (self.playInBackground or self.playInForeground ) and serviceref == (self.playInBackground or self.playInForeground): data.icon = self.iconMoviePlayRec else: data.icon = self.iconMovieRec elif switch in ('p', 's'): data.part = 100 if (self.playInBackground or self.playInForeground ) and serviceref == (self.playInBackground or self.playInForeground): data.partcol = self.pbarColourSeen else: data.partcol = self.pbarColourRec elif (self.playInBackground or self.playInForeground) and serviceref == ( self.playInBackground or self.playInForeground): data.icon = self.iconMoviePlay elif pathName.endswith( ".tmpcut.ts" ): # cutting with moviecut plugin to same filename data.icon = self.iconCutting else: data.part = moviePlayState(pathName + '.cuts', serviceref, data.len) if switch == 'i': if data.part is not None and data.part > 0: data.icon = self.iconPart[data.part // 25] else: if config.usage.movielist_unseen.value: data.icon = self.iconUnwatched elif switch in ('p', 's'): if data.part is not None and data.part > 0: data.partcol = self.pbarColourSeen else: if config.usage.movielist_unseen.value: data.part = 100 data.partcol = self.pbarColour colX = 0 if switch == 'p': iconSize = self.pbarLargeWidth ih = self.itemHeight def addProgress(): # icon/progress if data: if switch == 'i' and hasattr(data, 'icon') and data.icon is not None: res.append( MultiContentEntryPixmapAlphaBlend( pos=(colX, self.partIconeShift), size=(iconSize, data.icon.size().height()), png=data.icon)) elif switch in ('p', 's'): if hasattr(data, 'part') and data.part > 0: res.append( MultiContentEntryProgress(pos=(colX, self.pbarShift), size=(iconSize, self.pbarHeight), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) elif hasattr(data, 'icon') and data.icon is not None: res.append( MultiContentEntryPixmapAlphaBlend( pos=(colX, self.pbarShift), size=(iconSize, self.pbarHeight), png=data.icon)) return iconSize serviceref = info.getInfoString(serviceref, iServiceInformation.sServiceref) displayPicon = None if piconWidth > 0: # Picon picon = getPiconName(serviceref) if picon != "": displayPicon = loadPNG(picon) if displayPicon is not None: res.append( MultiContentEntryPixmapAlphaBlend( pos=(colX, 0), size=(piconWidth, ih), png=displayPicon, backcolor=None, backcolor_sel=None, flags=BT_SCALE | BT_KEEP_ASPECT_RATIO | BT_HALIGN_CENTER | BT_VALIGN_CENTER)) colX = piconWidth else: colX = addProgress() # Recording name res.append( MultiContentEntryText(pos=(colX, 0), size=(width - iconSize - space - durationWidth - dateWidth - r - colX, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=data.txt)) colX = width - iconSize - space - durationWidth - dateWidth - r if piconWidth > 0: colX = addProgress() # Duration Mins if durationWidth > 0: if data: len = data.len if len > 0: len = ngettext("%d Min", "%d Mins", (len / 60)) % (len / 60) res.append( MultiContentEntryText(pos=(colX + 425, 0), size=(durationWidth, ih), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=len)) # Date begin_string = "" if begin > 0: if config.movielist.use_fuzzy_dates.value: begin_string = ', '.join(FuzzyTime(begin, inPast=True)) else: begin_string = strftime( "%s, %s" % (config.usage.date.daylong.value, config.usage.time.short.value), localtime(begin)) res.append( MultiContentEntryText(pos=(width - dateWidth - r - 130, 0), size=(dateWidth + 130, ih), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=begin_string)) return res
def buildTimerEntry(self, timer, processed): width = self.l.getItemSize().width() res = [None] res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, width, 30, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, timer.service_ref.getServiceName())) res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 30, width, 20, 1, RT_HALIGN_LEFT | RT_VALIGN_CENTER, timer.name)) repeatedtext = "" days = (_("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun")) if timer.repeated: flags = timer.repeated count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if (flags & 1 == 1): if (count != 0): repeatedtext += ", " repeatedtext += days[x] count += 1 flags = flags >> 1 if timer.justplay: if timer.end - timer.begin < 4: # rounding differences res.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 50, width - 150, 20, 1, RT_HALIGN_LEFT | RT_VALIGN_CENTER, repeatedtext + ((" %s " + _("(ZAP)")) % (FuzzyTime(timer.begin)[1])))) else: res.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 50, width - 150, 20, 1, RT_HALIGN_LEFT | RT_VALIGN_CENTER, repeatedtext + ((" %s ... %s (%d " + _("mins") + ") ") % (FuzzyTime(timer.begin)[1], FuzzyTime(timer.end)[1], (timer.end - timer.begin) / 60)) + _("(ZAP)"))) else: res.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 50, width - 150, 20, 1, RT_HALIGN_LEFT | RT_VALIGN_CENTER, repeatedtext + ((" %s ... %s (%d " + _("mins") + ")") % (FuzzyTime(timer.begin)[1], FuzzyTime(timer.end)[1], (timer.end - timer.begin) / 60)))) else: if timer.justplay: if timer.end - timer.begin < 4: res.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 50, width - 150, 20, 1, RT_HALIGN_LEFT | RT_VALIGN_CENTER, repeatedtext + (("%s, %s " + _("(ZAP)")) % (FuzzyTime(timer.begin))))) else: res.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 50, width - 150, 20, 1, RT_HALIGN_LEFT | RT_VALIGN_CENTER, repeatedtext + (("%s, %s ... %s (%d " + _("mins") + ") ") % (FuzzyTime(timer.begin) + FuzzyTime(timer.end)[1:] + ((timer.end - timer.begin) / 60, ))) + _("(ZAP)"))) else: res.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 50, width - 150, 20, 1, RT_HALIGN_LEFT | RT_VALIGN_CENTER, repeatedtext + (("%s, %s ... %s (%d " + _("mins") + ")") % (FuzzyTime(timer.begin) + FuzzyTime(timer.end)[1:] + ((timer.end - timer.begin) / 60, ))))) if not processed: if timer.state == TimerEntry.StateWaiting: state = _("waiting") elif timer.state == TimerEntry.StatePrepared: state = _("about to start") elif timer.state == TimerEntry.StateRunning: if timer.justplay: state = _("zapped") else: state = _("recording...") elif timer.state == TimerEntry.StateEnded: state = _("done!") else: state = _("<unknown>") else: state = _("done!") if timer.disabled: state = _("disabled") res.append((eListboxPythonMultiContent.TYPE_TEXT, width - 150, 50, 150, 20, 1, RT_HALIGN_RIGHT | RT_VALIGN_CENTER, state)) if timer.disabled: png = LoadPixmap( resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/redx.png")) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 490, 5, 40, 40, png)) return res
def buildTimerEntry(self, timer, processed): height = self.l.getItemSize().height() width = self.l.getItemSize().width() res = [None] x = (2 * width) // 3 res.append((eListboxPythonMultiContent.TYPE_TEXT, 26, 2, x - 24, 25, 1, RT_HALIGN_LEFT | RT_VALIGN_TOP, timer.name)) res.append((eListboxPythonMultiContent.TYPE_TEXT, x, 0, width - x - 2, 25, 0, RT_HALIGN_RIGHT | RT_VALIGN_TOP, timer.service_ref.getServiceName())) days = (_("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun")) begin = FuzzyTime(timer.begin) if timer.repeated: repeatedtext = [] flags = timer.repeated for x in (0, 1, 2, 3, 4, 5, 6): if (flags & 1 == 1): repeatedtext.append(days[x]) flags = flags >> 1 repeatedtext = ", ".join(repeatedtext) if self.iconRepeat: res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 2, 2, 20, 20, self.iconRepeat)) else: repeatedtext = begin[0] # date if timer.justplay: text = repeatedtext + ((" %s " + _("(ZAP)")) % (begin[1])) else: text = repeatedtext + ((" %s ... %s (%d " + _("mins") + ")") % (begin[1], FuzzyTime(timer.end)[1], (timer.end - timer.begin) / 60)) res.append((eListboxPythonMultiContent.TYPE_TEXT, 148, 24, width - 150, 25, 1, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, text)) icon = None if not processed: if timer.state == TimerEntry.StateWaiting: state = _("waiting") icon = self.iconWait elif timer.state == TimerEntry.StatePrepared: state = _("about to start") icon = self.iconPrepared elif timer.state == TimerEntry.StateRunning: if timer.justplay: state = _("zapped") icon = self.iconZapped else: state = _("recording...") icon = self.iconRecording elif timer.state == TimerEntry.StateEnded: state = _("done!") icon = self.iconDone else: state = _("<unknown>") icon = None else: state = _("done!") icon = self.iconDone if timer.disabled: state = _("disabled") icon = self.iconDisabled if timer.failed: state = _("failed") icon = self.iconFailed res.append((eListboxPythonMultiContent.TYPE_TEXT, 26, 24, 126, 20, 1, RT_HALIGN_LEFT | RT_VALIGN_TOP, state)) if icon: res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 2, 25, 20, 20, icon)) if timer.isAutoTimer: res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 2, 2, 20, 20, self.iconAutoTimer)) line = LoadPixmap(resolveFilename(SCOPE_ACTIVE_SKIN, "div-h.png")) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 0, height - 2, width, 2, line)) return res
def buildListboxEntry(self, timer): if not timer.enabled: icon = self.iconDisabled else: icon = self.iconEnabled if timer.justplay: rectypeicon = self.iconZapped else: rectypeicon = self.iconRecording channel = [] for t in timer.services: channel.append(ServiceReference(t).getServiceName()) if len(channel) > 0: channel = ", ".join(channel) else: channel = _('All channels') height = self.l.getItemSize().height() width = self.l.getItemSize().width() res = [None] x = (2 * width) // 3 res.append((eListboxPythonMultiContent.TYPE_TEXT, 52, 2, x - 26, 25, 0, RT_HALIGN_LEFT | RT_VALIGN_BOTTOM, timer.name)) res.append((eListboxPythonMultiContent.TYPE_TEXT, 2, 47, width - 4, 25, 1, RT_HALIGN_LEFT | RT_VALIGN_BOTTOM, channel)) if timer.include[3]: total = len(timer.include[3]) count = 0 days = [] while count + 1 <= total: day = timer.include[3][count] day = { '0': _("Mon"), '1': _("Tue"), '2': _("Wed"), '3': _("Thur"), '4': _("Fri"), '5': _("Sat"), '6': _("Sun"), "weekend": _("Weekend"), "weekday": _("Weekday") }[day] days.append(day) count += 1 days = ', '.join(days) else: days = _("Everyday") res.append( (eListboxPythonMultiContent.TYPE_TEXT, float(width) / 10 * 4.5 + 1, 25, float(width) / 10 * 5.5 - 5, 25, 1, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, days)) if timer.hasTimespan(): nowt = time() now = localtime(nowt) begintime = int( mktime((now.tm_year, now.tm_mon, now.tm_mday, timer.timespan[0][0], timer.timespan[0][1], 0, now.tm_wday, now.tm_yday, now.tm_isdst))) endtime = int( mktime((now.tm_year, now.tm_mon, now.tm_mday, timer.timespan[1][0], timer.timespan[1][1], 0, now.tm_wday, now.tm_yday, now.tm_isdst))) timespan = ((" %s ... %s") % (FuzzyTime(begintime)[1], FuzzyTime(endtime)[1])) else: timespan = _("Any time") res.append((eListboxPythonMultiContent.TYPE_TEXT, width - 150 - 4, 0, 150, 25, 1, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, timespan)) if timer.hasTimeframe(): begin = strftime("%a, %d %b", localtime(timer.getTimeframeBegin())) end = strftime("%a, %d %b", localtime(timer.getTimeframeEnd())) timespan = (("%s ... %s") % (begin, end)) res.append((eListboxPythonMultiContent.TYPE_TEXT, 2, 25, float(width) / 10 * 4.5 - 5, 25, 1, RT_HALIGN_LEFT | RT_VALIGN_BOTTOM, timespan)) if icon: res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 2, 2, 24, 25, icon)) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 28, 5, 24, 25, rectypeicon)) try: devide = LoadPixmap(resolveFilename(SCOPE_ACTIVE_SKIN, "div-h.png")) except: devide = LoadPixmap( resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, height - 2, width, 2, devide)) return res
def buildMovieListEntry(self, serviceref, info, begin, data): width = self.l.getItemSize().width() iconSize = self.iconsWidth space = self.spaceIconeText r = self.spaceRight pathName = serviceref.getPath() res = [None] if serviceref.flags & eServiceReference.mustDescent: # Directory # Name is full path name valign_center = 0 if self.list_type == MovieList.LISTTYPE_MINIMAL: valign_center = RT_VALIGN_CENTER x = iconSize + space tn = self.treeDescription if info is None: # Special case: "parent" txt = ".." else: p = os.path.split(pathName) if not p[1]: # if path ends in '/', p is blank. p = os.path.split(p[0]) txt = p[1] if txt == ".Trash": res.append( MultiContentEntryPixmapAlphaTest( pos=(0, self.trashShift), size=(iconSize, self.iconTrash.size().height()), png=self.iconTrash)) res.append( MultiContentEntryText( pos=(x, 0), size=(width - x - tn - r, self.itemHeight), font=0, flags=RT_HALIGN_LEFT | valign_center, text=_("Deleted items"))) res.append( MultiContentEntryText(pos=(width - tn - r, 0), size=(tn, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | valign_center, text=_("Trash can"))) return res res.append( MultiContentEntryPixmapAlphaTest(pos=(0, self.dirShift), size=(iconSize, iconSize), png=self.iconFolder)) res.append( MultiContentEntryText(pos=(x, 0), size=(width - x - tn - r, self.itemHeight), font=0, flags=RT_HALIGN_LEFT | valign_center, text=txt)) res.append( MultiContentEntryText(pos=(width - tn - r, 0), size=(tn, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | valign_center, text=_("Directory"))) return res if (data == -1) or (data is None): data = MovieListData() cur_idx = self.l.getCurrentSelectionIndex() x = self.list[cur_idx] # x = ref,info,begin,... if config.usage.load_length_of_movies_in_moviellist.value: data.len = x[1].getLength(x[0]) #recalc the movie length... else: data.len = 0 #dont recalc movielist to speedup loading the list self.list[cur_idx] = ( x[0], x[1], x[2], data ) #update entry in list... so next time we don't need to recalc data.txt = info.getName(serviceref) if config.movielist.hide_extensions.value: fileName, fileExtension = os.path.splitext(data.txt) if fileExtension in KNOWN_EXTENSIONS: data.txt = fileName data.icon = None data.part = None if os.path.split(pathName)[1] in self.runningTimers: if self.playInBackground and serviceref == self.playInBackground: data.icon = self.iconMoviePlayRec else: data.icon = self.iconMovieRec elif self.playInBackground and serviceref == self.playInBackground: data.icon = self.iconMoviePlay else: switch = config.usage.show_icons_in_movielist.value data.part = moviePlayState(pathName + '.cuts', serviceref, data.len) if switch == 'i': if data.part is None: if config.usage.movielist_unseen.value: data.icon = self.iconUnwatched else: data.icon = self.iconPart[data.part // 25] elif switch == 'p' or switch == 's': if data.part is None: if config.usage.movielist_unseen.value: data.part = 0 data.partcol = 0x808080 else: data.partcol = 0xf0f0f0 service = ServiceReference( info.getInfoString(serviceref, iServiceInformation.sServiceref)) if service is None: data.serviceName = None else: data.serviceName = service.getServiceName() data.description = info.getInfoString( serviceref, iServiceInformation.sDescription) len = data.len if len > 0: len = "%d:%02d" % (len / 60, len % 60) else: len = "" if data.icon is not None: if self.list_type in (MovieList.LISTTYPE_COMPACT_DESCRIPTION, MovieList.LISTTYPE_COMPACT): pos = (0, self.partIconeShiftCompact) elif self.list_type == MovieList.LISTTYPE_ORIGINAL: pos = (0, self.partIconeShiftOriginal) else: pos = (0, self.partIconeShiftMinimal) res.append( MultiContentEntryPixmapAlphaTest( pos=pos, size=(iconSize, data.icon.size().height()), png=data.icon)) switch = config.usage.show_icons_in_movielist.value if switch in ('p', 's'): if switch == 'p': iconSize = self.pbarLargeWidth if data.part is not None: res.append( MultiContentEntryProgress(pos=(0, self.pbarShift), size=(iconSize, self.pbarHeight), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) elif switch == 'i': pass else: iconSize = 0 begin_string = "" if begin > 0: begin_string = ', '.join(FuzzyTime(begin, inPast=True)) ih = self.itemHeight if self.list_type == MovieList.LISTTYPE_ORIGINAL: fc, sc = self.columnsOriginal[0], self.columnsOriginal[1] ih1 = (ih * 2) / 5 # 75 -> 30 ih2 = (ih * 2) / 3 # 75 -> 50 res.append( MultiContentEntryText(pos=(iconSize + space, 0), size=(width - fc - r, ih1), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) if self.tags: res.append( MultiContentEntryText(pos=(width - fc - r, 0), size=(fc, ih1), font=2, flags=RT_HALIGN_RIGHT, text=info.getInfoString( serviceref, iServiceInformation.sTags))) if data.serviceName: res.append( MultiContentEntryText(pos=(sc - r, ih2), size=(sc, ih2 - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.serviceName)) else: if data.serviceName: res.append( MultiContentEntryText(pos=(width - fc - r, 0), size=(fc, ih1), font=2, flags=RT_HALIGN_RIGHT, text=data.serviceName)) res.append( MultiContentEntryText(pos=(0, ih1), size=(width - r, ih2 - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.description)) res.append( MultiContentEntryText(pos=(0, ih2), size=(sc - r, ih - ih2), font=1, flags=RT_HALIGN_LEFT, text=begin_string)) if len: res.append( MultiContentEntryText(pos=(width - sc - r, ih2), size=(sc, ih - ih2), font=1, flags=RT_HALIGN_RIGHT, text=len)) elif self.list_type == MovieList.LISTTYPE_COMPACT_DESCRIPTION: ih1 = ((ih * 8) + 14) / 15 # 37 -> 20, round up if len: lenSize = 58 * ih / 37 else: lenSize = 0 fc, sc, tc = self.columnsCompactDescription[ 0], self.columnsCompactDescription[ 1], self.columnsCompactDescription[2] res.append( MultiContentEntryText(pos=(iconSize + space, 0), size=(width - sc - r, ih1), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) res.append( MultiContentEntryText(pos=(0, ih1), size=(width - tc - lenSize - r, ih - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.description)) res.append( MultiContentEntryText(pos=(width - fc - r, 6), size=(fc, ih1), font=1, flags=RT_HALIGN_RIGHT, text=begin_string)) if data.serviceName: res.append( MultiContentEntryText(pos=(width - tc - lenSize - r, ih1), size=(tc, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=data.serviceName)) if lenSize: res.append( MultiContentEntryText(pos=(width - lenSize - r, ih1), size=(lenSize, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=len)) elif self.list_type == MovieList.LISTTYPE_COMPACT: col = self.compactColumn ih1 = ((ih * 8) + 14) / 15 # 37 -> 20, round up if len: lenSize = 2 * ih else: lenSize = 0 res.append( MultiContentEntryText(pos=(iconSize + space, 0), size=(width - lenSize - iconSize - space - r, ih1), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) if self.tags: res.append( MultiContentEntryText(pos=(width - col - r, ih1), size=(col, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=info.getInfoString( serviceref, iServiceInformation.sTags))) if data.serviceName: res.append( MultiContentEntryText(pos=(col, ih1), size=(col, ih - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.serviceName)) else: if data.serviceName: res.append( MultiContentEntryText(pos=(width - col - r, ih1), size=(col, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=data.serviceName)) res.append( MultiContentEntryText(pos=(0, ih1), size=(col, ih - ih1), font=1, flags=RT_HALIGN_LEFT, text=begin_string)) if lenSize: res.append( MultiContentEntryText(pos=(width - lenSize - r, 0), size=(lenSize, ih1), font=0, flags=RT_HALIGN_RIGHT, text=len)) else: if (self.descr_state == MovieList.SHOW_DESCRIPTION) or not len: dateSize = ih * 145 / 25 # 25 -> 145 res.append( MultiContentEntryText( pos=(iconSize + space, 0), size=(width - iconSize - space - dateSize - r, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=data.txt)) res.append( MultiContentEntryText(pos=(width - dateSize - r, 2), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=begin_string)) else: lenSize = ih * 3 # 25 -> 75 res.append( MultiContentEntryText(pos=(iconSize + space, 0), size=(width - lenSize - iconSize - space - r, ih), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) res.append( MultiContentEntryText(pos=(width - lenSize - r, 0), size=(lenSize, ih), font=0, flags=RT_HALIGN_RIGHT, text=len)) return res
def buildTimerEntry(self, timer, processed): height = self.l.getItemSize().height() width = self.l.getItemSize().width() res = [None] piconWidth = 100 if config.usage.timerlist_showpicons.value else 0 serviceName = timer.service_ref.getServiceName() serviceNameWidth = getTextBoundarySize(self.instance, self.serviceNameFont, self.l.getItemSize(), serviceName).width() nameWidth = width - serviceNameWidth - self.iconWidth - self.iconMargin - piconWidth if nameWidth < 200: serviceNameWidth = width - 200 - self.iconWidth - self.iconMargin - piconWidth def addPicon(): refstr = None if hasattr(timer.service_ref, 'sref'): refstr = str(timer.service_ref.sref) else: refstr = str(timer.service_ref) displayPicon = None picon = getPiconName(refstr) if picon != "": displayPicon = LoadPixmap(picon) if displayPicon is not None: res.append( MultiContentEntryPixmapAlphaBlend( pos=(colX, 0), size=(piconWidth, self.itemHeight), png=displayPicon, backcolor=None, backcolor_sel=None, flags=BT_SCALE | BT_KEEP_ASPECT_RATIO | BT_ALIGN_CENTER)) return piconWidth colX = 0 if config.usage.timerlist_showpicons.value: colX += addPicon() res.append( (eListboxPythonMultiContent.TYPE_TEXT, colX + self.iconWidth + self.iconMargin, 0, nameWidth, self.rowSplit, 2, RT_HALIGN_LEFT | RT_VALIGN_BOTTOM, timer.name)) res.append( (eListboxPythonMultiContent.TYPE_TEXT, width - serviceNameWidth, 0, serviceNameWidth, self.rowSplit, 0, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, serviceName)) begin = FuzzyTime(timer.begin) if timer.repeated: days = (_("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun")) repeatedtext = [] flags = timer.repeated for x in (0, 1, 2, 3, 4, 5, 6): if flags & 1 == 1: repeatedtext.append(days[x]) flags >>= 1 if repeatedtext == [ _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun") ]: repeatedtext = _('Everyday') elif repeatedtext == [ _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri") ]: repeatedtext = _('Weekday') elif repeatedtext == [_("Sat"), _("Sun")]: repeatedtext = _('Weekend') else: repeatedtext = ", ".join(repeatedtext) if self.iconRepeat: res.append( (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, colX + self.iconMargin, self.rowSplit + (self.itemHeight - self.rowSplit - self.iconHeight) / 2, self.iconWidth, self.iconHeight, self.iconRepeat)) else: repeatedtext = begin[0] # date if timer.justplay: extra_text = _("(ZAP)") if timer.pipzap: extra_text = _("(ZAP as PiP)") text = repeatedtext + ((" %s " + extra_text) % (begin[1])) else: text = repeatedtext + ((" %s ... %s (%d " + _("mins") + ")") % (begin[1], FuzzyTime(timer.end)[1], (timer.end - timer.begin) / 60)) icon = None if not processed: if timer.state == TimerEntry.StateWaiting: state = _("waiting") if timer.isAutoTimer: icon = self.iconAutoTimer else: icon = self.iconWait elif timer.state == TimerEntry.StatePrepared: state = _("about to start") icon = self.iconPrepared elif timer.state == TimerEntry.StateRunning: if timer.justplay: state = _("zapped") icon = self.iconZapped else: state = _("recording...") icon = self.iconRecording elif timer.state == TimerEntry.StateEnded: state = _("done!") icon = self.iconDone else: state = _("<unknown>") icon = None elif timer.disabled: state = _("disabled") icon = self.iconDisabled elif timer.failed: state = _("failed") icon = self.iconFailed else: state = _("done!") icon = self.iconDone icon and res.append( (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, colX + self.iconMargin / 2, (self.rowSplit - self.iconHeight) / 2, self.iconWidth, self.iconHeight, icon)) orbpos = self.getOrbitalPos(timer.service_ref) orbposWidth = getTextBoundarySize(self.instance, self.font, self.l.getItemSize(), orbpos).width() res.append( (eListboxPythonMultiContent.TYPE_TEXT, colX + self.satPosLeft, self.rowSplit, orbposWidth, self.itemHeight - self.rowSplit, 1, RT_HALIGN_LEFT | RT_VALIGN_TOP, orbpos)) res.append((eListboxPythonMultiContent.TYPE_TEXT, colX + self.iconWidth + self.iconMargin, self.rowSplit, self.satPosLeft - self.iconWidth - self.iconMargin, self.itemHeight - self.rowSplit, 1, RT_HALIGN_LEFT | RT_VALIGN_TOP, state)) res.append((eListboxPythonMultiContent.TYPE_TEXT, colX + self.satPosLeft + orbposWidth, self.rowSplit, width - self.satPosLeft - orbposWidth - colX, self.itemHeight - self.rowSplit, 1, RT_HALIGN_RIGHT | RT_VALIGN_TOP, text)) line = LoadPixmap(resolveFilename(SCOPE_ACTIVE_SKIN, "div-h.png")) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 0, height - 2, width, 2, line)) return res
def getMovieList(rargs=None, locations=None): """ Generate a `dict` containing movie items information. .. deprecated:: 0.86 Args: rargs (dict): request object's args locations(list): paths where recordings might be stored Returns: dict: movie items """ movieliste = [] tag = None directory = None fields = None bookmarklist = [] if rargs and "tag" in rargs.keys(): tag = rargs["tag"][0] if rargs and "dirname" in rargs.keys(): directory = rargs["dirname"][0] if rargs and "fields" in rargs.keys(): fields = rargs["fields"][0] if directory is None: directory = MovieSelection.defaultMoviePath() else: try: directory.decode('utf-8') except UnicodeDecodeError: try: directory = directory.decode("cp1252").encode("utf-8") except UnicodeDecodeError: directory = directory.decode("iso-8859-1").encode("utf-8") if not directory: directory = MOVIE_LIST_ROOT_FALLBACK if directory[-1] != "/": directory += "/" if not os.path.isdir(directory): return { "movies": [], "locations": [], "bookmarks": [], "directory": [], } root = eServiceReference(MOVIE_LIST_SREF_ROOT + directory) for item in sorted(os.listdir(directory)): abs_p = os.path.join(directory, item) if os.path.isdir(abs_p): bookmarklist.append(item) folders = [root] if rargs and "recursive" in rargs.keys(): for f in bookmarklist: if f[-1] != "/": f += "/" ff = eServiceReference(MOVIE_LIST_SREF_ROOT + directory + f) folders.append(ff) # get all locations if locations is not None: folders = [] for f in locations: if f[-1] != "/": f += "/" ff = eServiceReference(MOVIE_LIST_SREF_ROOT + f) folders.append(ff) for root in folders: movielist = MovieList(None) movielist.load(root, None) if tag is not None: movielist.reload(root=root, filter_tags=[tag]) for (serviceref, info, begin, unknown) in movielist.list: if serviceref.flags & eServiceReference.mustDescent: continue length_minutes = 0 txtdesc = "" filename = '/'.join(serviceref.toString().split("/")[1:]) filename = '/' + filename name, ext = os.path.splitext(filename) sourceRef = ServiceReference( info.getInfoString( serviceref, iServiceInformation.sServiceref)) rtime = info.getInfo( serviceref, iServiceInformation.sTimeCreate) movie = { 'filename': filename, 'filename_stripped': filename.split("/")[-1], 'serviceref': serviceref.toString(), 'length': "?:??", 'lastseen': 0, 'filesize_readable': '', 'recordingtime': rtime, 'begintime': 'undefined', 'eventname': mangle_epg_text( ServiceReference(serviceref).getServiceName()), 'servicename': mangle_epg_text(sourceRef.getServiceName()), 'tags': info.getInfoString(serviceref, iServiceInformation.sTags), 'fullname': serviceref.toString(), } if rtime > 0: fuzzy_rtime = FuzzyTime(rtime) movie['begintime'] = fuzzy_rtime[0] + ", " + fuzzy_rtime[1] try: length_minutes = info.getLength(serviceref) except BaseException: pass if length_minutes: movie['length'] = "%d:%02d" % ( length_minutes / 60, length_minutes % 60) if fields is None or 'pos' in fields: movie['lastseen'] = getPosition( filename + '.cuts', length_minutes) if fields is None or 'desc' in fields: txtfile = name + '.txt' if ext.lower() != '.ts' and os.path.isfile(txtfile): with open(txtfile, "rb") as handle: txtdesc = ''.join(handle.readlines()) event = info.getEvent(serviceref) extended_description = event and event.getExtendedDescription() or "" # NOQA if extended_description == '' and txtdesc != '': extended_description = txtdesc movie['descriptionExtended'] = unicode( extended_description, 'utf_8', errors='ignore').encode( 'utf_8', 'ignore') desc = info.getInfoString( serviceref, iServiceInformation.sDescription) movie['description'] = unicode( desc, 'utf_8', errors='ignore').encode( 'utf_8', 'ignore') if fields is None or 'size' in fields: size = 0 sz = '' try: size = os.stat(filename).st_size if size > 1073741824: sz = "%.2f %s" % ((size / 1073741824.), _("GB")) elif size > 1048576: sz = "%.2f %s" % ((size / 1048576.), _("MB")) elif size > 1024: sz = "%.2f %s" % ((size / 1024.), _("kB")) except BaseException: pass movie['filesize'] = size movie['filesize_readable'] = sz movieliste.append(movie) if locations is None: return { "movies": movieliste, "bookmarks": bookmarklist, "directory": directory } return { "movies": movieliste, "locations": locations }
def buildListboxEntry(self, timer): if self.style_autotimerslist == "standard": size = self.l.getItemSize() color = None if not timer.enabled: color = self.colorDisabled return [ None, (eListboxPythonMultiContent.TYPE_TEXT, 5, 0, size.width() - 5, size.height(), 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, timer.name, color, color) ] else: if not timer.enabled: icon = self.iconDisabled else: icon = self.iconEnabled if timer.justplay: rectypeicon = self.iconZapped else: rectypeicon = self.iconRecording channels = [] bouquets = [] channel = "" if timer.services: for t in timer.services: channels.append(ServiceReference(t).getServiceName()) if timer.bouquets: for t in timer.bouquets: bouquets.append(ServiceReference(t).getServiceName()) if channels or bouquets: if channels: channel = _("[S] ") channel += ", ".join(channels) channel += " " if bouquets: channel += _("[B] ") channel += ", ".join(bouquets) else: channel = _("All channels") if timer.searchType == "favoritedesc": channel = _("[B] ") + channel height = self.l.getItemSize().height() width = self.l.getItemSize().width() res = [None] x = (2 * width) // 3 nx, ny, nw, nh = skin.parameters.get("AutotimerListTimerName", (52, 2, 26, 25)) res.append((eListboxPythonMultiContent.TYPE_TEXT, nx, ny, x - nw, nh, 0, RT_HALIGN_LEFT | RT_VALIGN_BOTTOM, timer.name)) nx, ny, nw, nh = skin.parameters.get("AutotimerListChannels", (2, 47, 4, 25)) res.append((eListboxPythonMultiContent.TYPE_TEXT, nx, ny, width - nw, nh, 1, RT_HALIGN_LEFT | RT_VALIGN_BOTTOM, channel)) if timer.include[3]: total = len(timer.include[3]) count = 0 days = [] while count + 1 <= total: day = timer.include[3][count] day = { '0': _("Mon"), '1': _("Tue"), '2': _("Wed"), '3': _("Thur"), '4': _("Fri"), '5': _("Sat"), '6': _("Sun"), "weekend": _("Weekend"), "weekday": _("Weekday") }[day] days.append(day) count += 1 days = ', '.join(days) else: days = _("Everyday") dx, ny, dw, nh = skin.parameters.get("AutotimerListDays", (1, 25, 5, 25)) res.append((eListboxPythonMultiContent.TYPE_TEXT, float(width) / 10 * 4.5 + dx, ny, float(width) / 10 * 5.5 - dw, nh, 1, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, days)) if timer.hasTimespan(): nowt = time() now = localtime(nowt) begintime = int(mktime((now.tm_year, now.tm_mon, now.tm_mday, timer.timespan[0][0], timer.timespan[0][1], 0, now.tm_wday, now.tm_yday, now.tm_isdst))) endtime = int(mktime((now.tm_year, now.tm_mon, now.tm_mday, timer.timespan[1][0], timer.timespan[1][1], 0, now.tm_wday, now.tm_yday, now.tm_isdst))) timespan = ((" %s ... %s") % (FuzzyTime(begintime)[1], FuzzyTime(endtime)[1])) else: timespan = _("Any time") dx, ny, nw, nh = skin.parameters.get("AutotimerListHasTimespan", (154, 1, 150, 25)) res.append((eListboxPythonMultiContent.TYPE_TEXT, width - dx, ny, nw, nh, 1, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, timespan)) if timer.hasTimeframe(): begin = strftime("%a, %d %b", localtime(timer.getTimeframeBegin())) end = strftime("%a, %d %b", localtime(timer.getTimeframeEnd())) timespan = (("%s ... %s") % (begin, end)) nx, ny, nw, nh = skin.parameters.get("AutotimerListTimespan", (2, 25, 5, 25)) res.append((eListboxPythonMultiContent.TYPE_TEXT, nx, ny, float(width) / 10 * 4.5 - nw, nh, 1, RT_HALIGN_LEFT | RT_VALIGN_BOTTOM, timespan)) if icon: nx, ny, nw, nh = skin.parameters.get("AutotimerListIcon", (2, 3, 24, 25)) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, nx, ny, nw, nh, icon)) nx, ny, nw, nh = skin.parameters.get("AutotimerListRectypeicon", (28, 5, 24, 25)) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, nx, ny, nw, nh, rectypeicon)) devide = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "div-h.png")) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, height - 2, width, 1, devide)) return res
def buildTimerEntry(self, timer, processed): width = self.l.getItemSize().width() res = [None] serviceName = timer.service_ref.getServiceName() serviceNameWidth = getTextBoundarySize(self.instance, self.serviceNameFont, self.l.getItemSize(), serviceName).width() if 200 > width - serviceNameWidth - self.iconWidth - self.iconMargin: serviceNameWidth = width - 200 - self.iconWidth - self.iconMargin if timer.external: res.append((eListboxPythonMultiContent.TYPE_TEXT, width - serviceNameWidth, 0, serviceNameWidth, self.rowSplit, 0, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, serviceName, self.backupColor, self.backupColorSel, None, None, None, None)) else: res.append( (eListboxPythonMultiContent.TYPE_TEXT, width - serviceNameWidth, 0, serviceNameWidth, self.rowSplit, 0, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, serviceName)) res.append( (eListboxPythonMultiContent.TYPE_TEXT, self.iconWidth + self.iconMargin, 0, width - serviceNameWidth - self.iconWidth - self.iconMargin, self.rowSplit, 2, RT_HALIGN_LEFT | RT_VALIGN_BOTTOM, timer.name)) begin = FuzzyTime(timer.begin) if timer.repeated: days = (_("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun")) repeatedtext = [] flags = timer.repeated for x in (0, 1, 2, 3, 4, 5, 6): if flags & 1 == 1: repeatedtext.append(days[x]) flags >>= 1 repeatedtext = ", ".join(repeatedtext) if self.iconRepeat: res.append( (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, self.iconMargin / 2, self.rowSplit + (self.itemHeight - self.rowSplit - self.iconHeight) / 2, self.iconWidth, self.iconHeight, self.iconRepeat)) else: repeatedtext = begin[0] # date if "autotimer" in timer.flags: self.iconAutoTimer and res.append( (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, self.iconMargin / 2, self.rowSplit + (self.itemHeight - self.rowSplit - self.iconHeight) / 2, self.iconWidth, self.iconHeight, self.iconAutoTimer)) if timer.justplay: if timer.pipzap: extra_text = _("(ZAP as PiP)") else: extra_text = _("(ZAP)") text = repeatedtext + ((" %s %s") % (begin[1], extra_text)) else: text = repeatedtext + ((" %s ... %s (%d " + _("mins") + ")") % (begin[1], FuzzyTime(timer.end)[1], (timer.end - timer.begin) / 60)) icon = None if not processed and (not timer.disabled or (timer.repeated and timer.isRunning() and not timer.justplay)): if timer.state == TimerEntry.StateWaiting: state = _("waiting") if timer.isAutoTimer: icon = self.iconAutoTimer else: icon = self.iconWait elif timer.state == TimerEntry.StatePrepared: state = _("about to start") icon = self.iconPrepared elif timer.state == TimerEntry.StateRunning: if timer.justplay: state = _("zapped") icon = self.iconZapped else: state = _("recording...") icon = self.iconRecording elif timer.state == TimerEntry.StateEnded: state = _("done!") icon = self.iconDone else: state = _("<unknown>") icon = None elif timer.disabled: state = _("disabled") icon = self.iconDisabled else: state = _("done!") icon = self.iconDone icon and res.append( (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, self.iconMargin / 2, (self.rowSplit - self.iconHeight) / 2, self.iconWidth, self.iconHeight, icon)) orbpos = self.getOrbitalPos(timer.service_ref, timer.state) orbposWidth = getTextBoundarySize(self.instance, self.font, self.l.getItemSize(), orbpos).width() res.append( (eListboxPythonMultiContent.TYPE_TEXT, self.satPosLeft, self.rowSplit, orbposWidth, self.itemHeight - self.rowSplit, 1, RT_HALIGN_LEFT | RT_VALIGN_TOP, orbpos)) res.append((eListboxPythonMultiContent.TYPE_TEXT, self.iconWidth + self.iconMargin, self.rowSplit, self.satPosLeft - self.iconWidth - self.iconMargin, self.itemHeight - self.rowSplit, 1, RT_HALIGN_LEFT | RT_VALIGN_TOP, state)) res.append((eListboxPythonMultiContent.TYPE_TEXT, self.satPosLeft + orbposWidth, self.rowSplit, width - self.satPosLeft - orbposWidth, self.itemHeight - self.rowSplit, 1, RT_HALIGN_RIGHT | RT_VALIGN_TOP, text)) return res
def buildMovieListEntry(self, serviceref, info, begin, data): switch = config.usage.show_icons_in_movielist.value ext = config.movielist.useextlist.value width = self.l.getItemSize().width() pathName = serviceref.getPath() res = [None] if serviceref.flags & eServiceReference.mustDescent: if self.screenwidth and self.screenwidth == 1920: iconSize = 37 else: iconSize = 22 if info is None: txt = '..' else: p = os.path.split(pathName) if not p[1]: p = os.path.split(p[0]) txt = p[1] if txt == '.Trash': if self.screenwidth and self.screenwidth == 1920: res.append( MultiContentEntryPixmapAlphaBlend( pos=(3, 5), size=(iconSize, 37), png=self.iconTrash)) res.append( MultiContentEntryText(pos=(60, 5), size=(width - 166, self.itemHeight), font=0, flags=RT_HALIGN_LEFT, text=_('Deleted items'))) res.append( MultiContentEntryText(pos=(width - 145, 0), size=(145, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=_('Trashcan'))) return res else: res.append( MultiContentEntryPixmapAlphaBlend( pos=(0, 2), size=(iconSize, 24), png=self.iconTrash)) res.append( MultiContentEntryText(pos=(iconSize + 10, 0), size=(width - 166, self.itemHeight), font=0, flags=RT_HALIGN_LEFT, text=_('Deleted items'))) res.append( MultiContentEntryText(pos=(width - 150, 0), size=(145, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=_('Trashcan'))) return res if self.screenwidth and self.screenwidth == 1920: res.append( MultiContentEntryPixmapAlphaBlend(pos=(3, 5), size=(iconSize, iconSize), png=self.iconFolder)) res.append( MultiContentEntryText(pos=(60, 5), size=(width - 166, self.itemHeight), font=0, flags=RT_HALIGN_LEFT, text=txt)) res.append( MultiContentEntryText(pos=(width - 145, 0), size=(145, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=_('Directory'))) return res else: res.append( MultiContentEntryPixmapAlphaBlend(pos=(0, 2), size=(iconSize, iconSize), png=self.iconFolder)) res.append( MultiContentEntryText(pos=(iconSize + 10, 0), size=(width - 166, self.itemHeight), font=0, flags=RT_HALIGN_LEFT, text=txt)) res.append( MultiContentEntryText(pos=(width - 150, 0), size=(145, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=_('Directory'))) return res if data == -1 or data is None: data = MovieListData() cur_idx = self.l.getCurrentSelectionIndex() x = self.list[cur_idx] data.len = 0 self.list[cur_idx] = (x[0], x[1], x[2], data) data.txt = info.getName(serviceref) if config.movielist.hide_extensions.value: fileName, fileExtension = os.path.splitext(data.txt) if fileExtension in KNOWN_EXTENSIONS: data.txt = fileName data.icon = None data.part = None if os.path.split(pathName)[1] in self.runningTimers: if switch == 'i': if (self.playInBackground or self.playInForeground ) and serviceref == (self.playInBackground or self.playInForeground): data.icon = self.iconMoviePlayRec else: data.icon = self.iconMovieRec elif switch == 'p' or switch == 's': data.part = 100 if (self.playInBackground or self.playInForeground ) and serviceref == (self.playInBackground or self.playInForeground): data.partcol = 16762653 else: data.partcol = 16711709 elif (self.playInBackground or self.playInForeground) and serviceref == ( self.playInBackground or self.playInForeground): data.icon = self.iconMoviePlay else: data.part = moviePlayState(pathName + '.cuts', serviceref, data.len) if switch == 'i': if data.part is not None and data.part > 0: data.icon = self.iconPart[data.part // 25] elif config.usage.movielist_unseen.value: data.icon = self.iconUnwatched elif switch == 'p' or switch == 's': if data.part is not None and data.part > 0: data.partcol = 16762653 elif config.usage.movielist_unseen.value: data.part = 100 data.partcol = 2122547 len = data.len if len > 0: len = '%d:%02d' % (len / 60, len % 60) else: len = '' iconSize = 0 if switch == 'i': if self.screenwidth and self.screenwidth == 1920: iconSize = 42 res.append( MultiContentEntryPixmapAlphaBlend(pos=(2, 3), size=(iconSize, iconSize), png=data.icon)) else: iconSize = 22 res.append( MultiContentEntryPixmapAlphaBlend(pos=(0, 1), size=(iconSize, 20), png=data.icon)) elif switch == 'p': if self.screenwidth and self.screenwidth == 1920: iconSize = 42 else: iconSize = 48 if data.part is not None and data.part > 0: if self.screenwidth and self.screenwidth == 1920: res.append( MultiContentEntryProgress(pos=(0, 10), size=(iconSize + 5, 16), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) else: res.append( MultiContentEntryProgress(pos=(0, 5), size=(iconSize - 2, 16), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) elif self.screenwidth and self.screenwidth == 1920: res.append( MultiContentEntryPixmapAlphaBlend(pos=(0, 1), size=(iconSize, iconSize), png=data.icon)) else: res.append( MultiContentEntryPixmapAlphaBlend(pos=(0, 1), size=(iconSize, 20), png=data.icon)) elif switch == 's': if self.screenwidth and self.screenwidth == 1920: iconSize = 42 else: iconSize = 22 if data.part is not None and data.part > 0: if self.screenwidth and self.screenwidth == 1920: res.append( MultiContentEntryProgress(pos=(0, 10), size=(iconSize + 5, 16), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) else: res.append( MultiContentEntryProgress(pos=(0, 5), size=(iconSize - 2, 16), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) elif self.screenwidth and self.screenwidth == 1920: res.append( MultiContentEntryPixmapAlphaBlend(pos=(0, 1), size=(iconSize, iconSize), png=data.icon)) else: res.append( MultiContentEntryPixmapAlphaBlend(pos=(0, 1), size=(iconSize, 20), png=data.icon)) begin_string = '' if begin > 0: begin_string = ', '.join(FuzzyTime(begin, inPast=True)) if ext != '0': ih = self.itemHeight / 2 else: ih = self.itemHeight lenSize = ih * 3 dateSize = ih * 145 / 25 if ext != '0': getrec = info.getName(serviceref) fileName, fileExtension = os.path.splitext(getrec) desc = None picon = None service = None try: serviceHandler = eServiceCenter.getInstance() info = serviceHandler.info(serviceref) desc = info.getInfoString(serviceref, iServiceInformation.sDescription) ref = info.getInfoString(serviceref, iServiceInformation.sServiceref) service = ServiceReference(ref).getServiceName() except Exception as e: print('[MovieList] load extended infos get failed: ', e) if ext == '2': try: picon = getPiconName(ref) picon = loadPNG(picon) except Exception as e: print('[MovieList] load picon get failed: ', e) if fileExtension in RECORD_EXTENSIONS: if self.screenwidth and self.screenwidth == 1920: if ext == '1': res.append( MultiContentEntryText( pos=(iconSize + 20, 5), size=(width - iconSize - dateSize - dateSize / 2 - 15, ih), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) res.append( MultiContentEntryText( pos=(width - dateSize - dateSize / 2 - 5, 1), size=(dateSize + dateSize / 2, ih), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=service)) if ext == '2': piconSize = ih * 2 res.append( MultiContentEntryText(pos=(iconSize + 20, 5), size=(width - iconSize - dateSize - 15, ih + 2), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) res.append( MultiContentEntryPixmapAlphaTest( pos=(width - 48 - 5, 1), size=(piconSize, ih - 2), png=picon, flags=BT_SCALE | BT_KEEP_ASPECT_RATIO)) res.append( MultiContentEntryText(pos=(iconSize + 20, ih), size=(width - iconSize - dateSize - 15, ih), font=1, flags=RT_HALIGN_LEFT, text=desc)) res.append( MultiContentEntryText(pos=(width - dateSize, 0), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT, text=begin_string)) return res else: if ext == '1': res.append( MultiContentEntryText( pos=(iconSize + 8, 0), size=(width - iconSize - dateSize - dateSize / 2 - 15, ih), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) res.append( MultiContentEntryText( pos=(width - dateSize - dateSize / 2 - 5, 1), size=(dateSize + dateSize / 2, ih), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=service)) if ext == '2': piconSize = ih * 2 res.append( MultiContentEntryText(pos=(iconSize + 8, 0), size=(width - iconSize - dateSize - 15, ih + 2), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) res.append( MultiContentEntryPixmapAlphaTest( pos=(width - 48 - 5, 1), size=(piconSize, ih - 2), png=picon, flags=BT_SCALE | BT_KEEP_ASPECT_RATIO)) res.append( MultiContentEntryText(pos=(iconSize + 8, ih), size=(width - iconSize - dateSize - 15, ih), font=1, flags=RT_HALIGN_LEFT, text=desc)) res.append( MultiContentEntryText(pos=(width - dateSize - 5, ih), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=begin_string)) return res elif self.screenwidth and self.screenwidth == 1920: res.append( MultiContentEntryText(pos=(iconSize + 20, 5), size=(width - iconSize - dateSize - 15, ih), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) res.append( MultiContentEntryText(pos=(width - dateSize, ih), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT, text=begin_string)) return res else: res.append( MultiContentEntryText(pos=(iconSize + 8, 0), size=(width - iconSize - dateSize - 15, ih), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) res.append( MultiContentEntryText(pos=(width - dateSize - 5, ih), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=begin_string)) return res else: if self.screenwidth and self.screenwidth == 1920: res.append( MultiContentEntryText(pos=(iconSize + 20, 5), size=(width - iconSize - dateSize - 15, ih), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) res.append( MultiContentEntryText(pos=(width - dateSize, 0), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT, text=begin_string)) return res res.append( MultiContentEntryText(pos=(iconSize + 8, 0), size=(width - iconSize - dateSize - 15, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=data.txt)) res.append( MultiContentEntryText(pos=(width - dateSize - 5, 0), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=begin_string)) return res return
def buildMovieListEntry(self, serviceref, info, begin, data): switch = config.usage.show_icons_in_movielist.value ext = config.movielist.useextlist.value width = self.l.getItemSize().width() pathName = serviceref.getPath() res = [None] if ext != '0': ih = self.itemHeight // 2 else: ih = self.itemHeight if self.screenwidth and self.screenwidth == 1920: listBeginX = 3 listEndX = 3 listMarginX = 12 pathIconSize = 29 dataIconSize = 25 progressIconSize = 25 progressBarSize = 72 textPosY = 2 else: listBeginX = 2 listEndX = 2 listMarginX = 8 pathIconSize = 25 dataIconSize = 21 progressIconSize = 21 progressBarSize = 48 textPosY = 1 textPosX = listBeginX + dataIconSize + listMarginX if serviceref.flags & eServiceReference.mustDescent: # Directory iconSize = pathIconSize iconPosX = listBeginX - 1 iconPosY = ih / 2 - iconSize / 2 if iconPosY < iconPosX: iconPosY = iconPosX # Name is full path name if info is None: # Special case: "parent" txt = ".." else: p = os.path.split(pathName) if not p[1]: # if path ends in '/', p is blank. p = os.path.split(p[0]) txt = p[1] if txt == ".Trash": dateSize = getTextBoundarySize(self.instance, self.dateFont, self.l.getItemSize(), _("Trashcan")).width() res.append( MultiContentEntryPixmapAlphaBlend(pos=(iconPosX, iconPosY), size=(iconSize, iconSize), png=self.iconTrash)) res.append( MultiContentEntryText( pos=(textPosX, 0), size=(width - textPosX - dateSize - listMarginX - listEndX, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=_("Deleted items"))) res.append( MultiContentEntryText( pos=(width - dateSize - listEndX, textPosY), size=(dateSize, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=_("Trashcan"))) return res dateSize = getTextBoundarySize(self.instance, self.dateFont, self.l.getItemSize(), _("Directory")).width() res.append( MultiContentEntryPixmapAlphaBlend(pos=(iconPosX, iconPosY), size=(iconSize, iconSize), png=self.iconFolder)) res.append( MultiContentEntryText(pos=(textPosX, 0), size=(width - textPosX - dateSize - listMarginX - listEndX, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=txt)) res.append( MultiContentEntryText(pos=(width - dateSize - listEndX, textPosY), size=(dateSize, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=_("Directory"))) return res if (data == -1) or (data is None): data = MovieListData() cur_idx = self.l.getCurrentSelectionIndex() x = self.list[cur_idx] # x = ref,info,begin,... data.len = 0 #dont recalc movielist to speedup loading the list self.list[cur_idx] = ( x[0], x[1], x[2], data ) #update entry in list... so next time we don't need to recalc data.txt = info.getName(serviceref) if config.movielist.hide_extensions.value: fileName, fileExtension = os.path.splitext(data.txt) if fileExtension in KNOWN_EXTENSIONS: data.txt = fileName data.icon = None data.part = None if os.path.split(pathName)[1] in self.runningTimers: if switch == 'i': if (self.playInBackground or self.playInForeground ) and serviceref == (self.playInBackground or self.playInForeground): data.icon = self.iconMoviePlayRec else: data.icon = self.iconMovieRec elif switch == 'p' or switch == 's': data.part = 100 if (self.playInBackground or self.playInForeground ) and serviceref == (self.playInBackground or self.playInForeground): data.partcol = 0xffc71d else: data.partcol = 0xff001d elif (self.playInBackground or self.playInForeground) and serviceref == ( self.playInBackground or self.playInForeground): data.icon = self.iconMoviePlay else: data.part = moviePlayState(pathName + '.cuts', serviceref, data.len) if switch == 'i': if data.part is not None and data.part > 0: data.icon = self.iconPart[data.part // 25] else: if config.usage.movielist_unseen.value: data.icon = self.iconUnwatched elif switch == 'p' or switch == 's': if data.part is not None and data.part > 0: data.partcol = 0xffc71d else: if config.usage.movielist_unseen.value: data.part = 100 data.partcol = 0x206333 len = data.len if len > 0: len = "%d:%02d" % (len // 60, len % 60) else: len = "" iconSize = 0 if switch == 'i': iconSize = dataIconSize iconPosX = listBeginX iconPosY = ih // 2 - iconSize // 2 if iconPosY < iconPosX: iconPosY = iconPosX res.append( MultiContentEntryPixmapAlphaBlend(pos=(iconPosX, iconPosY), size=(iconSize, iconSize), png=data.icon)) elif switch == 'p': if data.part is not None and data.part > 0: iconSize = progressBarSize iconPosX = listBeginX iconPosY = ih // 2 - iconSize // 8 if iconPosY < iconPosX: iconPosY = iconPosX res.append( MultiContentEntryProgress(pos=(iconPosX, iconPosY), size=(iconSize, iconSize // 4), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) else: iconSize = dataIconSize iconPosX = listBeginX iconPosY = ih // 2 - iconSize // 2 if iconPosY < iconPosX: iconPosY = iconPosX res.append( MultiContentEntryPixmapAlphaBlend(pos=(iconPosX, iconPosY), size=(iconSize, iconSize), png=data.icon)) elif switch == 's': iconSize = progressIconSize iconPosX = listBeginX iconPosY = ih // 2 - iconSize // 2 if iconPosY < iconPosX: iconPosY = iconPosX if data.part is not None and data.part > 0: res.append( MultiContentEntryProgress(pos=(iconPosX, iconPosY), size=(iconSize, iconSize), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) else: res.append( MultiContentEntryPixmapAlphaBlend(pos=(iconPosX, iconPosY), size=(iconSize, iconSize), png=data.icon)) begin_string = "" if begin > 0: begin_string = ', '.join(FuzzyTime(begin, inPast=True)) dateSize = serviceSize = getTextBoundarySize(self.instance, self.dateFont, self.l.getItemSize(), begin_string).width() if iconSize: textPosX = listBeginX + iconSize + listMarginX else: textPosX = listBeginX if ext != '0': getrec = info.getName(serviceref) fileName, fileExtension = os.path.splitext(getrec) desc = None picon = None service = None try: serviceHandler = eServiceCenter.getInstance() info = serviceHandler.info(serviceref) desc = info.getInfoString( serviceref, iServiceInformation.sDescription) # get description ref = info.getInfoString( serviceref, iServiceInformation.sServiceref) # get reference service = ServiceReference( ref).getServiceName() # get service name serviceSize = getTextBoundarySize(self.instance, self.dateFont, self.l.getItemSize(), service).width() except Exception as e: print(('[MovieList] load extended infos get failed: ', e)) if ext == '2': try: picon = getPiconName(ref) picon = loadPNG(picon) except Exception as e: print(('[MovieList] load picon get failed: ', e)) if fileExtension in RECORD_EXTENSIONS: if ext == '1': res.append( MultiContentEntryText( pos=(textPosX, 0), size=(width - textPosX - serviceSize - listMarginX - listEndX, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=data.txt)) res.append( MultiContentEntryText( pos=(width - serviceSize - listEndX, textPosY), size=(serviceSize, ih), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=service)) if ext == '2': piconSize = ih * 1.667 res.append( MultiContentEntryText( pos=(textPosX, 0), size=(width - textPosX - dateSize - listMarginX - listEndX, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=data.txt)) res.append( MultiContentEntryPixmapAlphaTest( pos=(width - piconSize - listEndX, listEndX), size=(piconSize, ih), png=picon, flags=BT_SCALE | BT_KEEP_ASPECT_RATIO)) res.append( MultiContentEntryText(pos=(listBeginX, ih + textPosY), size=(width - listBeginX - dateSize - listMarginX - listEndX, ih), font=1, flags=RT_HALIGN_LEFT, text=desc)) res.append( MultiContentEntryText(pos=(width - dateSize - listEndX, ih + textPosY), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT, text=begin_string)) return res else: res.append( MultiContentEntryText(pos=(textPosX, 0), size=(width - textPosX - dateSize - listMarginX - listEndX, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=data.txt)) res.append( MultiContentEntryText(pos=(width - dateSize - listEndX, ih), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT, text=begin_string)) return res else: res.append( MultiContentEntryText(pos=(textPosX, 0), size=(width - textPosX - dateSize - listMarginX - listEndX, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=data.txt)) res.append( MultiContentEntryText(pos=(width - dateSize - listEndX, textPosY), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=begin_string)) return res
def buildMovieListEntry(self, serviceref, info, begin, data): width = self.l.getItemSize().width() pathName = serviceref.getPath() res = [None] if serviceref.flags & eServiceReference.mustDescent: # Directory iconSize = 22 # Name is full path name if info is None: # Special case: "parent" txt = ".." else: p = os.path.split(pathName) if not p[1]: # if path ends in '/', p is blank. p = os.path.split(p[0]) txt = p[1] if txt == ".Trash": res.append( MultiContentEntryPixmapAlphaTest(pos=(0, 1), size=(iconSize, 24), png=self.iconTrash)) res.append( MultiContentEntryText(pos=(iconSize + 2, 0), size=(width - 166, self.itemHeight), font=0, flags=RT_HALIGN_LEFT, text=_("Deleted items"))) res.append( MultiContentEntryText(pos=(width - 145, 4), size=(145, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT, text=_("Trash can"))) return res res.append( MultiContentEntryPixmapAlphaTest(pos=(0, 1), size=(iconSize, iconSize), png=self.iconFolder)) res.append( MultiContentEntryText(pos=(iconSize + 2, 0), size=(width - 166, self.itemHeight), font=0, flags=RT_HALIGN_LEFT, text=txt)) res.append( MultiContentEntryText(pos=(width - 145, 4), size=(145, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT, text=_("Directory"))) return res if (data == -1) or (data is None): data = MovieListData() cur_idx = self.l.getCurrentSelectionIndex() x = self.list[cur_idx] # x = ref,info,begin,... if config.usage.load_length_of_movies_in_moviellist.value: data.len = x[1].getLength(x[0]) #recalc the movie length... else: data.len = 0 #dont recalc movielist to speedup loading the list self.list[cur_idx] = ( x[0], x[1], x[2], data ) #update entry in list... so next time we don't need to recalc data.txt = info.getName(serviceref) if config.movielist.hide_extensions.value: fileName, fileExtension = os.path.splitext(data.txt) if fileExtension in KNOWN_EXTENSIONS: data.txt = fileName data.icon = None data.part = None if os.path.split(pathName)[1] in self.runningTimers: if self.playInBackground and serviceref == self.playInBackground: data.icon = self.iconMoviePlayRec else: data.icon = self.iconMovieRec elif self.playInBackground and serviceref == self.playInBackground: data.icon = self.iconMoviePlay else: switch = config.usage.show_icons_in_movielist.value data.part = moviePlayState(pathName + '.cuts', serviceref, data.len) if switch == 'i': if data.part is None: if config.usage.movielist_unseen.value: data.icon = self.iconUnwatched else: data.icon = self.iconPart[data.part // 25] elif switch == 'p' or switch == 's': if data.part is None: if config.usage.movielist_unseen.value: data.part = 0 data.partcol = 0x808080 else: data.partcol = 0xf0f0f0 service = ServiceReference( info.getInfoString(serviceref, iServiceInformation.sServiceref)) if service is None: data.serviceName = None else: data.serviceName = service.getServiceName() data.description = info.getInfoString( serviceref, iServiceInformation.sDescription) len = data.len if len > 0: len = "%d:%02d" % (len / 60, len % 60) else: len = "" if data.icon is not None: iconSize = 22 if self.list_type in (MovieList.LISTTYPE_COMPACT_DESCRIPTION, MovieList.LISTTYPE_COMPACT): pos = (0, 4) else: pos = (0, 5) res.append( MultiContentEntryPixmapAlphaTest(pos=pos, size=(iconSize, 20), png=data.icon)) switch = config.usage.show_icons_in_movielist.value if switch == 'p' or switch == 's': if switch == 'p': iconSize = 48 else: iconSize = 22 if data.part is not None: res.append( MultiContentEntryProgress(pos=(0, 5), size=(iconSize - 2, 16), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) elif switch == 'i': iconSize = 22 else: iconSize = 0 begin_string = "" if begin > 0: begin_string = ', '.join(FuzzyTime(begin, inPast=True)) ih = self.itemHeight if self.list_type == MovieList.LISTTYPE_ORIGINAL: ih1 = (ih * 2) / 5 # 75 -> 30 ih2 = (ih * 2) / 3 # 75 -> 50 res.append( MultiContentEntryText(pos=(iconSize, 0), size=(width - 182, ih1), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) if self.tags: res.append( MultiContentEntryText(pos=(width - 180, 0), size=(180, ih1), font=2, flags=RT_HALIGN_RIGHT, text=info.getInfoString( serviceref, iServiceInformation.sTags))) if data.serviceName: res.append( MultiContentEntryText(pos=(200, ih2), size=(200, ih2 - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.serviceName)) else: if data.serviceName: res.append( MultiContentEntryText(pos=(width - 180, 0), size=(180, ih1), font=2, flags=RT_HALIGN_RIGHT, text=data.serviceName)) res.append( MultiContentEntryText(pos=(0, ih1), size=(width, ih2 - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.description)) res.append( MultiContentEntryText(pos=(0, ih2), size=(200, ih - ih2), font=1, flags=RT_HALIGN_LEFT, text=begin_string)) if len: res.append( MultiContentEntryText(pos=(width - 200, ih2), size=(198, ih - ih2), font=1, flags=RT_HALIGN_RIGHT, text=len)) elif self.list_type == MovieList.LISTTYPE_COMPACT_DESCRIPTION: ih1 = ((ih * 8) + 14) / 15 # 37 -> 20, round up if len: lenSize = 58 * ih / 37 else: lenSize = 0 res.append( MultiContentEntryText(pos=(iconSize, 0), size=(width - 140, ih1), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) res.append( MultiContentEntryText(pos=(0, ih1), size=(width - 154 - lenSize, ih - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.description)) res.append( MultiContentEntryText(pos=(width - 120, 6), size=(120, ih1), font=1, flags=RT_HALIGN_RIGHT, text=begin_string)) if data.serviceName: res.append( MultiContentEntryText(pos=(width - 154 - lenSize, ih1), size=(154, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=data.serviceName)) if lenSize: res.append( MultiContentEntryText(pos=(width - lenSize, ih1), size=(lenSize, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=len)) elif self.list_type == MovieList.LISTTYPE_COMPACT: ih1 = ((ih * 8) + 14) / 15 # 37 -> 20, round up if len: lenSize = 2 * ih else: lenSize = 0 res.append( MultiContentEntryText(pos=(iconSize, 0), size=(width - lenSize - iconSize, ih1), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) if self.tags: res.append( MultiContentEntryText(pos=(width - 200, ih1), size=(200, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=info.getInfoString( serviceref, iServiceInformation.sTags))) if data.serviceName: res.append( MultiContentEntryText(pos=(200, ih1), size=(200, ih - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.serviceName)) else: if data.serviceName: res.append( MultiContentEntryText(pos=(width - 200, ih1), size=(200, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=data.serviceName)) res.append( MultiContentEntryText(pos=(0, ih1), size=(200, ih - ih1), font=1, flags=RT_HALIGN_LEFT, text=begin_string)) if lenSize: res.append( MultiContentEntryText(pos=(width - lenSize, 0), size=(lenSize, ih1), font=0, flags=RT_HALIGN_RIGHT, text=len)) else: if (self.descr_state == MovieList.SHOW_DESCRIPTION) or not len: dateSize = ih * 145 / 25 # 25 -> 145 res.append( MultiContentEntryText(pos=(iconSize, 0), size=(width - iconSize - dateSize, ih), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) res.append( MultiContentEntryText(pos=(width - dateSize, 4), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT, text=begin_string)) else: lenSize = ih * 3 # 25 -> 75 res.append( MultiContentEntryText(pos=(iconSize, 0), size=(width - lenSize - iconSize, ih), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) res.append( MultiContentEntryText(pos=(width - lenSize, 0), size=(lenSize, ih), font=0, flags=RT_HALIGN_RIGHT, text=len)) return res
def buildTimerEntry(self, timer, processed): height = self.l.getItemSize().height() width = self.l.getItemSize().width() res = [None] serviceName = ' ' + timer.service_ref.getServiceName() serviceNameWidth = getTextBoundarySize(self.instance, self.serviceNameFont, self.l.getItemSize(), serviceName).width() if 200 > width - serviceNameWidth - self.iconWidth - self.iconMargin: serviceNameWidth = width - 200 - self.iconWidth - self.iconMargin res.append((eListboxPythonMultiContent.TYPE_TEXT, width - serviceNameWidth, 0, serviceNameWidth, self.rowSplit, 0, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, serviceName)) res.append((eListboxPythonMultiContent.TYPE_TEXT, self.iconWidth + self.iconMargin, 0, width - serviceNameWidth - self.iconWidth - self.iconMargin, self.rowSplit, 2, RT_HALIGN_LEFT | RT_VALIGN_BOTTOM, timer.name)) begin = FuzzyTime(timer.begin) if timer.repeated: days = (_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')) repeatedtext = [] flags = timer.repeated for x in (0, 1, 2, 3, 4, 5, 6): if flags & 1 == 1: repeatedtext.append(days[x]) flags >>= 1 if repeatedtext == [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')]: repeatedtext = _('Everyday') elif repeatedtext == [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri')]: repeatedtext = _('Weekday') elif repeatedtext == [_('Sat'), _('Sun')]: repeatedtext = _('Weekend') else: repeatedtext = ', '.join(repeatedtext) if self.iconRepeat: res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, self.iconMargin / 2, self.rowSplit + (self.itemHeight - self.rowSplit - self.iconHeight) / 2, self.iconWidth, self.iconHeight, self.iconRepeat)) else: repeatedtext = begin[0] if timer.justplay: if timer.end > timer.begin + 3: text = repeatedtext + (' %s ... %s (' + _('ZAP') + ', %d ' + _('mins') + ')') % (begin[1], FuzzyTime(timer.end)[1], (timer.end - timer.begin) / 60) else: text = repeatedtext + (' %s (' + _('ZAP') + ')') % begin[1] else: text = repeatedtext + (' %s ... %s (%d ' + _('mins') + ')') % (begin[1], FuzzyTime(timer.end)[1], (timer.end - timer.begin) / 60) icon = None if not processed: if timer.state == TimerEntry.StateWaiting: state = _('waiting') if timer.isAutoTimer: icon = self.iconAutoTimer else: icon = self.iconWait elif timer.state == TimerEntry.StatePrepared: state = _('about to start') icon = self.iconPrepared elif timer.state == TimerEntry.StateRunning: if timer.justplay: state = _('zapped') icon = self.iconZapped else: state = _('recording...') icon = self.iconRecording elif timer.state == TimerEntry.StateEnded: state = _('done!') icon = self.iconDone else: state = _('<unknown>') icon = None elif timer.disabled: state = _('disabled') icon = self.iconDisabled elif timer.failed: state = _('failed') icon = self.iconFailed else: state = _('done!') icon = self.iconDone icon and res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, self.iconMargin / 2, (self.rowSplit - self.iconHeight) / 2, self.iconWidth, self.iconHeight, icon)) orbpos = self.getOrbitalPos(timer.service_ref) orbposWidth = getTextBoundarySize(self.instance, self.font, self.l.getItemSize(), orbpos).width() res.append((eListboxPythonMultiContent.TYPE_TEXT, self.satPosLeft, self.rowSplit, orbposWidth, self.itemHeight - self.rowSplit, 1, RT_HALIGN_LEFT | RT_VALIGN_TOP, orbpos)) res.append((eListboxPythonMultiContent.TYPE_TEXT, self.iconWidth + self.iconMargin, self.rowSplit, self.satPosLeft - self.iconWidth - self.iconMargin, self.itemHeight - self.rowSplit, 1, RT_HALIGN_LEFT | RT_VALIGN_TOP, state)) res.append((eListboxPythonMultiContent.TYPE_TEXT, self.satPosLeft + orbposWidth, self.rowSplit, width - self.satPosLeft - orbposWidth, self.itemHeight - self.rowSplit, 1, RT_HALIGN_RIGHT | RT_VALIGN_TOP, text)) line = LoadPixmap(resolveFilename(SCOPE_ACTIVE_SKIN, 'div-h.png')) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 0, height - 2, width, 2, line)) return res
def updateState(self): cur = self["timerlist"].getCurrent() if cur: self["description"].setText(cur.description) if self.key_red_choice != self.DELETE: self["actions"].actions.update( {"red": self.removeTimerQuestion}) self["key_red"].setText(_("Delete")) self.key_red_choice = self.DELETE if cur.disabled and (self.key_yellow_choice != self.ENABLE): self["actions"].actions.update( {"yellow": self.toggleDisabledState}) self["key_yellow"].setText(_("Enable")) self.key_yellow_choice = self.ENABLE elif cur.isRunning() and not cur.repeated and ( self.key_yellow_choice != self.STOP): self["actions"].actions.update( {"yellow": self.removeTimerQuestion}) self["key_yellow"].setText(_("Stop")) self.key_yellow_choice = self.STOP elif ((not cur.isRunning()) or cur.repeated) and (not cur.disabled) and ( self.key_yellow_choice != self.DISABLE): self["actions"].actions.update( {"yellow": self.toggleDisabledState}) self["key_yellow"].setText(_("Disable")) self.key_yellow_choice = self.DISABLE else: self["description"].setText(" ") if self.key_red_choice != self.EMPTY: self.removeAction("red") self["key_red"].setText(" ") self.key_red_choice = self.EMPTY if self.key_yellow_choice != self.EMPTY: self.removeAction("yellow") self["key_yellow"].setText(" ") self.key_yellow_choice = self.EMPTY showCleanup = True for x in self.list: if (not x[0].disabled) and (x[1] == True): break else: showCleanup = False if showCleanup and (self.key_blue_choice != self.CLEANUP): self["actions"].actions.update({"blue": self.cleanupQuestion}) self["key_blue"].setText(_("Cleanup")) self.key_blue_choice = self.CLEANUP elif (not showCleanup) and (self.key_blue_choice != self.EMPTY): self.removeAction("blue") self["key_blue"].setText(" ") self.key_blue_choice = self.EMPTY if len(self.list) == 0: return timer = self['timerlist'].getCurrent() if timer: try: name = str(timer.name) time = "%s %s ... %s" % (FuzzyTime( timer.begin)[0], FuzzyTime( timer.begin)[1], FuzzyTime(timer.end)[1]) duration = ("(%d " + _("mins") + ")") % ( (timer.end - timer.begin) / 60) service = str(timer.service_ref.getServiceName()) if timer.state == RealTimerEntry.StateWaiting: state = _("waiting") elif timer.state == RealTimerEntry.StatePrepared: state = _("about to start") elif timer.state == RealTimerEntry.StateRunning: if timer.justplay: state = _("zapped") else: state = _("recording...") elif timer.state == RealTimerEntry.StateEnded: state = _("done!") else: state = _("<unknown>") except: name = "" time = "" duration = "" service = "" else: name = "" time = "" duration = "" service = "" for cb in self.onChangedEntry: cb(name, time, duration, service, state) if config.usage.timerlist_show_epg.value: event = self.getEPGEvent(cur) if event: self["Event"].newEvent(event) self["ServiceEvent"].newService(cur.service_ref.ref)
def getMovieList(directory=None, tag=None, rargs=None, locations=None): movieliste = [] if directory is None: directory = MovieSelection.defaultMoviePath() if not directory: directory = "/media/" elif directory[-1] != "/": directory += "/" root = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + directory) bookmarklist = [ x for x in listdir(directory) if (x[0] != '.' and (isdir(join(directory, x)) or ( islink(join(directory, x)) and exists(join(directory, x))))) ] bookmarklist.sort() folders = [] folders.append(root) if rargs and "recursive" in rargs.keys(): for f in bookmarklist: if f[-1] != "/": f += "/" ff = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + directory + f) folders.append(ff) # get all locations if locations is not None: folders = [] for f in locations: if f[-1] != "/": f += "/" ff = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + f) folders.append(ff) if config.OpenWebif.parentalenabled.value: dir_is_protected = checkParentalProtection(directory) else: dir_is_protected = False import os if not dir_is_protected: for root in folders: movielist = MovieList(None) movielist.load(root, None) if tag != None: movielist.reload(root=root, filter_tags=[tag]) #??? loadLength = True for (serviceref, info, begin, unknown) in movielist.list: if serviceref.flags & eServiceReference.mustDescent: continue rtime = info.getInfo(serviceref, iServiceInformation.sTimeCreate) if rtime > 0: t = FuzzyTime(rtime) begin_string = t[0] + ", " + t[1] else: begin_string = "undefined" try: Len = info.getLength(serviceref) except: Len = None filename = '/'.join(serviceref.toString().split("/")[1:]) filename = '/' + filename pos = getPosition(filename + '.cuts', Len) # get txt name, ext = os.path.splitext(filename) ext = ext.lower() txtdesc = "" if ext != 'ts': txtfile = name + '.txt' if fileExists(txtfile): txtlines = open(txtfile).readlines() txtdesc = "" for line in txtlines: txtdesc += line if Len > 0: Len = "%d:%02d" % (Len / 60, Len % 60) else: Len = "?:??" sourceERef = info.getInfoString( serviceref, iServiceInformation.sServiceref) sourceRef = ServiceReference(sourceERef) event = info.getEvent(serviceref) ext = event and event.getExtendedDescription() or "" if ext == '' and txtdesc != '': ext = txtdesc desc = info.getInfoString(serviceref, iServiceInformation.sDescription) servicename = ServiceReference( serviceref).getServiceName().replace('\xc2\x86', '').replace( '\xc2\x87', '') movie = {} movie['filename'] = filename movie['filename_stripped'] = filename.split("/")[-1] movie['eventname'] = servicename movie['description'] = unicode(desc, 'utf_8', errors='ignore').encode( 'utf_8', 'ignore') movie['begintime'] = begin_string movie['serviceref'] = serviceref.toString() movie['length'] = Len movie['tags'] = info.getInfoString(serviceref, iServiceInformation.sTags) filename = filename.replace("'", "\'").replace("%", "\%") try: movie['filesize'] = os_stat(filename).st_size except: movie['filesize'] = 0 movie['fullname'] = serviceref.toString() movie['descriptionExtended'] = unicode(ext, 'utf_8', errors='ignore').encode( 'utf_8', 'ignore') movie['servicename'] = sourceRef.getServiceName().replace( '\xc2\x86', '').replace('\xc2\x87', '') movie['recordingtime'] = rtime movie['lastseen'] = pos movieliste.append(movie) if locations == None: ml = { "movies": movieliste, "bookmarks": bookmarklist, "directory": directory } else: ml = {"movies": movieliste, "locations": locations} return ml
def getText(self): self.recordings = self.source.getBoolean() text = None mostrardebug = False if self.recordings: ref = 'err' try: from Screens.InfoBar import InfoBar if InfoBar and InfoBar.instance: ref = str(ServiceReference(InfoBar.instance.session.nav.getCurrentlyPlayingServiceReference())) except: pass if mostrardebug: os.system("echo 'inicio[" + str(self.type) + "]'>/tmp/testrec.txt") conta = 0 infovarios = False for timer in NavigationInstance.instance.RecordTimer.timer_list: if timer.state == timer.StateRunning: conta = conta + 1 infovarios = False nombre = timer.name if mostrardebug: os.system("echo 'nombre: [" + str(nombre) + "]'>>/tmp/testrec.txt") os.system("echo 'ref: [" + str(ref) + "]'>>/tmp/testrec.txt") if len(nombre) < 2: try: nombre = os.path.split(timer.Filename)[1] except: nombre = '(' + _('Record') + ')' try: archivo = str(timer.Filename).replace('\n', '') except: archivo = 'NA' if mostrardebug: os.system("echo 'archivo: [" + archivo + "]'>>/tmp/testrec.txt") inicio = str(FuzzyTime(timer.begin)[1]) fin = str(FuzzyTime(timer.end)[1]) duracion = str((timer.end - timer.begin) / 60) + ' ' + _('mins') nfaltan = (timer.end - time()) / 60 if nfaltan >= 1: faltan = str(int(nfaltan)) + ' ' + _('mins') else: faltan = str(int(nfaltan * 60)) + ' ' + _('secs') self.poll_interval = 300 nomcan = timer.service_ref.getServiceName() if self.type == self.DURACION: text = duracion elif self.type == self.INICIO: text = inicio elif self.type == self.FIN: text = fin elif self.type == self.NOMBRE: text = nombre elif self.type == self.RESTAN: text = faltan elif self.type == self.CANAL: text = nomcan elif self.type == self.NOMBREYCANAL: text = nomcan if len(text) > 20: text = text[:17] + '...' text = text + ' (+' + faltan + ') ' elif self.type == self.INFO: infovarios = True text = inicio + ' - ' + fin + ' (+' + faltan + ') ' text = text + ' ' + nomcan if len(text) > 40: text = text[:37] + '...' text = text + ' :: ' + nombre if len(text) > 69: text = text[:66] + '...' elif self.type == self.PROGRESO: now = int(time()) duration = timer.end - timer.begin if duration > 0: valor = int((now - timer.begin) * 100 / duration) text = str(valor) + ' %' else: text = '? %' if archivo in ref or ref == str(timer.service_ref): if mostrardebug: os.system("echo 'break'>>/tmp/testrec.txt") break if mostrardebug: os.system("echo '-----------------------------------------------------'>>/tmp/testrec.txt") if conta > 1 and infovarios: text = text + '(' + str(conta) + ' RECs)' return text
def buildMovieListEntry(self, serviceref, info, begin, data): switch = config.usage.show_icons_in_movielist.value width = self.l.getItemSize().width() dateWidth = self.dateWidth if not config.movielist.use_fuzzy_dates.value: dateWidth += 30 iconSize = self.iconsWidth space = self.spaceIconeText r = self.spaceRight pathName = serviceref.getPath() res = [ None ] if serviceref.flags & eServiceReference.mustDescent: # Directory # Name is full path name if info is None: # Special case: "parent" txt = ".." else: p = os.path.split(pathName) if not p[1]: # if path ends in '/', p is blank. p = os.path.split(p[0]) txt = p[1] if txt == ".Trash": res.append(MultiContentEntryPixmapAlphaBlend(pos=(0,self.trashShift), size=(iconSize,self.iconTrash.size().height()), png=self.iconTrash)) res.append(MultiContentEntryText(pos=(iconSize+space, 0), size=(width-166, self.itemHeight), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_CENTER, text = _("Deleted items"))) res.append(MultiContentEntryText(pos=(width-145-r, 0), size=(145, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT|RT_VALIGN_CENTER, text=_("Trash can"))) return res res.append(MultiContentEntryPixmapAlphaBlend(pos=(0,self.dirShift), size=(iconSize,iconSize), png=self.iconFolder)) res.append(MultiContentEntryText(pos=(iconSize+space, 0), size=(width-166, self.itemHeight), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_CENTER, text = txt)) res.append(MultiContentEntryText(pos=(width-145-r, 0), size=(145, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT|RT_VALIGN_CENTER, text=_("Directory"))) return res if data == -1 or data is None: data = MovieListData() cur_idx = self.l.getCurrentSelectionIndex() x = self.list[cur_idx] # x = ref,info,begin,... data.len = 0 #dont recalc movielist to speedup loading the list self.list[cur_idx] = (x[0], x[1], x[2], data) #update entry in list... so next time we don't need to recalc data.txt = info.getName(serviceref) if config.movielist.hide_extensions.value: fileName, fileExtension = os.path.splitext(data.txt) if fileExtension in KNOWN_EXTENSIONS: data.txt = fileName data.icon = None data.part = None if os.path.split(pathName)[1] in self.runningTimers: if switch == 'i': if (self.playInBackground or self.playInForeground) and serviceref == (self.playInBackground or self.playInForeground): data.icon = self.iconMoviePlayRec else: data.icon = self.iconMovieRec elif switch in ('p', 's'): data.part = 100 if (self.playInBackground or self.playInForeground) and serviceref == (self.playInBackground or self.playInForeground): data.partcol = self.pbarColourSeen else: data.partcol = self.pbarColourRec elif (self.playInBackground or self.playInForeground) and serviceref == (self.playInBackground or self.playInForeground): data.icon = self.iconMoviePlay else: data.part = moviePlayState(pathName + '.cuts', serviceref, data.len) if switch == 'i': if data.part is not None and data.part > 0: data.icon = self.iconPart[data.part // 25] else: if config.usage.movielist_unseen.value: data.icon = self.iconUnwatched elif switch in ('p', 's'): if data.part is not None and data.part > 0: data.partcol = self.pbarColourSeen else: if config.usage.movielist_unseen.value: data.part = 100 data.partcol = self.pbarColour len = data.len if len > 0: len = "%d:%02d" % (len / 60, len % 60) else: len = "" if data: pos = (0,self.partIconeShift) if switch == 'i' and hasattr(data, 'icon') and data.icon is not None: res.append(MultiContentEntryPixmapAlphaBlend(pos=pos, size=(iconSize,data.icon.size().height()), png=data.icon)) elif switch in ('p', 's'): if switch == 'p': iconSize = self.pbarLargeWidth if hasattr(data, 'part') and data.part > 0: res.append(MultiContentEntryProgress(pos=(0,self.pbarShift), size=(iconSize, self.pbarHeight), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) elif hasattr(data, 'icon') and data.icon is not None: res.append(MultiContentEntryPixmapAlphaBlend(pos=(0,self.pbarShift), size=(iconSize, self.pbarHeight), png=data.icon)) begin_string = "" if begin > 0: if config.movielist.use_fuzzy_dates.value: begin_string = ', '.join(FuzzyTime(begin, inPast = True)) else: begin_string = strftime("%s, %s" % (config.usage.date.daylong.value, config.usage.time.short.value), localtime(begin)) ih = self.itemHeight res.append(MultiContentEntryText(pos=(iconSize+space, 0), size=(width-iconSize-space-dateWidth-r, ih), font = 0, flags = RT_HALIGN_LEFT|RT_VALIGN_CENTER, text = data.txt)) res.append(MultiContentEntryText(pos=(width-dateWidth-r, 2), size=(dateWidth, ih), font=1, flags=RT_HALIGN_RIGHT|RT_VALIGN_CENTER, text=begin_string)) return res
def buildTimerEntry(self, timer, processed): screenwidth = getDesktop(0).size().width() timertype = { TIMERTYPE.WAKEUP: _("Wake up"), TIMERTYPE.WAKEUPTOSTANDBY: _("Wake up to standby"), TIMERTYPE.STANDBY: _("Standby"), TIMERTYPE.AUTOSTANDBY: _("Auto standby"), TIMERTYPE.AUTODEEPSTANDBY: _("Auto deep standby"), TIMERTYPE.DEEPSTANDBY: _("Deep standby"), TIMERTYPE.REBOOT: _("Reboot"), TIMERTYPE.RESTART: _("Restart GUI") }[timer.timerType] afterevent = { AFTEREVENT.NONE: _("Nothing"), AFTEREVENT.WAKEUPTOSTANDBY: _("Wake up to standby"), AFTEREVENT.STANDBY: _("Standby"), AFTEREVENT.DEEPSTANDBY: _("Deep standby") }[timer.afterEvent] height = self.l.getItemSize().height() width = self.l.getItemSize().width() res = [ None ] x = width / 2 res.append((eListboxPythonMultiContent.TYPE_TEXT, self.iconWidth + self.iconMargin, 2, width, self.rowSplit, 0, RT_HALIGN_LEFT|RT_VALIGN_BOTTOM, timertype)) if timer.timerType == TIMERTYPE.AUTOSTANDBY or timer.timerType == TIMERTYPE.AUTODEEPSTANDBY: if self.iconRepeat and timer.autosleeprepeat != "once": res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, self.iconMargin / 2, self.rowSplit + (self.itemHeight - self.rowSplit - self.iconHeight) / 2, self.iconWidth, self.iconHeight, self.iconRepeat)) icon = None if not processed: if timer.state == TimerEntry.StateWaiting: state = _("waiting") icon = self.iconWait elif timer.state == TimerEntry.StatePrepared or timer.state == TimerEntry.StateRunning: state = _("running...") icon = self.iconZapped elif timer.state == TimerEntry.StateEnded: state = _("done!") icon = self.iconDone else: state = _("<unknown>") icon = None else: state = _("done!") icon = self.iconDone res.append((eListboxPythonMultiContent.TYPE_TEXT, 148, 26, width-150, self.itemHeight - self.rowSplit, 2, RT_HALIGN_RIGHT|RT_VALIGN_BOTTOM, _("Delay:") + " " + str(timer.autosleepdelay) + "(" + _("mins") + ")")) else: res.append((eListboxPythonMultiContent.TYPE_TEXT, x+24, 2, x-2-24, self.itemHeight - self.rowSplit, 2, RT_HALIGN_RIGHT|RT_VALIGN_BOTTOM, _('At End:') + ' ' + afterevent)) days = ( _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun") ) begin = FuzzyTime(timer.begin) if timer.repeated: repeatedtext = [] flags = timer.repeated for x in (0, 1, 2, 3, 4, 5, 6): if flags & 1 == 1: repeatedtext.append(days[x]) flags >>= 1 if repeatedtext == [_("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun")]: repeatedtext = _('Everyday') elif repeatedtext == [_("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri")]: repeatedtext = _('Weekday') elif repeatedtext == [_("Sat"), _("Sun")]: repeatedtext = _('Weekend') else: repeatedtext = ", ".join(repeatedtext) if self.iconRepeat: res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 2, self.rowSplit, 20, 20, self.iconRepeat)) else: repeatedtext = begin[0] # date text = repeatedtext + ((" %s ... %s (%d " + _("mins") + ")") % (begin[1], FuzzyTime(timer.end)[1], (timer.end - timer.begin) / 60)) res.append((eListboxPythonMultiContent.TYPE_TEXT, 148, self.itemHeight - self.rowSplit, width-150, self.rowSplit, 2, RT_HALIGN_RIGHT|RT_VALIGN_BOTTOM, text)) icon = None if not processed: if timer.state == TimerEntry.StateWaiting: state = _("waiting") icon = self.iconWait elif timer.state == TimerEntry.StatePrepared: state = _("about to start") icon = self.iconPrepared elif timer.state == TimerEntry.StateRunning: state = _("running...") icon = self.iconZapped elif timer.state == TimerEntry.StateEnded: state = _("done!") icon = self.iconDone else: state = _("<unknown>") icon = None else: state = _("done!") icon = self.iconDone if timer.disabled: state = _("disabled") icon = self.iconDisabled if timer.failed: state = _("failed") icon = self.iconFailed icon and res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, self.iconMargin / 6, (self.rowSplit - self.iconHeight) / 6, self.iconWidth, self.iconHeight, icon)) res.append((eListboxPythonMultiContent.TYPE_TEXT, self.iconMargin + self.iconWidth, self.rowSplit, 400, height - self.rowSplit, 2, RT_HALIGN_LEFT|RT_VALIGN_BOTTOM, state)) line = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "div-h.png")) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 0, height-2, width, 2, line)) return res
def updateState(self): cur = self["timerlist"].getCurrent() if cur: if self.key_red_choice != self.DELETE: self["actions"].actions.update({"red": self.removeTimerQuestion}) self["key_red"].setText(_("Delete")) self.key_red_choice = self.DELETE if cur.disabled and (self.key_yellow_choice != self.ENABLE): self["actions"].actions.update({"yellow": self.toggleDisabledState}) self["key_yellow"].setText(_("Enable")) self.key_yellow_choice = self.ENABLE elif cur.isRunning() and not cur.repeated and (self.key_yellow_choice != self.EMPTY): self.removeAction("yellow") self["key_yellow"].setText(" ") self.key_yellow_choice = self.EMPTY elif ((not cur.isRunning()) or cur.repeated) and (not cur.disabled) and (self.key_yellow_choice != self.DISABLE): self["actions"].actions.update({"yellow": self.toggleDisabledState}) self["key_yellow"].setText(_("Disable")) self.key_yellow_choice = self.DISABLE else: if self.key_red_choice != self.EMPTY: self.removeAction("red") self["key_red"].setText(" ") self.key_red_choice = self.EMPTY if self.key_yellow_choice != self.EMPTY: self.removeAction("yellow") self["key_yellow"].setText(" ") self.key_yellow_choice = self.EMPTY showCleanup = True for x in self.list: if (not x[0].disabled) and (x[1] == True): break else: showCleanup = False if showCleanup and (self.key_blue_choice != self.CLEANUP): self["actions"].actions.update({"blue": self.cleanupQuestion}) self["key_blue"].setText(_("Cleanup")) self.key_blue_choice = self.CLEANUP elif (not showCleanup) and (self.key_blue_choice != self.EMPTY): self.removeAction("blue") self["key_blue"].setText(" ") self.key_blue_choice = self.EMPTY if len(self.list) == 0: return timer = self['timerlist'].getCurrent() if timer: name = gettimerType(timer) if getafterEvent(timer) == "Nothing": after = "" else: after = getafterEvent(timer) time = "%s %s ... %s" % (FuzzyTime(timer.begin)[0], FuzzyTime(timer.begin)[1], FuzzyTime(timer.end)[1]) duration = ("(%d " + _("mins") + ")") % ((timer.end - timer.begin) // 60) if timer.state == RealTimerEntry.StateWaiting: state = _("waiting") elif timer.state == RealTimerEntry.StatePrepared: state = _("about to start") elif timer.state == RealTimerEntry.StateRunning: state = _("running...") elif timer.state == RealTimerEntry.StateEnded: state = _("done!") else: state = _("<unknown>") else: name = "" after = "" time = "" duration = "" state = "" for cb in self.onChangedEntry: cb(name, after, time, duration, state)
def buildMovieListEntry(self, serviceref, info, begin, tinfo): # print "[SF-Plugin] SF:MovieList.buildMovieListEntry, lst_type=%x, show_tims=%x" % (self.list_type, self.show_times) width = self.l.getItemSize().width() len = tinfo[5] #tinfo = [type, pixmap, txt, description, service, len] if len <= 0: #recalc len when not already done cur_idx = self.l.getCurrentSelectionIndex() x = self.list[cur_idx] if config.usage.load_length_of_movies_in_moviellist.value: len = x[1].getLength(x[0]) #recalc the movie length... else: len = 0 #dont recalc movielist to speedup loading the list self.list[cur_idx][3][ 5] = len #update entry in list... so next time we don't need to recalc if len > 0: len = "%d:%02d" % (len / 60, len % 60) else: len = "" res = [None] begin_string = "" date_string = "" pixmap = tinfo[1] typ = tinfo[0] service = None if typ & (self.VIRT_UP | self.REAL_UP): txt = tinfo[3] # [2] == " " for alpha-sort to top else: txt = tinfo[2] if begin > 0: t = FuzzyTime(begin) begin_string = t[0] + ", " + t[1] date_string = t[0] if not typ & (self.REAL_DIR | self.VIRT_ENTRY): service = tinfo[4] description = tinfo[3] tags = self.tags and info.getInfoString(serviceref, iServiceInformation.sTags) if isinstance(pixmap, str): pixmap = MultiContentEntryText(pos=(0, 0), size=(25, 20), font=0, flags=RT_HALIGN_LEFT, text=pixmap) if pixmap is not None: res.append(pixmap) XPOS = 25 if self.list_type & MovieList.LISTTYPE_ORIGINAL: res.append( MultiContentEntryText(pos=(XPOS, 0), size=(width, 30), font=0, flags=RT_HALIGN_LEFT, text=txt)) line2 = 20 if self.list == self.sflists[0]: line2 = 50 if not typ & (self.REAL_DIR | self.VIRT_ENTRY): res.append( MultiContentEntryText(pos=(XPOS, 30), size=(width, 20), font=1, flags=RT_HALIGN_LEFT, text=description)) res.append( MultiContentEntryText(pos=(XPOS, line2), size=(150, 20), font=1, flags=RT_HALIGN_LEFT, text=begin_string)) if service: res.append( MultiContentEntryText(pos=(XPOS + 150, line2), size=(180, 20), font=2, flags=RT_HALIGN_RIGHT, text=service)) if tags: res.append( MultiContentEntryText(pos=(width - 250, line2), size=(180, 20), font=2, flags=RT_HALIGN_RIGHT, text=tags)) if not typ & (self.REAL_DIR | self.VIRT_ENTRY): res.append( MultiContentEntryText(pos=(width - 60, line2), size=(60, 20), font=2, flags=RT_HALIGN_RIGHT, text=len)) return res tslen = 80 if self.show_times & self.SHOW_RECORDINGTIME: tslen += 50 date_string = begin_string dusz = 0 if self.show_times & self.SHOW_DURATION and not tinfo[0] & ( self.VIRT_ENTRY | self.REAL_UP): dusz = 57 if self.list_type & MovieList.LISTTYPE_COMPACT: res.append( MultiContentEntryText(pos=(XPOS, 4), size=(tslen - 5, 20), font=1, flags=RT_HALIGN_RIGHT, text=date_string)) res.append( MultiContentEntryText(pos=(XPOS + tslen, 0), size=(width - XPOS - tslen, 20), font=0, flags=RT_HALIGN_LEFT, text=txt)) other = None if self.list_type & MovieList.LISTTYPE_COMPACT_TAGS: if tags: res.append( MultiContentEntryText(pos=(width - dusz - 185, 20), size=(180, 17), font=1, flags=RT_HALIGN_RIGHT, text=tags)) otherend = dusz + 185 other = service else: if service: res.append( MultiContentEntryText(pos=(width - dusz - 155, 20), size=(153, 17), font=1, flags=RT_HALIGN_RIGHT, text=service)) otherend = dusz + 160 other = tags if self.list == self.sflists[0]: if not typ & (self.REAL_DIR | self.VIRT_ENTRY): res.append( MultiContentEntryText(pos=(XPOS, 20), size=(width - (XPOS + otherend), 17), font=1, flags=RT_HALIGN_LEFT, text=description)) elif other: res.append( MultiContentEntryText(pos=(XPOS, 20), size=(width - (XPOS + otherend), 17), font=1, flags=RT_HALIGN_LEFT, text=other)) if dusz: res.append( MultiContentEntryText(pos=(width - dusz, 20), size=(dusz - 2, 20), font=1, flags=RT_HALIGN_RIGHT, text=len)) else: # assert(self.list_type == MovieList.LISTTYPE_MINIMAL) res.append( MultiContentEntryText(pos=(XPOS, 3), size=(tslen - 5, 20), font=1, flags=RT_HALIGN_RIGHT, text=date_string)) res.append( MultiContentEntryText(pos=(XPOS + tslen, 0), size=(width - XPOS - tslen - dusz, 20), font=0, flags=RT_HALIGN_LEFT, text=txt)) if dusz: res.append( MultiContentEntryText(pos=(width - dusz, 3), size=(dusz, 20), font=1, flags=RT_HALIGN_RIGHT, text=len)) return res
def getMovieSearchList(rargs=None, locations=None): movieliste = [] tag = None directory = None fields = None short = None extended = None searchstr = None if rargs: searchstr = getUrlArg2(rargs, "find") short = getUrlArg2(rargs, "short") extended = getUrlArg2(rargs, "extended") s = {'title': str(searchstr)} if short is not None: s['shortDesc'] = str(searchstr) if extended is not None: s['extDesc'] = str(searchstr) movielist = MovieList(None) vdir_list = [] for x in moviedb.searchContent(s, 'ref', query_type="OR", exactmatch=False): vdir_list.append(eServiceReference(x[0])) root = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + "/") movielist.load(root, None) movielist.reload(root=None, vdir=5, vdir_list=vdir_list) for (serviceref, info, begin, unknown) in movielist.list: if serviceref.flags & eServiceReference.mustDescent: continue length_minutes = 0 txtdesc = "" filename = '/'.join(serviceref.toString().split("/")[1:]) filename = '/' + filename name, ext = os.path.splitext(filename) sourceRef = ServiceReference( info.getInfoString( serviceref, iServiceInformation.sServiceref)) rtime = info.getInfo(serviceref, iServiceInformation.sTimeCreate) movie = { 'filename': filename, 'filename_stripped': filename.split("/")[-1], 'serviceref': serviceref.toString(), 'length': "?:??", 'lastseen': 0, 'filesize_readable': '', 'recordingtime': rtime, 'begintime': 'undefined', 'eventname': ServiceReference(serviceref).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''), 'servicename': sourceRef.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''), 'tags': info.getInfoString(serviceref, iServiceInformation.sTags), 'fullname': serviceref.toString(), } if rtime > 0: fuzzy_rtime = FuzzyTime(rtime) movie['begintime'] = fuzzy_rtime[0] + ", " + fuzzy_rtime[1] try: length_minutes = info.getLength(serviceref) except: # noqa: E722 pass if length_minutes: movie['length'] = "%d:%02d" % (length_minutes / 60, length_minutes % 60) # if fields is None or 'pos' in fields: # movie['lastseen'] = getPosition(filename + '.cuts', length_minutes) if fields is None or 'desc' in fields: txtfile = name + '.txt' if ext.lower() != '.ts' and os.path.isfile(txtfile): with open(txtfile, "rb") as handle: txtdesc = six.ensure_str(b''.join(handle.readlines())) event = info.getEvent(serviceref) extended_description = event and event.getExtendedDescription() or "" if extended_description == '' and txtdesc != '': extended_description = txtdesc movie['descriptionExtended'] = ConvertDesc(extended_description) desc = info.getInfoString(serviceref, iServiceInformation.sDescription) movie['description'] = ConvertDesc(desc) if fields is None or 'size' in fields: size = 0 sz = '' try: size = os.stat(filename).st_size if size > 1073741824: sz = "%.2f %s" % ((size / 1073741824.), _("GB")) elif size > 1048576: sz = "%.2f %s" % ((size / 1048576.), _("MB")) elif size > 1024: sz = "%.2f %s" % ((size / 1024.), _("kB")) except: # noqa: E722 pass movie['filesize'] = size movie['filesize_readable'] = sz movieliste.append(movie) return { "movies": movieliste, "locations": [] }
def buildTimerEntry(self, timer, processed): screenwidth = getDesktop(0).size().width() height = self.l.getItemSize().height() width = self.l.getItemSize().width() res = [None] x = width / 2 res.append((eListboxPythonMultiContent.TYPE_TEXT, self.iconWidth + self.iconMargin, 3, width, self.rowSplit, 0, RT_HALIGN_LEFT | RT_VALIGN_BOTTOM, gettimerType(timer))) if timer.timerType == TIMERTYPE.AUTOSTANDBY or timer.timerType == TIMERTYPE.AUTODEEPSTANDBY: if self.iconRepeat and timer.autosleeprepeat != "once": res.append( (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, self.iconMargin / 2, self.rowSplit + (self.itemHeight - self.rowSplit - self.iconHeight) / 2, self.iconWidth, self.iconHeight, self.iconRepeat)) icon = None if not processed: if timer.state == TimerEntry.StateWaiting: state = _("waiting") icon = self.iconWait elif timer.state == TimerEntry.StatePrepared or timer.state == TimerEntry.StateRunning: state = _("running...") icon = self.iconZapped elif timer.state == TimerEntry.StateEnded: state = _("done!") icon = self.iconDone else: state = _("<unknown>") icon = None else: state = _("done!") icon = self.iconDone autosleepwindow = "" if timer.autosleepwindow == 'yes': autosleepwindow = _("Time range:") + " " + FuzzyTime( timer.autosleepbegin)[1] + " ... " + FuzzyTime( timer.autosleepend)[1] + ", " res.append((eListboxPythonMultiContent.TYPE_TEXT, 150, 26, width - 150, self.itemHeight - self.rowSplit, 2, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, autosleepwindow + _("Delay:") + " " + str(timer.autosleepdelay) + "(" + _("mins") + ")")) else: res.append((eListboxPythonMultiContent.TYPE_TEXT, x + 24, 2, x - 2 - 24, self.itemHeight - self.rowSplit, 1, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, _('At End:') + ' ' + getafterEvent(timer))) days = (_("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun")) begin = FuzzyTime(timer.begin) if timer.repeated: repeatedtext = [] flags = timer.repeated for x in (0, 1, 2, 3, 4, 5, 6): if flags & 1 == 1: repeatedtext.append(days[x]) flags >>= 1 if repeatedtext == [ _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun") ]: repeatedtext = _('Everyday') elif repeatedtext == [ _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri") ]: repeatedtext = _('Weekday') elif repeatedtext == [_("Sat"), _("Sun")]: repeatedtext = _('Weekend') else: repeatedtext = ", ".join(repeatedtext) if self.iconRepeat: res.append( (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 2, self.rowSplit, 20, 20, self.iconRepeat)) else: repeatedtext = begin[0] # date text = repeatedtext + ((" %s ... %s (%d " + _("mins") + ")") % (begin[1], FuzzyTime(timer.end)[1], (timer.end - timer.begin) / 60)) res.append( (eListboxPythonMultiContent.TYPE_TEXT, 150, self.itemHeight - self.rowSplit, width - 150, self.rowSplit, 1, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, text)) icon = None if not processed: if timer.state == TimerEntry.StateWaiting: state = _("waiting") icon = self.iconWait elif timer.state == TimerEntry.StatePrepared: state = _("about to start") icon = self.iconPrepared elif timer.state == TimerEntry.StateRunning: state = _("running...") icon = self.iconZapped elif timer.state == TimerEntry.StateEnded: state = _("done!") icon = self.iconDone else: state = _("<unknown>") icon = None else: state = _("done!") icon = self.iconDone if timer.disabled: state = _("disabled") icon = self.iconDisabled if timer.failed: state = _("failed") icon = self.iconFailed res.append((eListboxPythonMultiContent.TYPE_TEXT, self.iconMargin + self.iconWidth, self.rowSplit, 150, height - self.rowSplit, 1, RT_HALIGN_LEFT | RT_VALIGN_BOTTOM, state)) icon and res.append( (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, self.iconMargin / 2, (self.rowSplit - self.iconHeight) / 2, self.iconWidth, self.iconHeight, icon)) line = LoadPixmap(resolveFilename(SCOPE_ACTIVE_SKIN, "div-h.png")) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 0, height - 2, width, 2, line)) return res
def getMovieList(rargs=None, locations=None): movieliste = [] tag = None directory = None fields = None bookmarklist = [] if rargs: tag = getUrlArg2(rargs, "tag") directory = getUrlArg2(rargs, "dirname") fields = getUrlArg2(rargs, "fields") if directory is None: directory = MovieSelection.defaultMoviePath() else: if not PY3: try: directory.decode('utf-8') except UnicodeDecodeError: try: directory = directory.decode("cp1252").encode("utf-8") except UnicodeDecodeError: directory = directory.decode("iso-8859-1").encode("utf-8") if not directory: directory = MOVIE_LIST_ROOT_FALLBACK if directory[-1] != "/": directory += "/" if not os.path.isdir(directory): return { "movies": [], "locations": [], "bookmarks": [], "directory": [], } root = eServiceReference(MOVIE_LIST_SREF_ROOT + directory) for item in sorted(os.listdir(directory)): abs_p = os.path.join(directory, item) if os.path.isdir(abs_p): bookmarklist.append(item) folders = [root] if rargs and b"recursive" in list(rargs.keys()): for f in bookmarklist: if f[-1] != "/": f += "/" ff = eServiceReference(MOVIE_LIST_SREF_ROOT + directory + f) folders.append(ff) # get all locations if locations is not None: folders = [] for f in locations: if f[-1] != "/": f += "/" ff = eServiceReference(MOVIE_LIST_SREF_ROOT + f) folders.append(ff) if config.OpenWebif.parentalenabled.value: dir_is_protected = checkParentalProtection(directory) else: dir_is_protected = False if not dir_is_protected: movielist = MovieList(None) for root in folders: if tag is not None: movielist.load(root=root, filter_tags=[tag]) else: movielist.load(root=root, filter_tags=None) for (serviceref, info, begin, unknown) in movielist.list: if serviceref.flags & eServiceReference.mustDescent: continue length_minutes = 0 txtdesc = "" filename = '/'.join(serviceref.toString().split("/")[1:]) filename = '/' + filename name, ext = os.path.splitext(filename) sourceRef = ServiceReference( info.getInfoString( serviceref, iServiceInformation.sServiceref)) rtime = info.getInfo( serviceref, iServiceInformation.sTimeCreate) movie = { 'filename': filename, 'filename_stripped': filename.split("/")[-1], 'serviceref': serviceref.toString(), 'length': "?:??", 'lastseen': 0, 'filesize_readable': '', 'recordingtime': rtime, 'begintime': 'undefined', 'eventname': ServiceReference(serviceref).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''), 'servicename': sourceRef.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''), 'tags': info.getInfoString(serviceref, iServiceInformation.sTags), 'fullname': serviceref.toString(), } if rtime > 0: fuzzy_rtime = FuzzyTime(rtime) movie['begintime'] = fuzzy_rtime[0] + ", " + fuzzy_rtime[1] try: length_minutes = info.getLength(serviceref) except: # noqa: E722 pass if length_minutes: movie['length'] = "%d:%02d" % (length_minutes / 60, length_minutes % 60) if fields is None or 'pos' in fields: movie['lastseen'] = _moviePlayState(filename + '.cuts', serviceref, length_minutes) or 0 if fields is None or 'desc' in fields: txtfile = name + '.txt' if ext.lower() != '.ts' and os.path.isfile(txtfile): with open(txtfile, "rb") as handle: txtdesc = six.ensure_str(b''.join(handle.readlines())) event = info.getEvent(serviceref) extended_description = event and event.getExtendedDescription() or "" if extended_description == '' and txtdesc != '': extended_description = txtdesc movie['descriptionExtended'] = ConvertDesc(extended_description) desc = info.getInfoString(serviceref, iServiceInformation.sDescription) movie['description'] = ConvertDesc(desc) if fields is None or 'size' in fields: size = 0 sz = '' try: size = os.stat(filename).st_size if size > 1073741824: sz = "%.2f %s" % ((size / 1073741824.), _("GB")) elif size > 1048576: sz = "%.2f %s" % ((size / 1048576.), _("MB")) elif size > 1024: sz = "%.2f %s" % ((size / 1024.), _("kB")) except: # noqa: E722 pass movie['filesize'] = size movie['filesize_readable'] = sz movieliste.append(movie) # del movielist if locations is None: return { "movies": movieliste, "bookmarks": bookmarklist, "directory": directory } return { "movies": movieliste, "locations": locations }
def gotThreadMsg(self, msg): """Create Notifications if there is anything to display.""" ret = self.__queue.pop() conflicts = ret[4] if conflicts and config.plugins.autotimer.notifconflict.value and Standby.inStandby is None: AddPopup( #_("%(conflicts)d conflict(s) encountered when trying to add new timers:\n%(timers)s") % { "conflicts":len(conflicts), "timers":'\n'.join( [ _("%(sname)s - %(tname)s: %(name)s at %(begin)s") % {"sname":ServiceReference(x[3]).getServiceName(), "tname":x[4], "name":x[0], "begin":FuzzyTime(x[2])} for x in conflicts ] ) }, _("%d conflict(s) encountered when trying to add new timers:\n%s") % (len(conflicts), '\n'.join([_("%s: %s at %s") % (x[4], x[0], "('%s', '%s')" % FuzzyTime(x[2])) for x in conflicts])), MessageBox.TYPE_INFO, config.plugins.autotimer.popup_timeout.value, NOTIFICATIONID ) similars = ret[5] if similars and config.plugins.autotimer.notifsimilar.value and Standby.inStandby is None: AddPopup( _("%d conflict(s) solved with similar timer(s):\n%s") % (len(similars), '\n'.join([_("%s: %s at %s") % (x[4], x[0], "('%s', '%s')" % FuzzyTime(x[2])) for x in similars])), MessageBox.TYPE_INFO, config.plugins.autotimer.popup_timeout.value, SIMILARNOTIFICATIONID ) added_timer = ret[1] if added_timer and config.plugins.autotimer.notiftimers.value and Standby.inStandby is None: AddPopup( _("AutoTimer\n%d timer(s) were added.") % (ret[1]), MessageBox.TYPE_INFO, config.plugins.autotimer.popup_timeout.value, TIMERNOTIFICATIONID )