def onInit(self): playControl = self.getControl(self.C_POPUP_PLAY) remindControl = self.getControl(self.C_POPUP_REMIND) channelLogoControl = self.getControl(self.C_POPUP_CHANNEL_LOGO) channelTitleControl = self.getControl(self.C_POPUP_CHANNEL_TITLE) programTitleControl = self.getControl(self.C_POPUP_PROGRAM_TITLE) playControl.setLabel(strings(WATCH_CHANNEL, self.program.channel.title)) if not self.program.channel.isPlayable(): playControl.setEnabled(False) self.setFocusId(self.C_POPUP_CHOOSE_STREAM) if self.database.getCustomStreamUrl(self.program.channel): chooseStrmControl = self.getControl(self.C_POPUP_CHOOSE_STREAM) chooseStrmControl.setLabel(strings(REMOVE_STRM_FILE)) if self.program.channel.logo is not None: channelLogoControl.setImage(self.program.channel.logo) channelTitleControl.setVisible(False) else: channelTitleControl.setLabel(self.program.channel.title) channelLogoControl.setVisible(False) programTitleControl.setLabel(self.program.title) if self.showRemind: remindControl.setLabel(strings(REMIND_PROGRAM)) else: remindControl.setLabel(strings(DONT_REMIND_PROGRAM))
def __init__(self): try: fetcher = FileFetcher('guides.ini', ADDON) if fetcher.fetchFile() < 0: xbmcgui.Dialog().ok(strings(FETCH_ERROR_TITLE), strings(FETCH_ERROR_LINE1), strings(FETCH_ERROR_LINE2)) print self.filePath self.guideParser.read(self.filePath) guideTypes = [] defaultGuideId = 0 # fallback to the first guide in case no default is actually set in the ini file for section in self.guideParser.sections(): sectMap = self.SectionMap(section) id = int(sectMap['id']) fName = sectMap['file'] sortOrder = int(sectMap['sort_order']) default = False if 'default' in sectMap and sectMap['default'] == 'true': default = True defaultGuideId = id guideTypes.append((id, sortOrder, section, fName, default)) self.guideTypes = sorted(guideTypes, key=itemgetter(self.GUIDE_SORT)) logger.debug('GuideTypes collected: %s' % str(self.guideTypes), __name__) ADDON.setSetting('xmltv.type', str(defaultGuideId)) except: logger.error('unable to parse guides.ini', __name__)
def getControl(self, controlId): try: return super(EPG, self).getControl(controlId) except: if controlId in self.ignoreMissingControlIds: return None if not self.isClosing: xbmcgui.Dialog().ok("Control not found " + str(controlId), strings(SKIN_ERROR_LINE1), strings(SKIN_ERROR_LINE2), strings(SKIN_ERROR_LINE3)) self.close() return None
def _scheduleNotification(self, channelTitle, programTitle, startTime): t = startTime - datetime.datetime.now() timeToNotification = ((t.days * 86400) + t.seconds) / 60 if timeToNotification < 0: return name = self.createAlarmClockName(programTitle, startTime) description = strings(NOTIFICATION_5_MINS, channelTitle) xbmc.executebuiltin('AlarmClock(%s-5mins,Notification(%s,%s,10000,%s),%d,True)' % (name.encode('utf-8', 'replace'), programTitle.encode('utf-8', 'replace'), description.encode('utf-8', 'replace'), self.icon, timeToNotification - 5)) description = strings(NOTIFICATION_NOW, channelTitle) xbmc.executebuiltin('AlarmClock(%s-now,Notification(%s,%s,10000,%s),%d,True)' % (name.encode('utf-8', 'replace'), programTitle.encode('utf-8', 'replace'), description.encode('utf-8', 'replace'), self.icon, timeToNotification))
def onInit(self): if self.initialized: # onInit(..) is invoked again by XBMC after a video addon exits after being invoked by XBMC.RunPlugin(..) debug("invoked, but we're already initialized!") return self.initialized = True self._hideControl(self.C_MAIN_MOUSE_CONTROLS, self.C_MAIN_OSD) self._showControl(self.C_MAIN_EPG, self.C_MAIN_LOADING) self.setControlLabel(self.C_MAIN_LOADING_TIME_LEFT, strings(BACKGROUND_UPDATE_IN_PROGRESS)) self.setFocusId(self.C_MAIN_LOADING_CANCEL) control = self.getControl(self.C_MAIN_EPG_VIEW_MARKER) if control: left, top = control.getPosition() self.focusPoint.x = left self.focusPoint.y = top self.epgView.left = left self.epgView.top = top self.epgView.right = left + control.getWidth() self.epgView.bottom = top + control.getHeight() self.epgView.width = control.getWidth() self.epgView.cellHeight = control.getHeight() / CHANNELS_PER_PAGE try: self.database = Database() except SourceNotConfiguredException: self.onSourceNotConfigured() self.close() return self.database.initialize(self.onSourceInitialized, self.isSourceInitializationCancelled) self.updateTimebar()
def _initialize(self, cancel_requested_callback): sqlite3.register_adapter(datetime.datetime, self.adapt_datetime) sqlite3.register_converter("timestamp", self.convert_datetime) self.sourceNotConfigured = False while True: if cancel_requested_callback is not None and cancel_requested_callback(): break try: self.conn = sqlite3.connect(self.databasePath, detect_types=sqlite3.PARSE_DECLTYPES) self.conn.execute("PRAGMA foreign_keys = ON") self.conn.row_factory = sqlite3.Row # create and drop dummy table to check if database is locked c = self.conn.cursor() c.execute("CREATE TABLE IF NOT EXISTS database_lock_check(id TEXT PRIMARY KEY)") c.execute("DROP TABLE database_lock_check") c.close() self._createTables() self.settingsChanged = self._wasSettingsChanged(ADDON) break except sqlite3.OperationalError: if cancel_requested_callback is None: debug("Database is locked, bailing out...") break else: # ignore 'database is locked' debug("Database is locked, retrying...") except sqlite3.DatabaseError: self.conn = None try: os.unlink(self.databasePath) except OSError: pass xbmcgui.Dialog().ok( ADDON.getAddonInfo("name"), strings(DATABASE_SCHEMA_ERROR_1), strings(DATABASE_SCHEMA_ERROR_2), strings(DATABASE_SCHEMA_ERROR_3), ) if self.conn is None: self.sourceNotConfigured = True
def getControl(self, controlId): try: return super(TVGuide, self).getControl(controlId) except: if controlId in self.ignoreMissingControlIds: return None if not self.isClosing: xbmcgui.Dialog().ok(buggalo.getRandomHeading(), strings(SKIN_ERROR_LINE1), strings(SKIN_ERROR_LINE2), strings(SKIN_ERROR_LINE3)) self.close() return None
def onSourceProgressUpdate(self, percentageComplete): control = self.getControl(self.C_MAIN_LOADING_PROGRESS) if percentageComplete < 1: if control: control.setPercent(1) self.progressStartTime = datetime.datetime.now() self.progressPreviousPercentage = percentageComplete elif percentageComplete != self.progressPreviousPercentage: if control: control.setPercent(percentageComplete) self.progressPreviousPercentage = percentageComplete delta = datetime.datetime.now() - self.progressStartTime if percentageComplete < 20: self.setControlLabel(self.C_MAIN_LOADING_TIME_LEFT, strings(CALCULATING_REMAINING_TIME)) else: secondsLeft = int(delta.seconds) / float(percentageComplete) * (100.0 - percentageComplete) if secondsLeft > 30: secondsLeft -= secondsLeft % 10 self.setControlLabel(self.C_MAIN_LOADING_TIME_LEFT, strings(TIME_LEFT) % secondsLeft) return not xbmc.abortRequested and not self.isClosing
def onClick(self, controlId): if controlId == self.C_POPUP_CHOOSE_STREAM and self.database.getCustomStreamUrl(self.program.channel): self.database.deleteCustomStreamUrl(self.program.channel) chooseStrmControl = self.getControl(self.C_POPUP_CHOOSE_STREAM) chooseStrmControl.setLabel(strings(CHOOSE_STRM_FILE)) if not self.program.channel.isPlayable(): playControl = self.getControl(self.C_POPUP_PLAY) playControl.setEnabled(False) else: self.buttonClicked = controlId self.close()
def onClick(self, controlId): if controlId == self.C_STREAM_STRM_BROWSE: stream = xbmcgui.Dialog().browse(1, ADDON.getLocalizedString(30304), 'video', '.strm') if stream: self.database.setCustomStreamUrl(self.channel, stream) self.getControl(self.C_STREAM_STRM_FILE_LABEL).setText(stream) self.strmFile = stream elif controlId == self.C_STREAM_ADDONS_OK: listControl = self.getControl(self.C_STREAM_ADDONS_STREAMS) item = listControl.getSelectedItem() if item: stream = item.getProperty('stream') self.database.setCustomStreamUrl(self.channel, stream) self.close() elif controlId == self.C_STREAM_FAVOURITES_OK: listControl = self.getControl(self.C_STREAM_FAVOURITES) item = listControl.getSelectedItem() if item: stream = item.getProperty('stream') self.database.setCustomStreamUrl(self.channel, stream) self.close() elif controlId == self.C_STREAM_STRM_OK: self.database.setCustomStreamUrl(self.channel, self.strmFile) self.close() elif controlId in [self.C_STREAM_ADDONS_CANCEL, self.C_STREAM_FAVOURITES_CANCEL, self.C_STREAM_STRM_CANCEL]: self.close() elif controlId in [self.C_STREAM_ADDONS_PREVIEW, self.C_STREAM_FAVOURITES_PREVIEW, self.C_STREAM_STRM_PREVIEW]: if self.player.isPlaying(): self.player.stop() self.getControl(self.C_STREAM_ADDONS_PREVIEW).setLabel(strings(PREVIEW_STREAM)) self.getControl(self.C_STREAM_FAVOURITES_PREVIEW).setLabel(strings(PREVIEW_STREAM)) self.getControl(self.C_STREAM_STRM_PREVIEW).setLabel(strings(PREVIEW_STREAM)) return stream = None visible = self.getControl(self.C_STREAM_VISIBILITY_MARKER).getLabel() if visible == self.VISIBLE_ADDONS: listControl = self.getControl(self.C_STREAM_ADDONS_STREAMS) item = listControl.getSelectedItem() stream = item.getProperty('stream') elif visible == self.VISIBLE_FAVOURITES: listControl = self.getControl(self.C_STREAM_FAVOURITES) item = listControl.getSelectedItem() stream = item.getProperty('stream') elif visible == self.VISIBLE_STRM: stream = self.strmFile if stream is not None: self.player.play(item = stream, windowed = True) if self.player.isPlaying(): self.getControl(self.C_STREAM_ADDONS_PREVIEW).setLabel(strings(STOP_PREVIEW)) self.getControl(self.C_STREAM_FAVOURITES_PREVIEW).setLabel(strings(STOP_PREVIEW)) self.getControl(self.C_STREAM_STRM_PREVIEW).setLabel(strings(STOP_PREVIEW))
def _scheduleNotification(self, channelTitle, programTitle, startTime): t = startTime - datetime.datetime.now() timeToNotification = ((t.days * 86400) + t.seconds) / 60 if timeToNotification < 0: return name = self.createAlarmClockName(programTitle, startTime) description = strings(NOTIFICATION_5_MINS, channelTitle) xbmc.executebuiltin( 'AlarmClock(%s-5mins,Notification(%s,%s,10000,%s),%d,True)' % (name.encode('utf-8', 'replace'), programTitle.encode('utf-8', 'replace'), description.encode('utf-8', 'replace'), self.icon, timeToNotification - 5)) description = strings(NOTIFICATION_NOW, channelTitle) xbmc.executebuiltin( 'AlarmClock(%s-now,Notification(%s,%s,10000,%s),%d,True)' % (name.encode( 'utf-8', 'replace'), programTitle.encode( 'utf-8', 'replace'), description.encode( 'utf-8', 'replace'), self.icon, timeToNotification))
def onFocus(self, controlId): try: controlInFocus = self.getControl(controlId) except Exception: return program = self._getProgramFromControl(controlInFocus) if program is None: return self.setControlLabel(self.C_MAIN_TITLE, '[B]%s[/B]' % program.title) self.setControlLabel(self.C_MAIN_TIME, '[B]%s - %s[/B]' % (self.formatTime(program.startDate), self.formatTime(program.endDate))) #Rob Newton - 20130130 - Display category self.setControlLabel(self.C_MAIN_CATEGORY, '[B]%s[/B]' % program.category) if program.description: description = program.description else: description = strings(NO_DESCRIPTION) self.setControlText(self.C_MAIN_DESCRIPTION, description) if program.channel.logo is not None: self.setControlImage(self.C_MAIN_LOGO, program.channel.logo) if program.imageSmall is not None: self.setControlImage(self.C_MAIN_IMAGE, program.imageSmall) #Rob Newton - 20130130 - Display SickBeard logo bottom right of cell if program.sickbeardManaged == 1: self.setControlImage(self.C_MAIN_SICKBEARD_OR_COUCHPOTATO_ICON, 'sb-logo-tiny.png') elif program.sickbeardManaged == 1: self.setControlImage(self.C_MAIN_SICKBEARD_OR_COUCHPOTATO_ICON, 'cp-logo-tiny.png') else: self.setControlImage(self.C_MAIN_SICKBEARD_OR_COUCHPOTATO_ICON, '') if ADDON.getSetting('program.background.enabled') == 'true' and program.imageLarge is not None: self.setControlImage(self.C_MAIN_BACKGROUND, program.imageLarge) if not self.osdEnabled and self.player.isPlaying(): self.player.stop()
def parseXMLTV(context, f, size, logoFolder, progress_callback): event, root = context.next() elements_parsed = 0 #Rob Newton - 20130131 - Only need to instantiate these once tmdbAPI = TMDB(ADDON.getSetting('tmdb.apikey')) tvdbAPI = TVDB(ADDON.getSetting('tvdb.apikey')) sbAPI = SickBeard(ADDON.getSetting('sickbeard.baseurl'),ADDON.getSetting('sickbeard.apikey')) cpAPI = CouchPotato(ADDON.getSetting('couchpotato.baseurl'),ADDON.getSetting('couchpotato.apikey')) for event, elem in context: if event == "end": result = None if elem.tag == "programme": channel = elem.get("channel") description = ascii(elem.findtext("desc")) iconElement = elem.find("icon") icon = None if iconElement is not None: icon = iconElement.get("src") if not description: description = strings(NO_DESCRIPTION) #Rob Newton - 20130127 - Parse the category of the program movie = False category = 'Normal' categories = '' categoryList = elem.findall("category") for cat in categoryList: categories += ', ' + cat.text if cat.text == 'Movie': movie = True category = cat.text elif cat.text == 'Sports': category = cat.text elif cat.text == 'Children': category = 'Kids' elif cat.text == 'Kids': category = cat.text elif cat.text == 'News': category = cat.text elif cat.text == 'Comedy': category = cat.text elif cat.text == 'Drama': category = cat.text #Trim prepended comma and space (considered storing all categories, but one is ok for now) categories = categories[2:] debug('Categories identified: %s' % categories) #If the movie flag was set, it should override the rest (ex: comedy and movie sometimes come together) if movie: category = 'Movie' #Rob Newton - 20130127 - Read the "new" boolean for this program and store as 1 or 0 for the db try: if elem.find("new") != None: new = 1 else: new = 0 except: new = 0 pass #Rob Newton - 20130127 - Decipher the TVDB ID by using the Zap2it ID in dd_progid tvdbid = 0 episodeId = 0 seasonNumber = 0 episodeNumber = 0 if not movie and ADDON.getSetting('tvdb.enabled') == 'true': dd_progid = '' episodeNumList = elem.findall("episode-num") for epNum in episodeNumList: if epNum.attrib["system"] == 'dd_progid': dd_progid = epNum.text #debug('dd_progid %s' % dd_progid) #The Zap2it ID is the first part of the string delimited by the dot # Ex: <episode-num system="dd_progid">MV00044257.0000</episode-num> dd_progid = dd_progid.split('.',1)[0] tvdbid = tvdbAPI.getIdByZap2it(dd_progid) #Sometimes GetSeriesByRemoteID does not find by Zap2it so we use the series name as backup if tvdbid == 0: tvdbid = tvdbAPI.getIdByShowName(ascii(elem.findtext('title'))) if tvdbid > 0: #Date element holds the original air date of the program airdateStr = elem.findtext('date') if airdateStr != None: try: #Change date format into the byAirDate lookup format (YYYY-MM-DD) t = time.strptime(airdateStr, '%Y%m%d') airDateTime = datetime.datetime(t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec) airdate = airDateTime.strftime('%Y-%m-%d') #Only way to get a unique lookup is to use TVDB ID and the airdate of the episode episode = ElementTree.fromstring(tvdbAPI.getEpisodeByAirdate(tvdbid, airdate)) episode = episode.find("Episode") episodeId = episode.findtext("id") seasonNumber = episode.findtext("SeasonNumber") episodeNumber = episode.findtext("EpisodeNumber") except: pass #Rob Newton - 20130131 - Lookup the movie info from TMDB imdbid = 0 if movie and ADDON.getSetting('tmdb.enabled') == 'true': #Date element holds the original air date of the program movieYear = elem.findtext('date') movieInfo = tmdbAPI.getMovie(ascii(elem.findtext('title')), movieYear) imdbid = movieInfo['imdb_id'] moviePosterUrl = tmdbAPI.getPosterUrl(movieInfo['poster_path']) #Rob Newton - 20130130 - Check for show being managed by SickBeard sbManaged = 0 if ADDON.getSetting('sickbeard.enabled') == 'true': if sbAPI.isShowManaged(tvdbid): sbManaged = 1 #Rob Newton - 20130130 - Check for movie being managed by CouchPotato cpManaged = 0 #if ADDON.getSetting('couchpotato.enabled') == 'true': # if cpAPI.isMovieManaged(imdbid): # cpManaged = 1 result = Program(channel, ascii(elem.findtext('title')), parseXMLTVDate(elem.get('start')), parseXMLTVDate(elem.get('stop')), description, None, icon, tvdbid, imdbid, episodeId, seasonNumber, episodeNumber, category, new, sbManaged, cpManaged) debug('new %r' % result) elif elem.tag == "channel": id = elem.get("id") title = elem.findtext("display-name") logo = None if logoFolder: logoFile = os.path.join(logoFolder.encode('utf-8', 'ignore'), title.encode('utf-8', 'ignore') + '.png') if xbmcvfs.exists(logoFile): logo = logoFile if not logo: iconElement = elem.find("icon") if iconElement is not None: logo = iconElement.get("src") result = Channel(id, title, logo) if result: elements_parsed += 1 if progress_callback and elements_parsed % 500 == 0: if not progress_callback(100.0 / size * f.tell()): raise SourceUpdateCanceledException() yield result root.clear() f.close()
def onEPGLoadError(self): self.redrawingEPG = False xbmcgui.Dialog().ok(strings(LOAD_ERROR_TITLE), strings(LOAD_ERROR_LINE1), strings(LOAD_ERROR_LINE2)) self.close()
def _showDescription(self, id): description = ZattooDB().getShowInfo(id,'description') if description == '': description = strings(NO_DESCRIPTION) self.setControlText(self.C_MAIN_DESCRIPTION, description)
def onClick(self, controlId): if controlId in [self.C_MAIN_LOADING_CANCEL, self.C_MAIN_MOUSE_EXIT]: self.close() return elif controlId == 4350: #touch start self.getControl(4401).setVisible(False) self.getControl(4400).setVisible(True) elif controlId == 4303: self._moveUp(CHANNELS_PER_PAGE) elif controlId == 4304: self._moveDown(CHANNELS_PER_PAGE) elif controlId == 4302: self.viewStartDate -= datetime.timedelta(hours=2) self.onRedrawEPG(self.channelIdx, self.viewStartDate) return elif controlId == 4305: self.viewStartDate += datetime.timedelta(hours=2) self.onRedrawEPG(self.channelIdx, self.viewStartDate) return elif controlId == 4307: self._previousDay() elif controlId == 4308: self._nextDay() elif controlId == 4309: self.getDate() elif controlId == 4001: self.viewStartDate = datetime.datetime.today() self.viewStartDate -= datetime.timedelta(minutes=self.viewStartDate.minute % 30, seconds=self.viewStartDate.second) self.onRedrawEPG(self.channelIdx, self.viewStartDate) if self.isClosing: return program = self._getProgramFromControl(self.getControl(controlId)) if program is None: return start = int(time.mktime(program['start_date'].timetuple())) end = int(time.mktime(program['end_date'].timetuple())) now = time.time() url='' try: if accountData['nonlive']['recording_number_limit'] > 0: if _zattooDB_.getRecord(program['showID']) > datetime.datetime.now(): RECORD = True else: RECORD = False else: RECORD = False except: RECORD = False try: if accountData['nonlive']['replay_availability'] == 'available' and _zattooDB_.getRestart(program['showID']) > datetime.datetime.now(): RECALL = True else: RECALL = False except: RECALL = False try: SERIE=accountData['nonlive']['recording_series_eligible'] except KeyError:SERIE = False # Set String for SubMenu recall_func = __addon__.getSetting('after_recall') if recall_func == "3": RECALL_MENU = ADD_TO_PLAYLIST else: RECALL_MENU = PLAY_FROM_START # if startime is in the future -> setup recording if start > now : #if not self.premiumUser: xbmcgui.Dialog().ok('Error',' ',strings(ERROR_NO_PREMIUM)) if RECORD: #print 'SERIES: ' + str(_zattooDB_.getSeries(program['showID'])) if SERIE and _zattooDB_.getSeries(program['showID']):#Series record avilable ret = xbmcgui.Dialog().select(program['channel']+': '+program['title']+' '+program['start_date'].strftime('%H:%M')+' - '+program['end_date'].strftime('%H:%M'),[strings(RECORD_SHOW), strings(RECORD_SERIES)]) if ret==0: #recording setup_recording({'program_id': program['showID']}) return elif ret==1: #recording_series setup_recording({'program_id': program['showID'], 'series': 'true'}) return else: return elif xbmcgui.Dialog().ok(program['title'], strings(RECORD_SHOW) + "?"): setup_recording({'program_id': program['showID']}) return else:return else: xbmcgui.Dialog().ok('Error', strings(ERROR_NO_PREMIUM)) return # else if endtime is in the past -> recall elif end < now: if RECALL and RECORD: if __addon__.getSetting('epgPlay')=='true': url = "plugin://"+__addonId__+"/?mode=watch_c&id=" + program['channel'] + "&showID=" + program['showID'] + "&start=" + str(start) + "&end=" + str(end) else: if SERIE and _zattooDB_.getSeries(program['showID']):#Series record avilable ret = xbmcgui.Dialog().select(program['channel']+': '+program['title']+' '+program['start_date'].strftime('%H:%M')+' - '+program['end_date'].strftime('%H:%M'),[strings(RECALL_MENU), strings(RECORD_SHOW), strings(RECORD_SERIES)]) if ret==0: #recall url = "plugin://"+__addonId__+"/?mode=watch_c&id=" + program['channel'] + "&showID=" + program['showID'] + "&restart=true" elif ret==1: #record #url = "plugin://"+__addonId__+"/?mode=record_p&program_id=" + program['showID'] setup_recording({'program_id': program['showID']}) return elif ret==2: #record series #url = "plugin://"+__addonId__+"/?mode=record_p&program_id=" + program['showID'] setup_recording({'program_id': program['showID'], 'series': 'true'}) return else: return else: ret = xbmcgui.Dialog().select(program['channel']+': '+program['title']+' '+program['start_date'].strftime('%H:%M')+' - '+program['end_date'].strftime('%H:%M'),[strings(RECALL_MENU), strings(RECORD_SHOW)]) if ret==0: #recall url = "plugin://"+__addonId__+"/?mode=watch_c&id=" + program['channel'] + "&showID=" + program['showID'] + "&restart=true" elif ret==1: #record #url = "plugin://"+__addonId__+"/?mode=record_p&program_id=" + program['showID'] setup_recording({'program_id': program['showID']}) return else: return elif RECALL: ret = xbmcgui.Dialog().select(program['channel']+': '+program['title']+' '+program['start_date'].strftime('%H:%M')+' - '+program['end_date'].strftime('%H:%M'),[strings(RECALL_MENU)]) if ret==0: #recall url = "plugin://"+__addonId__+"/?mode=watch_c&id=" + program['channel'] + "&showID=" + program['showID'] + "&restart=true" else: return else: xbmcgui.Dialog().ok('Error', strings(ERROR_NO_PREMIUM)) return # else currently playing else: if __addon__.getSetting('epgPlay')=='true' : url = "plugin://"+__addonId__+"/?mode=watch_c&id=" + program['channel'] + "&showID=" + program['showID'] elif RECALL and RECORD: if _zattooDB_.getSeries(program['showID']): #Series record avilable ret = xbmcgui.Dialog().select(program['channel']+': '+program['title']+' '+program['start_date'].strftime('%H:%M')+' - '+program['end_date'].strftime('%H:%M'), [strings(WATCH_CHANNEL), strings(RECALL_MENU), strings(RECORD_SHOW), strings(RECORD_SERIES)]) if ret==0: #watch live url = "plugin://"+__addonId__+"/?mode=watch_c&id=" + program['channel'] + "&showID=" + program['showID'] elif ret==1: #recall url = "plugin://"+__addonId__+"/?mode=watch_c&id=" + program['channel'] + "&showID=" + program['showID'] + "&restart=true" elif ret==2: #record #url = "plugin://"+__addonId__+"/?mode=record_p&program_id=" + program['showID'] setup_recording({'program_id': program['showID']}) return elif ret==3: #record series #url = "plugin://"+__addonId__+"/?mode=record_p&program_id=" + program['showID'] setup_recording({'program_id': program['showID'], 'series': 'true'}) return else: return else: ret = xbmcgui.Dialog().select(program['channel']+': '+program['title']+' '+program['start_date'].strftime('%H:%M')+' - '+program['end_date'].strftime('%H:%M'), [strings(WATCH_CHANNEL), strings(RECALL_MENU), strings(RECORD_SHOW)]) if ret==0: #watch live url = "plugin://"+__addonId__+"/?mode=watch_c&id=" + program['channel'] + "&showID=" + program['showID'] elif ret==1: #recall url = "plugin://"+__addonId__+"/?mode=watch_c&id=" + program['channel'] + "&showID=" + program['showID'] + "&restart=true" elif ret==2: #record #url = "plugin://"+__addonId__+"/?mode=record_p&program_id=" + program['showID'] setup_recording({'program_id': program['showID']}) return else: return elif RECORD: ret = xbmcgui.Dialog().select(program['channel']+': '+program['title']+' '+program['start_date'].strftime('%H:%M')+' - '+program['end_date'].strftime('%H:%M'), [strings(WATCH_CHANNEL), strings(RECORD_SHOW)]) if ret==0: #watch live url = "plugin://"+__addonId__+"/?mode=watch_c&id=" + program['channel'] + "&showID=" + program['showID'] elif ret==1: #record setup_recording({'program_id': program['showID']}) return else: return elif RECALL: ret = xbmcgui.Dialog().select(program['channel']+': '+program['title']+' '+program['start_date'].strftime('%H:%M')+' - '+program['end_date'].strftime('%H:%M'), [strings(WATCH_CHANNEL), strings(RECALL_MENU)]) if ret==0: #watch live url = "plugin://"+__addonId__+"/?mode=watch_c&id=" + program['channel'] + "&showID=" + program['showID'] elif ret==1: #recall url = "plugin://"+__addonId__+"/?mode=watch_c&id=" + program['channel'] + "&showID=" + program['showID'] + "&restart=true" else: url = "plugin://"+__addonId__+"/?mode=watch_c&id=" + program['channel'] + "&showID=" + program['showID'] self.channelIdx = _zattooDB_.get_channelNr(program['channel']) ret = __addon__.getSetting('after_recall') if ret == '2': player = xbmc.Player() if player.isPlaying(): debug('Player is playing') player.stop() del player xbmc.executebuiltin('RunPlugin(%s)' % url)
def onSourceNotConfigured(self): self.redrawingEPG = False self._hideControl(self.C_MAIN_LOADING) xbmcgui.Dialog().ok(strings(LOAD_ERROR_TITLE), strings(LOAD_ERROR_LINE1), strings(CONFIGURATION_ERROR_LINE2)) self.close()
def onEPGLoadError(self): self.redrawingEPG = False self._hideControl(self.C_MAIN_LOADING) xbmcgui.Dialog().ok(strings(LOAD_ERROR_TITLE), strings(LOAD_ERROR_LINE1), strings(LOAD_ERROR_LINE2)) self.close()
def onRedrawEPG(self, channelStart, startTime, focusFunction = None): if self.redrawingEPG or (self.database is not None and self.database.updateInProgress) or self.isClosing: debug('onRedrawEPG - already redrawing') return # ignore redraw request while redrawing debug('onRedrawEPG') self.redrawingEPG = True self.mode = MODE_EPG self._showControl(self.C_MAIN_EPG) self.updateTimebar(scheduleTimer = False) # show Loading screen self.setControlLabel(self.C_MAIN_LOADING_TIME_LEFT, strings(CALCULATING_REMAINING_TIME)) self._showControl(self.C_MAIN_LOADING) self.setFocusId(self.C_MAIN_LOADING_CANCEL) # remove existing controls self._clearEpg() try: self.channelIdx, channels, programs = self.database.getEPGView(channelStart, startTime, self.onSourceProgressUpdate, clearExistingProgramList = False) except SourceException: self.onEPGLoadError() return # date and time row self.setControlLabel(self.C_MAIN_DATE, self.formatDate(self.viewStartDate)) for col in range(1, 5): self.setControlLabel(4000 + col, self.formatTime(startTime)) startTime += HALF_HOUR if programs is None: self.onEPGLoadError() return # set channel logo or text for idx in range(0, CHANNELS_PER_PAGE): if idx >= len(channels): self.setControlImage(4110 + idx, '') self.setControlLabel(4010 + idx, '') else: channel = channels[idx] self.setControlLabel(4010 + idx, channel.title) if channel.logo is not None: self.setControlImage(4110 + idx, channel.logo) else: self.setControlImage(4110 + idx, '') for program in programs: idx = channels.index(program.channel) startDelta = program.startDate - self.viewStartDate stopDelta = program.endDate - self.viewStartDate cellStart = self._secondsToXposition(startDelta.seconds) if startDelta.days < 0: cellStart = self.epgView.left cellWidth = self._secondsToXposition(stopDelta.seconds) - cellStart if cellStart + cellWidth > self.epgView.right: cellWidth = self.epgView.right - cellStart if cellWidth > 1: if program.notificationScheduled: noFocusTexture = 'tvguide-program-red.png' focusTexture = 'tvguide-program-red-focus.png' else: noFocusTexture = 'tvguide-program-grey.png' focusTexture = 'tvguide-program-grey-focus.png' #Rob Newton - 20130127 - Override the standard item first then color items by category noFocusTexture = 'bevelBlueItemMiddle.png' if program.category == 'News': noFocusTexture = 'bevelAquagreenItemMiddle.png' if program.category == 'Movie': noFocusTexture = 'bevelRedItemMiddle.png' if program.category == 'Sports': noFocusTexture = 'bevelGreenItemMiddle.png' if program.category == 'Kids': noFocusTexture = 'bevelOrangeItemMiddle.png' if cellWidth < 25: title = '' # Text will overflow outside the button if it is too narrow else: title = program.title control = xbmcgui.ControlButton( cellStart, self.epgView.top + self.epgView.cellHeight * idx, cellWidth - 2, self.epgView.cellHeight - 2, title, noFocusTexture = noFocusTexture, focusTexture = focusTexture ) self.controlAndProgramList.append(ControlAndProgram(control, program)) # add program controls if focusFunction is None: focusFunction = self._findControlAt focusControl = focusFunction(self.focusPoint) controls = [elem.control for elem in self.controlAndProgramList] self.addControls(controls) if focusControl is not None: debug('onRedrawEPG - setFocus %d' % focusControl.getId()) self.setFocus(focusControl) self.ignoreMissingControlIds.extend([elem.control.getId() for elem in self.controlAndProgramList]) if focusControl is None and len(self.controlAndProgramList) > 0: self.setFocus(self.controlAndProgramList[0].control) self._hideControl(self.C_MAIN_LOADING) self.redrawingEPG = False
def onNotificationsCleared(): xbmcgui.Dialog().ok(strings(CLEAR_NOTIFICATIONS), strings(DONE))