class serienRecTimerListScreen(serienRecBaseScreen, Screen, HelpableScreen): def __init__(self, session): serienRecBaseScreen.__init__(self, session) Screen.__init__(self, session) HelpableScreen.__init__(self) self.skin = None self.session = session self.picload = ePicLoad() self.WochenTag = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"] self.database = SRDatabase(SerienRecorder.serienRecDataBaseFilePath) self["actions"] = HelpableActionMap(self, "SerienRecorderActions", { "ok": (self.keyOK, "Liste der erstellten Timer bearbeiten"), "cancel": (self.keyCancel, "zurück zur Serienplaner-Ansicht"), "left": (self.keyLeft, "zur vorherigen Seite blättern"), "right": (self.keyRight, "zur nächsten Seite blättern"), "up": (self.keyUp, "eine Zeile nach oben"), "down": (self.keyDown, "eine Zeile nach unten"), "red": (self.keyRed, "ausgewählten Timer löschen"), "green": (self.viewChange, "Sortierung ändern"), "yellow": (self.keyYellow, "umschalten alle/nur aktive Timer anzeigen"), "blue": (self.keyBlue, "alle noch ausstehenden Timer löschen"), "menu": (self.recSetup, "Menü für globale Einstellungen öffnen"), "startTeletext": (self.wunschliste, "Informationen zur ausgewählten Serie auf Wunschliste anzeigen"), "0" : (self.readLogFile, "Log-File des letzten Suchlaufs anzeigen"), "3" : (self.showProposalDB, "Liste der Serien/Staffel-Starts anzeigen"), "4" : (self.serieInfo, "Informationen zur ausgewählten Serie anzeigen"), "6" : (self.showConflicts, "Liste der Timer-Konflikte anzeigen"), "7" : (self.showWishlist, "Merkzettel (vorgemerkte Folgen) anzeigen"), "9" : (self.dropAllTimer, "Alle Timer aus der Datenbank löschen"), }, -1) self.helpList[0][2].sort() self["helpActions"] = ActionMap(["SerienRecorderActions" ,], { # "ok" : self.keyOK, "displayHelp" : self.showHelp, "displayHelp_long" : self.showManual, }, 0) self.setupSkin() self.changesMade = False self.filter = True self.onLayoutFinish.append(self.readTimer) self.onClose.append(self.__onClose) self.onLayoutFinish.append(self.setSkinProperties) def callHelpAction(self, *args): HelpableScreen.callHelpAction(self, *args) def setSkinProperties(self): super(self.__class__, self).setSkinProperties() self['text_red'].setText("Entferne Timer") if config.plugins.serienRec.recordListView.value == 0: self['text_green'].setText("Zeige neueste Timer zuerst") elif config.plugins.serienRec.recordListView.value == 1: self['text_green'].setText("Zeige früheste Timer zuerst") self['text_ok'].setText("Liste bearbeiten") self['text_yellow'].setText("Zeige auch alte Timer") self['text_blue'].setText("Entferne neue Timer") self.num_bt_text[4][1] = "Datenbank leeren" super(self.__class__, self).startDisplayTimer() def setupSkin(self): InitSkin(self) self.chooseMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent) self.chooseMenuList.l.setFont(0, gFont('Regular', 20 + int(config.plugins.serienRec.listFontsize.value))) self.chooseMenuList.l.setItemHeight(int(50 *skinFactor)) self['menu_list'] = self.chooseMenuList self['menu_list'].show() if config.plugins.serienRec.showCover.value: self['cover'].show() if not config.plugins.serienRec.showAllButtons.value: self['bt_red'].show() self['bt_green'].show() self['bt_ok'].show() self['bt_yellow'].show() self['bt_blue'].show() self['bt_exit'].show() self['bt_text'].show() self['bt_info'].show() self['bt_menu'].show() self['text_red'].show() self['text_green'].show() self['text_ok'].show() self['text_yellow'].show() self['text_blue'].show() self['text_0'].show() self['text_1'].show() self['text_2'].show() self['text_3'].show() self['text_4'].show() def updateMenuKeys(self): updateMenuKeys(self) def serieInfo(self): check = self['menu_list'].getCurrent() if check is None: return serien_name = self['menu_list'].getCurrent()[0][0] url = self.database.getMarkerURL(serien_name) if url: serien_id = url if serien_id: from SerienRecorderSeriesInfoScreen import serienRecShowInfo self.session.open(serienRecShowInfo, serien_name, serien_id) def wunschliste(self): serien_name = self['menu_list'].getCurrent()[0][0] url = self.database.getMarkerURL(serien_name) serien_id = url super(self.__class__, self).wunschliste(serien_id) def setupClose(self, result): super(self.__class__, self).setupClose(result) if result[1]: self.readTimer() def viewChange(self): if config.plugins.serienRec.recordListView.value == 1: config.plugins.serienRec.recordListView.value = 0 self['text_green'].setText("Zeige neueste Timer zuerst") else: config.plugins.serienRec.recordListView.value = 1 self['text_green'].setText("Zeige früheste Timer zuerst") config.plugins.serienRec.recordListView.save() SerienRecorder.configfile.save() self.readTimer() def readTimer(self, showTitle=True): current_time = int(time.time()) deltimer = 0 timerList = [] timers = self.database.getAllTimer(current_time if self.filter else None) for timer in timers: (serie, staffel, episode, title, start_time, stbRef, webChannel, eit, activeTimer) = timer if int(start_time) < int(current_time): deltimer += 1 timerList.append((serie, staffel, episode, title, start_time, webChannel, "1", 0, bool(activeTimer))) else: timerList.append((serie, staffel, episode, title, start_time, webChannel, "0", eit, bool(activeTimer))) if showTitle: self['title'].instance.setForegroundColor(parseColor("foreground")) if self.filter: self['title'].setText("Timer-Liste: %s ausstehende Timer" % len(timerList)) else: self['title'].setText("Timer-Liste: %s abgeschlossene und %s ausstehende Timer" % (deltimer, len(timerList ) -deltimer)) if config.plugins.serienRec.recordListView.value == 0: timerList.sort(key=lambda t : t[4]) elif config.plugins.serienRec.recordListView.value == 1: timerList.sort(key=lambda t : t[4]) timerList.reverse() self.chooseMenuList.setList(map(self.buildList, timerList)) if len(timerList) == 0: if showTitle: self['title'].instance.setForegroundColor(parseColor("foreground")) self['title'].setText("Serien Timer - 0 Serien in der Aufnahmeliste.") self.getCover() def buildList(self, entry): (serie, staffel, episode, title, start_time, webChannel, foundIcon, eit, activeTimer) = entry xtime = time.strftime(self.WochenTag[time.localtime(int(start_time)).tm_wday ] +", %d.%m.%Y - %H:%M", time.localtime(int(start_time))) xtitle = "S%sE%s - %s" % (str(staffel).zfill(2), str(episode).zfill(2), title) if int(foundIcon) == 1: imageFound = "%simages/found.png" % SerienRecorder.serienRecMainPath else: imageFound = "%simages/black.png" % SerienRecorder.serienRecMainPath if activeTimer: SerieColor = None else: SerieColor = parseColor('red').argb() foregroundColor = parseColor('foreground').argb() return [entry, (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 5, 8 * skinFactor, 32 * skinFactor, 32 * skinFactor, loadPNG(imageFound)), (eListboxPythonMultiContent.TYPE_TEXT, 40, 3, 200 * skinFactor, 26 * skinFactor, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, webChannel, SerieColor), (eListboxPythonMultiContent.TYPE_TEXT, 40, 29 * skinFactor, 250 * skinFactor, 18 * skinFactor, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, xtime, foregroundColor, foregroundColor), (eListboxPythonMultiContent.TYPE_TEXT, 300 * skinFactor, 3, 500 * skinFactor, 26 * skinFactor, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, serie, SerieColor), (eListboxPythonMultiContent.TYPE_TEXT, 300 * skinFactor, 29 * skinFactor, 500 * skinFactor, 18 * skinFactor, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, re.sub("(?<= - )dump\Z", "(Manuell hinzugefügt !!)", xtitle), foregroundColor, foregroundColor) ] def keyOK(self): self.session.open(serienRecModifyAdded, False) def callDeleteSelectedTimer(self, answer): if answer: serien_name = self['menu_list'].getCurrent()[0][0] staffel = self['menu_list'].getCurrent()[0][1] episode = self['menu_list'].getCurrent()[0][2] serien_title = self['menu_list'].getCurrent()[0][3] serien_time = self['menu_list'].getCurrent()[0][4] serien_channel = self['menu_list'].getCurrent()[0][5] serien_eit = self['menu_list'].getCurrent()[0][7] self.removeTimer(serien_name, staffel, episode, serien_title, serien_time, serien_channel, serien_eit) else: return def removeTimer(self, serien_name, staffel, episode, serien_title, serien_time, serien_channel, serien_eit=0): if config.plugins.serienRec.TimerName.value == "1": # "<Serienname>" title = serien_name elif config.plugins.serienRec.TimerName.value == "2": # "SnnEmm - <Episodentitel>" title = "S%sE%s - %s" % (str(staffel).zfill(2), str(episode).zfill(2), serien_title) else: # "<Serienname> - SnnEmm - <Episodentitel>" title = "%s - S%sE%s - %s" % (serien_name, str(staffel).zfill(2), str(episode).zfill(2), serien_title) from SerienRecorderTimer import serienRecBoxTimer removed = serienRecBoxTimer.removeTimerEntry(title, serien_time, serien_eit) if not removed: print "[SerienRecorder] enigma2 NOOOTTT removed" else: print "[SerienRecorder] enigma2 Timer removed." self.database.removeTimer(serien_name, staffel, episode, None, serien_time, serien_channel, (serien_eit if serien_eit > 0 else None)) self.changesMade = True self.readTimer(False) self['title'].instance.setForegroundColor(parseColor("red")) self['title'].setText("Timer '- %s -' entfernt." % serien_name) def keyRed(self): check = self['menu_list'].getCurrent() if check is None: print "[SerienRecorder] Serien Timer leer." return else: serien_name = self['menu_list'].getCurrent()[0][0] staffel = self['menu_list'].getCurrent()[0][1] episode = self['menu_list'].getCurrent()[0][2] serien_title = self['menu_list'].getCurrent()[0][3] serien_time = self['menu_list'].getCurrent()[0][4] serien_channel = self['menu_list'].getCurrent()[0][5] serien_eit = self['menu_list'].getCurrent()[0][7] print self['menu_list'].getCurrent()[0] if config.plugins.serienRec.confirmOnDelete.value: self.session.openWithCallback(self.callDeleteSelectedTimer, MessageBox, "Soll '%s - S%sE%s - %s' wirklich entfernt werden?" % (serien_name, str(staffel).zfill(2), str(episode).zfill(2), re.sub("\Adump\Z", "(Manuell hinzugefügt !!)", serien_title)), MessageBox.TYPE_YESNO, default=False) else: self.removeTimer(serien_name, staffel, episode, serien_title, serien_time, serien_channel, serien_eit) def keyYellow(self): if self.filter: self['text_yellow'].setText("Zeige nur neue Timer") self.filter = False else: self['text_yellow'].setText("Zeige auch alte Timer") self.filter = True self.readTimer() def keyBlue(self): if config.plugins.serienRec.confirmOnDelete.value: self.session.openWithCallback(self.removeNewTimerFromDB, MessageBox, "Sollen wirklich alle noch ausstehenden Timer von der Box und aus der Datenbank entfernt werden?", MessageBox.TYPE_YESNO, default=False) else: self.removeNewTimerFromDB(True) def removeNewTimerFromDB(self, answer): if answer: current_time = int(time.time()) timers = self.database.getAllTimer(current_time) for timer in timers: (serie, staffel, episode, title, start_time, stbRef, webChannel, eit, activeTimer) = timer self.removeTimer(serie, staffel, episode, title, start_time, webChannel, eit) self.readTimer(False) self['title'].instance.setForegroundColor(parseColor("red")) self['title'].setText("Alle noch ausstehenden Timer wurden entfernt.") else: return def removeOldTimerFromDB(self, answer): if answer: self.database.removeAllOldTimer() self.database.rebuild() self.readTimer(False) self['title'].instance.setForegroundColor(parseColor("red")) self['title'].setText("Alle alten Timer wurden entfernt.") else: return def dropAllTimer(self): if config.plugins.serienRec.confirmOnDelete.value: self.session.openWithCallback(self.removeOldTimerFromDB, MessageBox, "Sollen wirklich alle alten Timer aus der Datenbank entfernt werden?", MessageBox.TYPE_YESNO, default=False) else: self.removeOldTimerFromDB(True) def getCover(self): check = self['menu_list'].getCurrent() if check is None: return serien_name = self['menu_list'].getCurrent()[0][0] serien_id = None url = self.database.getMarkerURL(serien_name) if url: serien_id = url SerienRecorder.getCover(self, serien_name, serien_id) def keyLeft(self): self['menu_list'].pageUp() self.getCover() def keyRight(self): self['menu_list'].pageDown() self.getCover() def keyDown(self): self['menu_list'].down() self.getCover() def keyUp(self): self['menu_list'].up() self.getCover() def __onClose(self): self.stopDisplayTimer() def keyCancel(self): if config.plugins.serienRec.refreshViews.value: self.close(self.changesMade) else: self.close(False)
class serienRecEpisodes(serienRecBaseScreen, Screen, HelpableScreen): def __init__(self, session, serien_name, serie_url, serien_cover): serienRecBaseScreen.__init__(self, session) Screen.__init__(self, session) HelpableScreen.__init__(self) self.ErrorMsg = '' self.database = SRDatabase(serienRecDataBaseFilePath) self.addedEpisodes = self.database.getTimerForSeries(serien_name) self.modus = "menu_list" self.session = session self.picload = ePicLoad() self.serien_name = serien_name self.serien_id = 0 self.serien_cover = serien_cover self.episodes_list_cache = {} self.showEpisodes = True self.aStaffel = None self.aFromEpisode = None self.aToEpisode = None self.numberOfEpisodes = 0 self.page = 1 self.maxPages = 1 self.loading = False self.changesMade = False self["actions"] = HelpableActionMap(self, "SerienRecorderActions", { "ok" : (self.keyOK, "Informationen zur ausgewählten Episode anzeigen"), "cancel": (self.keyCancel, "Zurück zur Serien-Marker-Ansicht"), "left" : (self.keyLeft, "Zur vorherigen Seite blättern"), "right" : (self.keyRight, "Zur nächsten Seite blättern"), "up" : (self.keyUp, "Eine Zeile nach oben"), "down" : (self.keyDown, "Eine Zeile nach unten"), "red" : (self.keyRed, "Diese Folge (nicht mehr) timern"), "green" : (self.keyGreen, "Zeige nur Einträge aus der Timer-Liste"), "yellow": (self.keyYellow, "Ausgewählte Folge auf den Merkzettel"), "blue" : (self.keyBlue, "Neue Einträge manuell hinzufügen"), "menu" : (self.recSetup, "Menü für globale Einstellungen öffnen"), "nextBouquet" : (self.nextPage, "Nächste Seite laden"), "prevBouquet" : (self.backPage, "Vorherige Seite laden"), "startTeletext" : (self.wunschliste, "Informationen zur ausgewählten Serie auf Wunschliste anzeigen"), "0" : (self.readLogFile, "Log-File des letzten Suchlaufs anzeigen"), "3" : (self.showProposalDB, "Liste der Serien/Staffel-Starts anzeigen"), "4" : (self.serieInfo, "Informationen zur ausgewählten Serie anzeigen"), "6" : (self.showConflicts, "Liste der Timer-Konflikte anzeigen"), "7" : (self.showWishlist, "Merkzettel (vorgemerkte Folgen) anzeigen"), }, -1) self.helpList[0][2].sort() self["helpActions"] = ActionMap(["SerienRecorderActions", ], { "displayHelp" : self.showHelp, "displayHelp_long" : self.showManual, }, 0) self.setupSkin() self.serien_id = serie_url self.timer_default = eTimer() if isDreamOS(): self.timer_default_conn = self.timer_default.timeout.connect(self.loadEpisodes) else: self.timer_default.callback.append(self.loadEpisodes) self.onLayoutFinish.append(self.setSkinProperties) self.onLayoutFinish.append(self.searchEpisodes) self.onClose.append(self.__onClose) def callHelpAction(self, *args): HelpableScreen.callHelpAction(self, *args) def setSkinProperties(self): super(self.__class__, self).setSkinProperties() self['text_red'].setText("(De)aktivieren") self['text_green'].setText("Zeige Timer") self['text_ok'].setText("Beschreibung") self['text_yellow'].setText("Auf den Merkzettel") self['text_blue'].setText("Manuell hinzufügen") #self['headline'].instance.setHAlign(2) self['headline'].instance.setForegroundColor(parseColor('red')) self['headline'].instance.setFont(parseFont("Regular;16", ((1,1),(1,1)))) self.chooseMenuList.l.setItemHeight(int(28 * skinFactor)) self.num_bt_text[2][2] = buttonText_na self.num_bt_text[3][2] = buttonText_na super(self.__class__, self).startDisplayTimer() def setupSkin(self): super(self.__class__, self).setupSkin() self[self.modus].show() if config.plugins.serienRec.showCover.value: self['cover'].show() if not config.plugins.serienRec.showAllButtons.value: self['bt_epg'].hide() self['bt_info'].hide() self['bt_red'].show() self['bt_green'].show() self['bt_ok'].show() self['bt_yellow'].show() self['bt_blue'].show() self['bt_exit'].show() self['bt_text'].show() self['bt_menu'].show() self['text_red'].show() self['text_green'].show() self['text_ok'].show() self['text_yellow'].show() self['text_blue'].show() self['text_0'].show() self['text_1'].show() self['text_2'].show() self['text_3'].show() self['text_4'].show() def updateMenuKeys(self): updateMenuKeys(self) def setupClose(self, result): super(self.__class__, self).setupClose(result) def wunschliste(self): super(self.__class__, self).wunschliste(self.serien_id) def searchEpisodes(self): super(self.__class__, self).getCover(self.serien_name) self['title'].setText("Suche Episoden ' %s '" % self.serien_name) self.loading = True self.timer_default.start(0) def resultsEpisodes(self, data): self.maxPages = 1 self.episodes_list_cache[self.page] = [] for episode in data["episodes"]: if "title" in episode: title = episode["title"].encode("utf-8") else: title = "-" self.episodes_list_cache[self.page].append( [episode["season"], episode["episode"], episode["id"], title]) self.chooseMenuList.setList(map(self.buildList_episodes, self.episodes_list_cache[self.page])) self.numberOfEpisodes = data["numEpisodes"] self.loading = False self.showPages() def loadEpisodes(self): self.timer_default.stop() if self.page in self.episodes_list_cache: self.chooseMenuList.setList(map(self.buildList_episodes, self.episodes_list_cache[self.page])) self['title'].setText("%s Episoden für ' %s ' gefunden." % (self.numberOfEpisodes, self.serien_name)) else: getCover(self, self.serien_name, self.serien_id) try: episodes = SeriesServer().doGetEpisodes(int(self.serien_id), int(self.page)) self.resultsEpisodes(episodes) self['title'].setText("%s Episoden für ' %s ' gefunden." % (self.numberOfEpisodes, self.serien_name)) except: self['title'].setText("Fehler beim Abrufen der Episodenliste") self.loading = False self['headline'].show() def buildList_episodes(self, entry): (season, episode, info_id, title) = entry seasonEpisodeString = "S%sE%s" % (str(season).zfill(2), str(episode).zfill(2)) imageMinus = "%simages/red_dot.png" % serienRecMainPath imagePlus = "%simages/green_dot.png" % serienRecMainPath imageNone = "%simages/black.png" % serienRecMainPath middleImage = imageNone leftImage = imageMinus if len(self.addedEpisodes) > 0 and self.isAlreadyAdded(season, episode, title): leftImage = imagePlus color = parseColor('yellow').argb() if not str(season).isdigit(): color = parseColor('red').argb() return [entry, (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 5, 8 * skinFactor, 16 * skinFactor, 16 * skinFactor, loadPNG(leftImage)), (eListboxPythonMultiContent.TYPE_TEXT, 40 * skinFactor, 3, 140 * skinFactor, 22 * skinFactor, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, "%s" % seasonEpisodeString, color), (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 150 * skinFactor, 17 * skinFactor, 22 * skinFactor, 48 * skinFactor, loadPNG(middleImage)), (eListboxPythonMultiContent.TYPE_TEXT, 200 * skinFactor, 3, 550 * skinFactor, 22 * skinFactor, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, title), #(eListboxPythonMultiContent.TYPE_TEXT, 200 * skinFactor, 29 * skinFactor, 550 * skinFactor, 18 * skinFactor, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, otitle, parseColor('yellow').argb()), ] def loadTimer(self): self.addedEpisodes = self.database.getTimerForSeries(self.serien_name) addedlist = [] for timer in self.addedEpisodes: (Staffel, Episode, title, webChannel, start_time) = timer zeile = "%s - S%sE%s - %s" % (self.serien_name, str(Staffel).zfill(2), str(Episode).zfill(2), title) addedlist.append((zeile.replace(" - dump", " - %s" % "(Manuell hinzugefügt !!)"), self.serien_name, Staffel, Episode, title, start_time, webChannel)) return addedlist[:] def buildList_timer(self, entry): (zeile, Serie, Staffel, Episode, title, start_time, webChannel) = entry foregroundColor = parseColor('foreground').argb() return [entry, (eListboxPythonMultiContent.TYPE_TEXT, 20, 00, 1280 * skinFactor, 25 * skinFactor, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, zeile, foregroundColor) ] def showPages(self): headline = "Diese Liste stammt von TheTVDB, daher kann die Nummerierung/Episodenbeschreibung abweichen." if self.maxPages > 1: headline += " Seite %s/%s" % (str(self.page), str(self.maxPages)) self['headline'].setText(headline) def isAlreadyAdded(self, season, episode, title=None): result = False #Title is only relevant if season and episode is 0 #this happen when Wunschliste has no episode and season information seasonEpisodeString = "S%sE%s" % (str(season).zfill(2), str(episode).zfill(2)) if seasonEpisodeString != "S00E00": title = None if not title: for addedEpisode in self.addedEpisodes[:]: if str(addedEpisode[0]).zfill(2) == str(season).zfill(2) and str(addedEpisode[1]).zfill(2) == str(episode).zfill(2): result = True #self.addedEpisodes.remove(addedEpisode) break else: for addedEpisode in self.addedEpisodes[:]: if (str(addedEpisode[0]).zfill(2) == str(season).zfill(2)) and (str(addedEpisode[1]).zfill(2) == str(episode).zfill(2)) and (addedEpisode[2] == title): result = True #self.addedEpisodes.remove(addedEpisode) break return result def removeFromDB(self, season, episode, title=None): seasonEpisodeString = "S%sE%s" % (str(season).zfill(2), str(episode).zfill(2)) if seasonEpisodeString != "S00E00": title = None self.database.removeTimer(self.serien_name, season, episode, title, None, None, None) def keyOK(self): if self.loading and self.showEpisodes: return check = self['menu_list'].getCurrent() if not check: return sindex = self['menu_list'].getSelectedIndex() #if len(self.episodes_list_cache) >= self.page: if self.page in self.episodes_list_cache: if len(self.episodes_list_cache[self.page]) != 0: if self.episodes_list_cache[self.page][sindex][2]: self.session.open(serienRecShowEpisodeInfo, self.serien_name, self.serien_id, self.episodes_list_cache[self.page][sindex][3], self.episodes_list_cache[self.page][sindex][2]) #self.session.open(MessageBox, "Diese Funktion steht in dieser Version noch nicht zur Verfügung!", MessageBox.TYPE_INFO, timeout=10) def keyRed(self): if self.loading: return selectedRow = self['menu_list'].getCurrent() if not selectedRow: return sindex = self['menu_list'].getSelectedIndex() if self.showEpisodes: if self.page in self.episodes_list_cache: current_episodes_list = self.episodes_list_cache[self.page] if len(current_episodes_list) != 0: isAlreadyAdded = self.isAlreadyAdded(current_episodes_list[sindex][0], current_episodes_list[sindex][1], current_episodes_list[sindex][3]) if isAlreadyAdded: self.removeFromDB(current_episodes_list[sindex][0], current_episodes_list[sindex][1], current_episodes_list[sindex][3]) else: self.database.addToTimerList(self.serien_name, current_episodes_list[sindex][1], current_episodes_list[sindex][1], current_episodes_list[sindex][0], current_episodes_list[sindex][3], int(time.time()), "", "", 0, 1) self.addedEpisodes = self.database.getTimerForSeries(self.serien_name) self.chooseMenuList.setList(map(self.buildList_episodes, current_episodes_list)) else: (txt, serie, staffel, episode, title, start_time, webChannel) = selectedRow[0] self.removeFromDB(staffel, episode, title) timerList = self.loadTimer() self.chooseMenuList.setList(map(self.buildList_timer, timerList)) self['title'].setText("%s Timer für ' %s ' gefunden." % (len(timerList), self.serien_name)) def keyGreen(self): if self.loading: return if self.showEpisodes: # Show timer self.showEpisodes = False self['text_red'].setText("Eintrag löschen") self['text_green'].setText("Zeige Episoden") self['text_yellow'].hide() self['text_blue'].hide() self['text_ok'].hide() timerList = self.loadTimer() self.chooseMenuList.setList(map(self.buildList_timer, timerList)) self['title'].setText("%s Timer für ' %s ' gefunden." % (len(timerList), self.serien_name)) self['headline'].hide() else: # Show episodes self.showEpisodes = True self['text_red'].setText("(De)aktivieren") self['text_green'].setText("Zeige Timer") self['text_yellow'].show() self['text_blue'].show() self['text_ok'].show() self.loadEpisodes() def keyYellow(self): if self.loading and not self.showEpisodes: return check = self['menu_list'].getCurrent() if not check: return sindex = self['menu_list'].getSelectedIndex() #if len(self.episodes_list_cache) >= self.page: if self.page in self.episodes_list_cache: if len(self.episodes_list_cache[self.page]) != 0: if self.database.addBookmark(self.serien_name, self.episodes_list_cache[self.page][sindex][1], self.episodes_list_cache[self.page][sindex][1], self.episodes_list_cache[self.page][sindex][0], config.plugins.serienRec.NoOfRecords.value): self.session.open(MessageBox, "Die Episode wurde zum Merkzettel hinzugefügt", MessageBox.TYPE_INFO, timeout = 10) def nextPage(self): if self.loading and not self.showEpisodes: return if self.page <= self.maxPages: if self.page == self.maxPages: self.page = 1 else: self.page += 1 self.showPages() self.chooseMenuList.setList(map(self.buildList_episodes, [])) self.searchEpisodes() def backPage(self): if self.loading and not self.showEpisodes: return if self.page >= 1 and self.maxPages > 1: if self.page == 1: self.page = self.maxPages else: self.page -= 1 self.showPages() self.chooseMenuList.setList(map(self.buildList_episodes, [])) self.searchEpisodes() def answerStaffel(self, aStaffel): self.aStaffel = aStaffel if not self.aStaffel or self.aStaffel == "": return self.session.openWithCallback(self.answerFromEpisode, NTIVirtualKeyBoard, title = "von Episode:") def answerFromEpisode(self, aFromEpisode): self.aFromEpisode = aFromEpisode if not self.aFromEpisode or self.aFromEpisode == "": return self.session.openWithCallback(self.answerToEpisode, NTIVirtualKeyBoard, title = "bis Episode:") def answerToEpisode(self, aToEpisode): self.aToEpisode = aToEpisode if self.aToEpisode == "": self.aToEpisode = self.aFromEpisode if not self.aToEpisode: # or self.aFromEpisode is None or self.aStaffel is None: return else: print "[SerienRecorder] Staffel: %s" % self.aStaffel print "[SerienRecorder] von Episode: %s" % self.aFromEpisode print "[SerienRecorder] bis Episode: %s" % self.aToEpisode if self.database.addToTimerList(self.serien_name, self.aFromEpisode, self.aToEpisode, self.aStaffel, "dump", int(time.time()), "", "", 0, 1): self.chooseMenuList.setList(map(self.buildList_episodes, self.episodes_list_cache[self.page])) def keyBlue(self): if self.loading and not self.showEpisodes: return self.aStaffel = None self.aFromEpisode = None self.aToEpisode = None self.session.openWithCallback(self.answerStaffel, NTIVirtualKeyBoard, title = "%s: Staffel eingeben:" % self.serien_name) def __onClose(self): self.stopDisplayTimer()
class serienRecTimerListScreen(serienRecBaseScreen, Screen, HelpableScreen): def __init__(self, session): serienRecBaseScreen.__init__(self, session) Screen.__init__(self, session) HelpableScreen.__init__(self) self.skin = None self.session = session self.picload = ePicLoad() self.WochenTag = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"] self.database = SRDatabase(SerienRecorder.serienRecDataBaseFilePath) self["actions"] = HelpableActionMap( self, "SerienRecorderActions", { "ok": (self.keyOK, "Liste der erstellten Timer bearbeiten"), "cancel": (self.keyCancel, "zurück zur Serienplaner-Ansicht"), "left": (self.keyLeft, "zur vorherigen Seite blättern"), "right": (self.keyRight, "zur nächsten Seite blättern"), "up": (self.keyUp, "eine Zeile nach oben"), "down": (self.keyDown, "eine Zeile nach unten"), "red": (self.keyRed, "ausgewählten Timer löschen"), "green": (self.viewChange, "Sortierung ändern"), "yellow": (self.keyYellow, "umschalten alle/nur aktive Timer anzeigen"), "blue": (self.keyBlue, "alle noch ausstehenden Timer löschen"), "menu": (self.recSetup, "Menü für globale Einstellungen öffnen"), "startTeletext": (self.wunschliste, "Informationen zur ausgewählten Serie auf Wunschliste anzeigen" ), "0": (self.readLogFile, "Log-File des letzten Suchlaufs anzeigen"), "3": (self.showProposalDB, "Liste der Serien/Staffel-Starts anzeigen"), "4": (self.serieInfo, "Informationen zur ausgewählten Serie anzeigen"), "6": (self.showConflicts, "Liste der Timer-Konflikte anzeigen"), "7": (self.showWishlist, "Merkzettel (vorgemerkte Folgen) anzeigen"), "8": (self.cleanUp, "Timerliste bereinigen"), "9": (self.dropAllTimer, "Alle Timer aus der Datenbank löschen"), }, -1) self.helpList[0][2].sort() self["helpActions"] = ActionMap( [ "SerienRecorderActions", ], { # "ok" : self.keyOK, "displayHelp": self.showHelp, "displayHelp_long": self.showManual, }, 0) self.setupSkin() self.changesMade = False self.filter = True self.onLayoutFinish.append(self.readTimer) self.onClose.append(self.__onClose) self.onLayoutFinish.append(self.setSkinProperties) def callHelpAction(self, *args): HelpableScreen.callHelpAction(self, *args) def setSkinProperties(self): super(self.__class__, self).setSkinProperties() self['text_red'].setText("Entferne Timer") if config.plugins.serienRec.recordListView.value == 0: self['text_green'].setText("Zeige neueste Timer zuerst") elif config.plugins.serienRec.recordListView.value == 1: self['text_green'].setText("Zeige früheste Timer zuerst") self['text_ok'].setText("Liste bearbeiten") self['text_yellow'].setText("Zeige auch alte Timer") self['text_blue'].setText("Entferne neue Timer") self.num_bt_text[3][1] = "Bereinigen" self.num_bt_text[4][1] = "Datenbank leeren" super(self.__class__, self).startDisplayTimer() def setupSkin(self): InitSkin(self) self.chooseMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent) self.chooseMenuList.l.setFont( 0, gFont('Regular', 20 + int(config.plugins.serienRec.listFontsize.value))) self.chooseMenuList.l.setItemHeight(int(50 * skinFactor)) self['menu_list'] = self.chooseMenuList self['menu_list'].show() if config.plugins.serienRec.showCover.value: self['cover'].show() if not config.plugins.serienRec.showAllButtons.value: self['bt_red'].show() self['bt_green'].show() self['bt_ok'].show() self['bt_yellow'].show() self['bt_blue'].show() self['bt_exit'].show() self['bt_text'].show() self['bt_info'].show() self['bt_menu'].show() self['text_red'].show() self['text_green'].show() self['text_ok'].show() self['text_yellow'].show() self['text_blue'].show() self['text_0'].show() self['text_1'].show() self['text_2'].show() self['text_3'].show() self['text_4'].show() def updateMenuKeys(self): updateMenuKeys(self) def serieInfo(self): check = self['menu_list'].getCurrent() if check is None: return serien_name = self['menu_list'].getCurrent()[0][0] url = self.database.getMarkerURL(serien_name) if url: serien_id = url if serien_id: from SerienRecorderSeriesInfoScreen import serienRecShowInfo self.session.open(serienRecShowInfo, serien_name, serien_id) def wunschliste(self): serien_name = self['menu_list'].getCurrent()[0][0] url = self.database.getMarkerURL(serien_name) serien_id = url super(self.__class__, self).wunschliste(serien_id) def setupClose(self, result): super(self.__class__, self).setupClose(result) if result[1]: self.readTimer() def viewChange(self): if config.plugins.serienRec.recordListView.value == 1: config.plugins.serienRec.recordListView.value = 0 self['text_green'].setText("Zeige neueste Timer zuerst") else: config.plugins.serienRec.recordListView.value = 1 self['text_green'].setText("Zeige früheste Timer zuerst") config.plugins.serienRec.recordListView.save() SerienRecorder.configfile.save() self.readTimer() def readTimer(self, showTitle=True): current_time = int(time.time()) deltimer = 0 timerList = [] timers = self.database.getAllTimer( current_time if self.filter else None) for timer in timers: (serie, staffel, episode, title, start_time, stbRef, webChannel, eit, activeTimer) = timer if int(start_time) < int(current_time): deltimer += 1 timerList.append((serie, staffel, episode, title, start_time, webChannel, "1", 0, bool(activeTimer))) else: timerList.append((serie, staffel, episode, title, start_time, webChannel, "0", eit, bool(activeTimer))) if showTitle: self['title'].instance.setForegroundColor(parseColor("foreground")) if self.filter: self['title'].setText("Timer-Liste: %s ausstehende Timer" % len(timerList)) else: self['title'].setText( "Timer-Liste: %s abgeschlossene und %s ausstehende Timer" % (deltimer, len(timerList) - deltimer)) if config.plugins.serienRec.recordListView.value == 0: timerList.sort(key=lambda t: t[4]) elif config.plugins.serienRec.recordListView.value == 1: timerList.sort(key=lambda t: t[4]) timerList.reverse() self.chooseMenuList.setList(map(self.buildList, timerList)) if len(timerList) == 0: if showTitle: self['title'].instance.setForegroundColor( parseColor("foreground")) self['title'].setText( "Serien Timer - 0 Serien in der Aufnahmeliste.") self.getCover() def buildList(self, entry): (serie, staffel, episode, title, start_time, webChannel, foundIcon, eit, activeTimer) = entry xtime = time.strftime( self.WochenTag[time.localtime(int(start_time)).tm_wday] + ", %d.%m.%Y - %H:%M", time.localtime(int(start_time))) xtitle = "S%sE%s - %s" % (str(staffel).zfill(2), str(episode).zfill(2), title) if int(foundIcon) == 1: imageFound = "%simages/found.png" % SerienRecorder.serienRecMainPath else: imageFound = "%simages/black.png" % SerienRecorder.serienRecMainPath if activeTimer: SerieColor = None else: SerieColor = parseColor('red').argb() foregroundColor = parseColor('foreground').argb() return [ entry, (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 5, 8 * skinFactor, 32 * skinFactor, 32 * skinFactor, loadPNG(imageFound)), (eListboxPythonMultiContent.TYPE_TEXT, 40, 3, 250 * skinFactor, 26 * skinFactor, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, webChannel, SerieColor, SerieColor), (eListboxPythonMultiContent.TYPE_TEXT, 40, 29 * skinFactor, 250 * skinFactor, 18 * skinFactor, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, xtime, foregroundColor, foregroundColor), (eListboxPythonMultiContent.TYPE_TEXT, 300 * skinFactor, 3, 500 * skinFactor, 26 * skinFactor, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, serie, SerieColor, SerieColor), (eListboxPythonMultiContent.TYPE_TEXT, 300 * skinFactor, 29 * skinFactor, 500 * skinFactor, 18 * skinFactor, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, re.sub("(?<= - )dump\Z", "(Manuell hinzugefügt !!)", xtitle), foregroundColor, foregroundColor) ] def keyOK(self): self.session.open(serienRecModifyAdded, False) def callDeleteSelectedTimer(self, answer): if answer: serien_name = self['menu_list'].getCurrent()[0][0] staffel = self['menu_list'].getCurrent()[0][1] episode = self['menu_list'].getCurrent()[0][2] serien_title = self['menu_list'].getCurrent()[0][3] serien_time = self['menu_list'].getCurrent()[0][4] serien_channel = self['menu_list'].getCurrent()[0][5] serien_eit = self['menu_list'].getCurrent()[0][7] self.removeTimer(serien_name, staffel, episode, serien_title, serien_time, serien_channel, serien_eit) else: return def removeTimer(self, serien_name, staffel, episode, serien_title, serien_time, serien_channel, serien_eit=0): if config.plugins.serienRec.TimerName.value == "1": # "<Serienname>" title = serien_name elif config.plugins.serienRec.TimerName.value == "2": # "SnnEmm - <Episodentitel>" title = "S%sE%s - %s" % (str(staffel).zfill(2), str(episode).zfill(2), serien_title) elif config.plugins.serienRec.TimerName.value == "3": # "<Serienname> - SnnEmm" title = "%s - S%sE%s" % (serien_name, str(staffel).zfill(2), str(episode).zfill(2)) else: # "<Serienname> - SnnEmm - <Episodentitel>" title = "%s - S%sE%s - %s" % (serien_name, str(staffel).zfill(2), str(episode).zfill(2), serien_title) from SerienRecorderTimer import serienRecBoxTimer removed = serienRecBoxTimer.removeTimerEntry(title, serien_time, serien_eit) if not removed: print "[SerienRecorder] enigma2 NOOOTTT removed" else: print "[SerienRecorder] enigma2 Timer removed." self.database.removeTimer(serien_name, staffel, episode, None, serien_time, serien_channel, (serien_eit if serien_eit > 0 else None)) self.changesMade = True self.readTimer(False) self['title'].instance.setForegroundColor(parseColor("red")) self['title'].setText("Timer '- %s -' entfernt." % serien_name) def keyRed(self): check = self['menu_list'].getCurrent() if check is None: print "[SerienRecorder] Serien Timer leer." return else: serien_name = self['menu_list'].getCurrent()[0][0] staffel = self['menu_list'].getCurrent()[0][1] episode = self['menu_list'].getCurrent()[0][2] serien_title = self['menu_list'].getCurrent()[0][3] serien_time = self['menu_list'].getCurrent()[0][4] serien_channel = self['menu_list'].getCurrent()[0][5] serien_eit = self['menu_list'].getCurrent()[0][7] print self['menu_list'].getCurrent()[0] if config.plugins.serienRec.confirmOnDelete.value: self.session.openWithCallback( self.callDeleteSelectedTimer, MessageBox, "Soll '%s - S%sE%s - %s' wirklich entfernt werden?" % (serien_name, str(staffel).zfill(2), str(episode).zfill(2), re.sub("\Adump\Z", "(Manuell hinzugefügt !!)", serien_title)), MessageBox.TYPE_YESNO, default=False) else: self.removeTimer(serien_name, staffel, episode, serien_title, serien_time, serien_channel, serien_eit) def keyYellow(self): if self.filter: self['text_yellow'].setText("Zeige nur neue Timer") self.filter = False else: self['text_yellow'].setText("Zeige auch alte Timer") self.filter = True self.readTimer() def keyBlue(self): if config.plugins.serienRec.confirmOnDelete.value: self.session.openWithCallback( self.removeNewTimerFromDB, MessageBox, "Sollen wirklich alle noch ausstehenden Timer von der Box und aus der Datenbank entfernt werden?", MessageBox.TYPE_YESNO, default=False) else: self.removeNewTimerFromDB(True) def removeNewTimerFromDB(self, answer): if answer: current_time = int(time.time()) timers = self.database.getAllTimer(current_time) for timer in timers: (serie, staffel, episode, title, start_time, stbRef, webChannel, eit, activeTimer) = timer self.removeTimer(serie, staffel, episode, title, start_time, webChannel, eit) self.readTimer(False) self['title'].instance.setForegroundColor(parseColor("red")) self['title'].setText( "Alle noch ausstehenden Timer wurden entfernt.") else: return def removeOldTimerFromDB(self, answer): if answer: self.database.removeAllOldTimer() self.database.rebuild() self.readTimer(False) self['title'].instance.setForegroundColor(parseColor("red")) self['title'].setText("Alle alten Timer wurden entfernt.") else: return def dropAllTimer(self): if config.plugins.serienRec.confirmOnDelete.value: self.session.openWithCallback( self.removeOldTimerFromDB, MessageBox, "Sollen wirklich alle alten Timer aus der Datenbank entfernt werden?", MessageBox.TYPE_YESNO, default=False) else: self.removeOldTimerFromDB(True) def cleanUp(self): numberOfOrphanTimers = self.database.countOrphanTimers() self.session.openWithCallback( self.removeOrphanTimerFromDB, MessageBox, "Es wurden %d Einträge in der Timer-Liste gefunden, für die kein Serien-Marker vorhanden ist, sollen diese Einträge gelöscht werden?" % numberOfOrphanTimers, MessageBox.TYPE_YESNO, default=False) def removeOrphanTimerFromDB(self, answer): if answer: self.database.removeOrphanTimers() self.database.rebuild() else: return def getCover(self): check = self['menu_list'].getCurrent() if check is None: return serien_name = self['menu_list'].getCurrent()[0][0] serien_id = None url = self.database.getMarkerURL(serien_name) if url: serien_id = url SerienRecorder.getCover(self, serien_name, serien_id) def keyLeft(self): self['menu_list'].pageUp() self.getCover() def keyRight(self): self['menu_list'].pageDown() self.getCover() def keyDown(self): self['menu_list'].down() self.getCover() def keyUp(self): self['menu_list'].up() self.getCover() def __onClose(self): self.stopDisplayTimer() def keyCancel(self): if config.plugins.serienRec.refreshViews.value: self.close(self.changesMade) else: self.close(False)