def ask(self): debug("> LiveSportOnTV.ask()") self.downloadIcons() # make menu menu = self.MAIN_MENU_DATA.keys() menu.sort() menuIcons = [] for value in self.MAIN_MENU_DATA.values(): menuIcons.append(self.ICON_FN % value) menu.insert(0, __language__(500)) # exit menuIcons.insert(0, "") # exit has no icon selectedPos = 0 while menu: selectDialog = DialogSelect() selectDialog.setup( imageWidth=25, width=300, rows=len(menu), itemHeight=25, banner=os.path.join(DIR_GFX, "livesportontv_logo.gif"), panel=mytvGlobals.DIALOG_PANEL, ) selectedPos, action = selectDialog.ask(menu, selectedPos, icons=menuIcons) if selectedPos <= 0: # exit selected break title = menu[selectedPos] id = self.MAIN_MENU_DATA[title] self.displaySport(title, id) debug("< LiveSportOnTV.ask()")
def ask(self): debug("> ConfigGenreIcons().ask()") reInit = False self.load() # make menu imageList = [None] menu = [(__language__(500), '')] # exit keyList = self.genres.keys() keyList.sort() for key in keyList: fname = self.genres[key] yesno = mytvGlobals.config.configHelper.boolToYesNo(not fname.endswith(self.DISABLED_STR)) menu.append([key, yesno]) imageList.append(fname) useXOptions = [ __language__(350), __language__(351) ] # YES , NO selectDialog = DialogSelect() selectDialog.setup(__language__(542), rows=len(menu), width=330, imageWidth=30, \ title2=__language__(617),useXOptions=useXOptions, panel=mytvGlobals.DIALOG_PANEL) selectedPos, action = selectDialog.ask(menu, 0, imageList) # rename genre files if changed changed=False for key, value in menu: if value: if self.setState(key, mytvGlobals.config.configHelper.yesNoToBool(value)): changed = True del selectDialog debug("< ConfigGenreIcons().ask() changed=%s" % changed) return changed
def displaySport(self, title, ID): debug("> LiveSportOnTV.displaySport ID=%s" % ID) # ID string is a url otherwise a number if isinstance(ID, int): url = self.URL_RSS + str(ID) # else: url = self.URL_RSS_NOID + ID listTitle = __language__(519) menu = [] menuIcons = [] dialogProgress.create(__language__(519), __language__(303), title) html = fetchURL(url) dialogProgress.close() if html: menu, menuIcons = self.parseRSS(html, ID) if menu: menu.insert(0, xbmcgui.ListItem(__language__(500), "")) # exit menuIcons.insert(0, "") # exit icon selectDialog = DialogSelect() selectDialog.setup( listTitle, imageWidth=25, width=720, rows=len(menu), itemHeight=24, font=FONT10, panel=mytvGlobals.DIALOG_PANEL, ) selectedPos, action = selectDialog.ask(menu, icons=menuIcons) debug("< LiveSportOnTV.displaySport")
def ask(self, progTitle='', countryCode=''): debug("> TVRage.ask() countryCode="+countryCode) # setup country code countryCode = countryCode.upper() if not countryCode or countryCode not in self.COUNTRIES: self.countryCode = self.DEFAULT_COUNTRY else: self.countryCode = countryCode # create menu according to countryCode & get country schedule self.createMainMenu() if self.getSchedule(): selectedPos = 1 # start on Today # show this dialog and wait until it's closed while self.mainMenu: selectDialog = DialogSelect() selectDialog.setup(width=300, rows=len(self.mainMenu), banner=self.FILE_LOGO, panel=mytvGlobals.DIALOG_PANEL) selectedPos,action = selectDialog.ask(self.mainMenu, selectedPos) if selectedPos <= 0: # exit selected break selectedItem = self.mainMenu[selectedPos].getLabel() if selectedItem == self.MENU_OPT_YESTERDAY: self.scheduledDay(dayDelta=0) elif selectedItem == self.MENU_OPT_TODAY: self.scheduledDay(dayDelta=1) elif selectedItem == self.MENU_OPT_TOMORROW: self.scheduledDay(dayDelta=2) elif selectedItem == self.MENU_OPT_WEEK: self.scheduledWeek() elif selectedItem == self.MENU_OPT_DAY: self.scheduledDay() elif selectedItem == self.MENU_OPT_CURR_PROG: self.searchShow(progTitle) elif selectedItem == self.MENU_OPT_SEARCH: self.searchShow() elif selectedItem == self.MENU_OPT_COUNTRY: if self.selectCountry(): # changed deleteFile(self.FILE_SCHEDULE) # delete old country schedule self.createMainMenu() # rebuild menu if not self.getSchedule(): # fetch & parse new schedule self.close() del selectDialog self.deleteCache() debug("< TVRage.ask()")
def searchShow(self, showName=''): debug("> TVRage.searchShow()") firstSearch = True found = False while not found: if not firstSearch or not showName: showName = doKeyboard(showName, __language__(569)) if not showName: break firstSearch = False # download search page url = self.URL_SEARCH % showName dialogProgress.create(__language__(518), __language__(311), showName) doc = fetchURL(url) dialogProgress.close() if doc: flags = [] # regex = "src=['\"](.*?)['\"].+?href=.*?>(.*?)<.+?align='center'>(.*?)<" # 25/01/08 regex = "src=['\"](.*?)['\"].+?href=.*?>(.*?)<.+?(<table.*?</table>)" # 30/04/08 matches = parseDocList(doc, regex, '<b>Found ','</div') if matches: menu = [xbmcgui.ListItem(__language__(500),'')] flags = [''] found = True for match in matches: imgFN = os.path.join(DIR_DATASOURCE_GFX, os.path.basename(match[0])) flags.append(imgFN) title = cleanHTML(decodeEntities(match[1])) year = cleanHTML(decodeEntities(match[2])) menu.append(xbmcgui.ListItem(title, year)) showSelectPos = 0 while menu: selectDialog = DialogSelect() selectDialog.setup(width=475, rows=len(menu), imageWidth=25, banner=self.FILE_LOGO, panel=mytvGlobals.DIALOG_PANEL) showSelectPos,action = selectDialog.ask(menu, showSelectPos, icons=flags) if showSelectPos <= 0: # exit selected break showName = menu[showSelectPos].getLabel() self.getShowInfo(showName) else: messageOK(__language__(518), __language__(117), showName) debug("< TVRage.searchShow()")
def enterFont(self, currentValue): debug("> enterFont()") value = currentValue menu = [__language__(500)] for font in ALL_FONTS: menu.append(font) try: currentIdx = menu.index(currentValue) except: currentIdx = 0 selectDialog = DialogSelect() selectDialog.setup(__language__(572), rows=len(menu), width=360, panel=mytvGlobals.DIALOG_PANEL) selectedPos, action = selectDialog.ask(menu, currentIdx) if selectedPos > 0: value = menu[selectedPos] debug("< enterFont() value=%s" % value) return value
def selectCountry(self): debug("> TVRage.selectCountry()") origCode = self.countryCode flags = [] for code in self.COUNTRIES: flags.append(os.path.join(DIR_DATASOURCE_GFX, code + '.gif')) selectDialog = DialogSelect() selectDialog.setup(imageWidth=25, width=200, rows=len(self.COUNTRIES), banner=self.FILE_LOGO, panel=mytvGlobals.DIALOG_PANEL) selectedPos,action = selectDialog.ask(self.COUNTRIES, icons=flags) if selectedPos > 0: self.countryCode = self.COUNTRIES[selectedPos] changed = (origCode != self.countryCode) debug("< TVRage.selectCountry() changed=%s countryCode=%s" % (changed, self.countryCode)) return changed
def displayShowMenu(self, menu, title): debug("> TVRage.displayShowMenu()") selectedPos = 0 while menu: selectDialog = DialogSelect() selectDialog.setup(title, width=650, rows=len(menu), banner=self.FILE_LOGO, panel=mytvGlobals.DIALOG_PANEL) selectedPos,action = selectDialog.ask(menu, selectedPos) if selectedPos <= 0: break # if selected a Show, download extra info and display showName, epName = self.parseShowEpisodeName(menu[selectedPos]) # at least a showName reqd. if showName: self.getShowInfo(showName) debug("< TVRage.displayShowMenu()")
def configChannelName(): debug("> configChannelName()") changed = False # exit, No Channel name, No IDs, ID, alt.ID menuList = [__language__(500), __language__(577), __language__(560), __language__(561), __language__(562)] # popup dialog to select choice selectDialog = DialogSelect() selectDialog.setup(__language__(539), rows=len(menuList), width=270, panel=mytvGlobals.DIALOG_PANEL) selectedPos, action = selectDialog.ask(menuList) if selectedPos > 0: # 0 no ch names or id # 1 no ch id shown # 2 ch id # 3 alt ch id changed = mytvGlobals.config.setSystem(MYTVConfig.KEY_SYSTEM_SHOW_CH_ID, selectedPos-1) debug("< configChannelName() changed=%s" % changed) return changed
def scheduledDay(self, dayDelta=None): debug("> TVRage.scheduledDay() dayDelta="+str(dayDelta)) if dayDelta == None: menu = self.DAYS + self.scheduleDates[3:] # join [Yes, Tod, Tom] onto rest of week dates menu.insert(0, __language__(500)) # exit selectDialog = DialogSelect() selectDialog.setup(width=300, rows=len(menu), banner=self.FILE_LOGO, panel=mytvGlobals.DIALOG_PANEL) dayDelta,action = selectDialog.ask(menu) dayDelta -= 1 # allow for exit if dayDelta >= 0: menu = [ __language__(500)] date = self.scheduleDates[dayDelta] self.menuAddDate(menu, date) title = __language__(211) % date self.displayShowMenu(menu, title) debug("< TVRage.scheduledDay()")
def ask(self): debug("> ConfigMenu().ask()") # show this dialog and wait until it's closed reInit = mytvGlobals.INIT_NONE selectedPos = 0 while True: menuList = self.createMenuList() selectDialog = DialogSelect() selectDialog.setup(__language__(502), width=550, rows=len(menuList), banner=LOGO_FILENAME, panel=mytvGlobals.DIALOG_PANEL) selectedPos, action = selectDialog.ask(menuList, selectedPos) if selectedPos <= 0: break # exit selected # exec func associated with menu option (if has one) if self.menu[selectedPos][self.FUNC]: done = self.menu[selectedPos][self.FUNC]() # call menu func # force exit if updating script if done and self.menu[selectedPos][0] == __language__(554): # update script # restart script after update deleteCacheFiles(0) xbmc.executebuiltin('XBMC.RunScript(%s)'%(os.path.join(DIR_HOME, 'default.py'))) sys.exit(0) # end current instance else: done = True # set reInit status if still false. # this allows setting to persist if done: optInitLevel = self.menu[selectedPos][self.REINIT_REQUIRED] debug("func complete, optInitLevel=" + str(optInitLevel)) if optInitLevel > reInit: reInit = optInitLevel # save highest reinit level # exit back to epg for reInint now for some options if optInitLevel == mytvGlobals.INIT_FULL_NOW: debug("options requires exit menu to epg now") break debug("< ConfigMenu().ask() reInit=%s" % reInit) return reInit
def configEPGRows(): debug("configEPGRows()") selectedPos = 0 while True: menuList = [ xbmcgui.ListItem(__language__(500)), xbmcgui.ListItem(__language__(573), mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_EPG_ROW_HEIGHT)), xbmcgui.ListItem(__language__(574), mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_EPG_ROW_GAP_HEIGHT)) ] selectDialog = DialogSelect() selectDialog.setup(__language__(545), rows=len(menuList), width=270, panel=mytvGlobals.DIALOG_PANEL) selectedPos, action = selectDialog.ask(menuList, selectedPos) if selectedPos <= 0: break # exit selected if selectedPos == 1: key = MYTVConfig.KEY_DISPLAY_EPG_ROW_HEIGHT elif selectedPos == 2: key = MYTVConfig.KEY_DISPLAY_EPG_ROW_GAP_HEIGHT title = menuList[selectedPos].getLabel() value = menuList[selectedPos].getLabel2() value = int(doKeyboard(value, title, KBTYPE_NUMERIC)) mytvGlobals.config.setDisplay(key, value)
def ask(self): debug("> ask()") # show this dialog and wait until it's closed changed = False selectedPos = 0 while True: menuList = self.createMenuList() selectDialog = DialogSelect() selectDialog.setup(__language__(544), rows=len(menuList), width=300, panel=mytvGlobals.DIALOG_PANEL) selectedPos, action = selectDialog.ask(menuList, selectedPos) if selectedPos <= 0: break # exit selected else: # FONTS selectedValue = menuList[selectedPos].getLabel2() key = self.menu[selectedPos][self.CONFIG_KEY] value = self.enterFont(selectedValue) if (value != selectedValue) and mytvGlobals.config.setDisplay(key, value): changed = True debug("< ask() changed=%s " % changed) return changed
def ask(self): debug("> ConfigGenreColours().ask()") reInit = mytvGlobals.INIT_NONE if not self.genres: self.load() # show this dialog and wait until it's closed selectedPos = 0 while True: menu, colourImgList = self.createMenu() selectDialog = DialogSelect() selectDialog.setup(__language__(543), rows=len(menu), width=450, imageWidth=30, panel=mytvGlobals.DIALOG_PANEL) selectedPos, action = selectDialog.ask(menu, selectedPos, colourImgList) if selectedPos <= 0: # exit break elif selectedPos == 1: # ALL OFF self.reset() reInit = mytvGlobals.INIT_DISPLAY else: genreName = menu[selectedPos][0] backgFile = self.genres[genreName] if not backgFile: # set a default backg colour backgFile = "DarkBlue.png" backgFile, textColor = ButtonColorPicker().ask(backgFile) if backgFile == None: # DISABLED self.genres[genreName] = None mytvGlobals.config.action(self.SECTION_GENRE_COLOURS, genreName, mode=ConfigHelper.MODE_REMOVE_OPTION) reInit = mytvGlobals.INIT_DISPLAY elif backgFile: # SELECTED self.genres[genreName] = backgFile mytvGlobals.config.action(self.SECTION_GENRE_COLOURS, genreName, os.path.basename(backgFile), \ mode=ConfigHelper.MODE_WRITE) reInit = mytvGlobals.INIT_DISPLAY debug("< ConfigGenreColours().ask() reInit=%s" % reInit) return reInit
def ask(self): debug("> ConfigEPGColours.ask()") reInit = False # show this dialog and wait until it's closed selectedPos = 0 while True: selectDialog = DialogSelect() selectDialog.setup(__language__(541), width=330, rows=len(self.menu), panel=mytvGlobals.DIALOG_PANEL) selectedPos, action = selectDialog.ask(self.menu, selectedPos) if selectedPos <= 0: break selectedOpt = self.menu[selectedPos] if selectedOpt == self.MENU_OPT_CHNAME: textColor = mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_CHNAMES) backgFile, textColor = ButtonColorPicker().ask("", textColor, selectedOpt) if textColor: mytvGlobals.config.setDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_CHNAMES, textColor) elif selectedOpt == self.MENU_OPT_TITLE: textColor = mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_TITLE) backgFile, textColor = ButtonColorPicker().ask("", textColor, selectedOpt) if textColor: mytvGlobals.config.setDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_TITLE, textColor) elif selectedOpt == self.MENU_OPT_TITLE_DESC: textColor = mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_SHORT_DESC) backgFile, textColor = ButtonColorPicker().ask("", textColor, selectedOpt) if textColor: mytvGlobals.config.setDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_SHORT_DESC, textColor) elif selectedOpt == self.MENU_OPT_ODD: # ODD line backgFile = mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_NOFOCUS_ODD) textColor = mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_TEXT_ODD) backgFile, textColor = ButtonColorPicker().ask(backgFile, textColor, selectedOpt) if backgFile and textColor: mytvGlobals.config.setDisplay(MYTVConfig.KEY_DISPLAY_NOFOCUS_ODD, backgFile) mytvGlobals.config.setDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_TEXT_ODD, textColor) elif selectedOpt == self.MENU_OPT_EVEN: # EVEN line backgFile = mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_NOFOCUS_EVEN) textColor = mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_TEXT_EVEN) backgFile, textColor = ButtonColorPicker().ask(backgFile, textColor, selectedOpt) if backgFile and textColor: mytvGlobals.config.setDisplay(MYTVConfig.KEY_DISPLAY_NOFOCUS_EVEN, backgFile) mytvGlobals.config.setDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_TEXT_EVEN, textColor) elif selectedOpt == self.MENU_OPT_FAV: # FAV SHOWS backgFile = mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_NOFOCUS_FAV) textColor = mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_TEXT_FAV) backgFile, textColor = ButtonColorPicker().ask(backgFile, textColor, selectedOpt) if backgFile and textColor: mytvGlobals.config.setDisplay(MYTVConfig.KEY_DISPLAY_NOFOCUS_FAV, backgFile) mytvGlobals.config.setDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_TEXT_FAV, textColor) elif selectedOpt == self.MENU_OPT_FOCUS: # FOCUS backgFile = mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_FOCUS) textColor = mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_TEXT_ODD) backgFile, textColor = ButtonColorPicker().ask(backgFile, textColor, selectedOpt) if backgFile and textColor: mytvGlobals.config.setDisplay(MYTVConfig.KEY_DISPLAY_FOCUS, backgFile) mytvGlobals.config.setDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_TEXT_ODD, textColor) elif selectedOpt == self.MENU_OPT_COLOUR_ARROWS: textColor = mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_ARROWS) backgFile, textColor = ButtonColorPicker().ask("", textColor, selectedOpt) if textColor: mytvGlobals.config.setDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_ARROWS, textColor) elif selectedOpt == self.MENU_OPT_COLOUR_NOWTIME: textColor = mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_NOWTIME) backgFile, textColor = ButtonColorPicker().ask("", textColor, selectedOpt) if textColor: mytvGlobals.config.setDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_NOWTIME, textColor) elif selectedOpt == self.MENU_OPT_COLOUR_TIMERBAR: textColor = mytvGlobals.config.getDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_TIMERBAR) backgFile, textColor = ButtonColorPicker().ask("", textColor, selectedOpt) if textColor: mytvGlobals.config.setDisplay(MYTVConfig.KEY_DISPLAY_COLOUR_TIMERBAR, textColor) elif selectedOpt == self.MENU_OPT_RESET: mytvGlobals.config.setDisplay(MYTVConfig.KEY_DISPLAY_SKIN, "") mytvGlobals.config.initSectionDisplay() messageOK(__language__(541), __language__(215) % selectedOpt) else: # load a .skin file and overwrite keys with loaded values debug("change to a theme") section = mytvGlobals.SECTION_DISPLAY skinName = self.menu[selectedPos] items = mytvGlobals.config.action(section, mode=ConfigHelper.MODE_ITEMS) # get curr items # make dict from items displayDict = {} for key, value in items: displayDict[key] = value displayDict = mytvGlobals.config.loadSkinConfig(displayDict, skinName) # load skin file mytvGlobals.config.action(section, mode=ConfigHelper.MODE_REMOVE_SECTION) # clear section mytvGlobals.config.action(section, displayDict, mode=ConfigHelper.MODE_INIT_SECTION) # save new messageOK(__language__(541), __language__(215) % selectedOpt) reInit = True debug("< ConfigEPGColours.ask() reInit=%s" % reInit) return reInit
def configReorderChannels(): debug("> configReorderChannels()") def isHiddenText(text): if text[0] == '*': # * indicates HIDDEN text = __language__(350) # YES isHidden = True else: text = __language__(351) # NO isHidden = False return text, isHidden def setHidden(text, isHidden): if isHidden and text[0] != '*': # make hidden return '*' + text elif not isHidden and text[0] == '*': # unhide return text[1:] return text def makeMenu(): debug("> ReorderChannels.makeMenu()") # add channel name to list from [chid, ch name, alt ch id] menu = [ [__language__(500), ''] ] for channel in channels: label2,isHidden = isHiddenText(channel[1]) if isHidden: label = channel[1][1:] # removes the * at beginnning else: label = channel[1] menu.append( [label, label2] ) debug("< ReorderChannels.makeMenu()") return menu # load channel names channelsFilename = getChannelListFilename() channels = readChannelsList(channelsFilename, loadHidden=True) # chid, chname, alt.chid # loop until finished then break useXOptions = [ __language__(350), __language__(351) ] # YES , NO newChannels = [] menu = makeMenu() allowReorder = (len(menu) > 2) selectDialog = DialogSelect() selectDialog.setup(__language__(597), width=450, rows=len(menu), useXOptions=useXOptions, \ reorder=allowReorder,title2=__language__(609),movingTitle=__language__(598), \ panel=mytvGlobals.DIALOG_PANEL) selectedPos,action = selectDialog.ask(menu) if selectedPos <= 0: for menuIdx in range(len(menu)): label,label2 = menu[menuIdx] if not label2: # ignore exit continue for channel in channels: # compare menu's chName against channel chName, whcih may/not have * prefix if label == channel[1] or label == channel[1][1:]: isHidden = (label2 == __language__(350)) channel[1] = setHidden(channel[1], isHidden) newChannels.append(channel) break del selectDialog writeChannelsList(channelsFilename, newChannels) changed = True debug("< configReorderChannels changed=%s" % changed) return changed