def init(self): self.started = False self.showList = None self.searchPanel = None self.moviePanel = None self.ruleList = None self.searchTerms = '' self.category = 'series' self.play = None self.options = None self.devices = self.main.devices self.storageServer = hdhr.storageservers.StorageServers(self.devices) self.lineUp = self.main.lineUp self.cron = self.main.cron self.lastRecordingsRefresh = 0 self.lastSearchRefresh = 0 self.lastRulesRefresh = 0 self.nowShowing = None self.nowShowingHalfHour = None self.nsPanel2 = False self.nowShowingPanel1LastItem = None self.nowShowingPanel2LastItem = None self.wheelIgnore = False self.movingRule = None self.mode = 'WATCH' util.setGlobalProperty('now.showing','') util.setGlobalProperty('movie.posters','') util.setGlobalProperty('NO_RESULTS',T(32802)) util.setGlobalProperty('NO_RECORDINGS',T(32803)) util.setGlobalProperty('NO_RULES',T(32804))
def fillRules(self, update=False): self.lastRulesRefresh = time.time() if update: self.storageServer.updateRules() items = [] for r in self.storageServer.rules: item = kodigui.ManagedListItem(r.title, data_source=r) if r.dateTimeOnly: item.setProperty( 'rule.recent_only', '{0} at {1}'.format(r.displayDateDTO(), r.displayTimeDTO())) elif r.teamOnly: item.setProperty('rule.recent_only', '{0}: {1}'.format('TEAM', r.teamOnly)) else: item.setProperty('rule.recent_only', r.recentOnly and T(32805) or T(32806)) item.setProperty('seriesID', r.seriesID) #print '{0} {1}'.format(r.ruleID, r.title) items.append(item) if not items: util.setGlobalProperty( 'NO_RULES', self.storageServer.getRulesFailed and u'[COLOR 80FF0000]{0}[/COLOR]'.format(T(32830)) or T(32804)) else: util.setGlobalProperty('NO_RULES', '') self.ruleList.reset() self.ruleList.addItems(items)
def fillSearchPanel(self, update=False, movies=False): self.lastSearchRefresh = time.time() items = [] try: searchResults = hdhr.guide.search(self.devices.apiAuthID(),category=self.category,terms=self.searchTerms) or [] except: searchResults = [] e = util.ERROR() util.showNotification(e,header=T(32831)) util.setGlobalProperty('NO_RESULTS',not searchResults and T(32802) or '') for r in searchResults: item = kodigui.ManagedListItem(r.title,r.synopsis,thumbnailImage=r.icon,data_source=r) item.setProperty('series.title',r.title) item.setProperty('channel.number',r.channelNumber) item.setProperty('channel.name',r.channelName) item.setProperty('channel.icon',r.channelIcon) item.setProperty('has.rule',r.hasRule and '1' or '') item.setProperty('hidden',r.hidden and '1' or '') items.append(item) if update: if self.category == 'movie': self.moviePanel.replaceItems(items) else: self.searchPanel.replaceItems(items) else: if self.category == 'movie': self.moviePanel.reset() self.moviePanel.addItems(items) else: self.searchPanel.reset() self.searchPanel.addItems(items)
def fillShows(self, update=False): self.lastRecordingsRefresh = time.time() groupItems = [] seriesItems = [] groups = {} for r in self.storageServer.recordings: if r.displayGroupID in groups: item = groups[r.displayGroupID] ct = int(item.getProperty('show.count')) ct += 1 item.setProperty('show.count', str(ct)) else: if r.category == 'movie': title = T(32843) elif r.category == 'sport': title = T(32844) else: title = r.seriesTitle item = kodigui.ManagedListItem(title, r.seriesSynopsis, thumbnailImage=r.icon, data_source=r) item.setProperty('show.count', '1') item.setProperty('groupID', r.displayGroupID) groups[r.displayGroupID] = item if r.groupIsSeries: seriesItems.append(item) else: groupItems.append(item) groupItems.sort(key=lambda x: util.sortTitle(x.getLabel())) seriesItems.sort(key=lambda x: util.sortTitle(x.getLabel())) items = groupItems + seriesItems if not items: util.setGlobalProperty( 'NO_RECORDINGS', self.storageServer.getRecordingsFailed and u'[COLOR 80FF0000]{0}[/COLOR]'.format(T(32829)) or T(32803)) else: util.setGlobalProperty('NO_RECORDINGS', '') if items: allItem = kodigui.ManagedListItem( 'ALL RECORDINGS', thumbnailImage='script-hdhomerun-view-dvr_all.png') items.insert(0, allItem) if update: self.showList.replaceItems(items) else: self.showList.reset() self.showList.addItems(items)
def onClick(self,controlID): if controlID in (238,244,245): return if controlID == 241: self.option = 'SEARCH' elif controlID == 248: self.option = 'LIVETV' elif controlID == 247: self.option = 'EXIT' util.setGlobalProperty('window.animations','') self.doClose()
def main(): global BACKGROUND util.setGlobalProperty('running', '1') try: with util.Cron(1): BACKGROUND = background.BackgroundWindow.create(function=_main) BACKGROUND.modal() del BACKGROUND finally: util.setGlobalProperty('running', '')
def onPlayBackFailed(self): util.setGlobalProperty('playing.dvr','') self.setCurrent() util.DEBUG_LOG('ON PLAYBACK FAILED') self.showProgress() #In case we failed to play video on startup self.showSeekBar(hide=True) if self.fallbackChannel: channel = self.fallbackChannel self.fallbackChannel = None self.playChannel(channel) util.showNotification(util.T(32023),time_ms=5000,header=util.T(32022)) self.windowLoop()
def start(): util.LOG('[- START -----------------------] [{0}]'.format( util.ADDON.getAddonInfo('version'))) util.setGlobalProperty('guide.filter', '') util.setGlobalProperty('section', '') with util.Cron(interval=5): bw = windows.BackgroundWindow.create() connected = False ID = util.loadTabloDeviceID() if ID: tablo.API.discover() connected = tablo.API.selectDevice(ID) while True: if not connected: if connected is None: w = windows.ConnectWindow.open(updating=True) del w connected = False if ID: tablo.API.discover() connected = tablo.API.selectDevice(ID) continue else: w = windows.ConnectWindow.open() if w.exit or not tablo.API.deviceSelected(): return del w if tablo.API.getUpdateStatus(): util.DEBUG_LOG('Updating ({0})'.format(tablo.API.device.name)) connected = None continue windows.WM.start() if windows.WM.exit: break connected = False bw.show() bw.setProperty('busy', '1') backgroundthread.BGThreader.shutdown() bw.doClose() del bw util.LOG('[- END -------------------------]')
def onPlayBackStopped(self): try: if self.recordDialog: return except AttributeError: pass util.setGlobalProperty('playing.dvr','') self.setCurrent() util.DEBUG_LOG('ON PLAYBACK STOPPED') self.showProgress() #In case we failed to play video on startup self.showOverlay(False) self.showSeekBar(hide=True) self.windowLoop()
def start(): util.LOG('[- START -----------------------] [{0}]'.format(util.ADDON.getAddonInfo('version'))) util.setGlobalProperty('guide.filter', '') util.setGlobalProperty('section', '') with util.Cron(interval=5): bw = windows.BackgroundWindow.create() connected = False ID = util.loadTabloDeviceID() if ID: tablo.API.discover() connected = tablo.API.selectDevice(ID) while True: if not connected: if connected is None: w = windows.ConnectWindow.open(updating=True) del w connected = False if ID: tablo.API.discover() connected = tablo.API.selectDevice(ID) continue else: w = windows.ConnectWindow.open() if w.exit or not tablo.API.deviceSelected(): return del w if tablo.API.getUpdateStatus(): util.DEBUG_LOG('Updating ({0})'.format(tablo.API.device.name)) connected = None continue windows.WM.start() if windows.WM.exit: break connected = False bw.show() bw.setProperty('busy', '1') backgroundthread.BGThreader.shutdown() bw.doClose() del bw util.LOG('[- END -------------------------]')
def export(results=None,category=None): if exporting(): return util.setGlobalProperty('EXPORTING','true') util.setGlobalProperty('EXPORT_CANCELED','') try: _export(results,category) finally: util.setGlobalProperty('EXPORTING','') util.setGlobalProperty('EXPORT_CANCELED','')
def moveRule(self,move=False): if not move: if self.movingRule: util.setGlobalProperty('moving.rule','') if move is not None: self.updateRulePriority() self.movingRule = None elif move is not None: item = self.ruleList.getSelectedItem() if not item: return self.movingRule = item util.setGlobalProperty('moving.rule','1') else: if not self.movingRule: return pos = self.ruleList.getSelectedPosition() self.ruleList.moveItem(self.movingRule,pos)
def start(self): if not self.getLineUpAndGuide(): #If we fail to get lineUp, just exit self.doClose() return util.setGlobalProperty('DVR_ENABLED',self.hasDVR() and 'true' or '') self.fillChannelList() self.player = player.HDHRPlayer().init(self,self.devices,self.touchMode) if self.hasDVR() and util.getSetting('dvr.skip.livetv', False): return self.windowLoop() channel = self.getStartChannel() if not channel: xbmcgui.Dialog().ok(util.T(32018),util.T(32017),'',util.T(32012)) self.doClose() return if self.player.isPlayingHDHR(): self.fullscreenVideo() self.showProgress() if self.player.isPlayingRecording(): util.DEBUG_LOG('HDHR video already playing (recorded)') try: url = self.player.url rec = hdhr.storageservers.StorageServers(self.devices).getRecordingByPlayURL(url) self.setCurrent(rec=rec) except: util.ERROR() else: util.DEBUG_LOG('HDHR video already playing (live)') self.setCurrent(self.getListItemByChannel(channel)) else: util.DEBUG_LOG('HDHR video not currently playing. Starting channel...') self.playChannel(channel) self.selectChannel(channel) self.cron.registerReceiver(self) self.setFocusId(210) #Set focus now that dummy list is ready self.checkIfUpdated()
def openEpisodeDialog(self): item = self.showList.getSelectedItem() if not item: return path = skin.getSkinPath() groupID = item.dataSource and item.dataSource.displayGroupID or None d = EpisodesDialog(skin.DVR_EPISODES_DIALOG,path,'Main','1080i',group_id=groupID,storage_server=self.storageServer) d.doModal() self.play = d.play count = d.count del d if self.play: util.setGlobalProperty('window.animations','') self.doClose() else: if not count: if item.dataSource: # i.e. Not the all eps item self.showList.removeItem(item.pos()) else: item.setProperty('show.count', str(count))
def onAction(self,action): try: if action == xbmcgui.ACTION_PREVIOUS_MENU or action == xbmcgui.ACTION_NAV_BACK: util.setGlobalProperty('dvr.active','') self.moveRule(None) self.options = True #self.main.showOptions(from_dvr=True) self.doClose() elif self.mode == 'SEARCH': return self.onActionSearch(action) elif self.mode == 'WATCH': return self.onActionWatch(action) elif self.mode == 'RULES': return self.onActionRules(action) except: self._BASE.onAction(self,action) util.ERROR() return self._BASE.onAction(self,action)
def openDVRWindow(self): if not self.hasDVR(): return if (self.dvrWindow and self.dvrWindow.open) or (self.optionsDialog and self.optionsDialog.open): return if not self.dvrWindow: path = skin.getSkinPath() if util.getSetting('touch.mode',False): self.dvrWindow = dvr.DVRWindow(skin.DVR_WINDOW,path,'Main','1080i',main=self) else: self.dvrWindow = dvr.DVRDialog(skin.DVR_WINDOW,path,'Main','1080i',main=self) self.dvrWindow.modal() self.showProgress() #Hide the progress because of re-init triggering <onload> if self.dvrWindow.play: self.showOverlay(False) util.setGlobalProperty('window.animations',util.getSetting('window.animations',True) and '1' or '') if isinstance(self.dvrWindow.play, hdhr.storageservers.Recording): rec = self.dvrWindow.play self.playRecording(rec) util.setGlobalProperty('playing.dvr','1') else: self.playChannelByNumber(self.dvrWindow.play.channelNumber) self.dvrWindow.play = None return True return False
def cancel(): util.setGlobalProperty('EXPORT_CANCELED','true')
def setSearch(self,category=None): #self.searchTerms = self.getControl(self.SEARCH_EDIT_ID).getText() or '' if category: self.searchTerms = '' self.category = category catDisplay = {'series':'Shows','movie':'Movies','sport':'Sports','nowshowing':'Now Showing'} util.setGlobalProperty('search.terms',catDisplay[category]) if category == 'nowshowing': self.fillNowShowing() util.setGlobalProperty('movie.posters','') util.setGlobalProperty('now.showing','1') else: if self.nowShowing: self.nowShowing.pos = 0 util.setGlobalProperty('now.showing','') if category == 'movie': util.setGlobalProperty('movie.posters','1') else: util.setGlobalProperty('movie.posters','') self.fillSearchPanel() else: self.searchTerms = xbmcgui.Dialog().input(T(32812),self.searchTerms) if not self.searchTerms: return util.setGlobalProperty('now.showing','') util.setGlobalProperty('movie.posters','') self.category = '' util.setGlobalProperty('search.terms',self.searchTerms) self.fillSearchPanel() if util.getGlobalProperty('NO_RESULTS'): self.setFocusId(202) else: if category != 'nowshowing': if category == 'movie': self.setFocusId(self.MOVIE_PANEL_ID) else: self.setFocusId(self.SEARCH_PANEL_ID)
def fillNowShowing(self, next_section=False, prev_section=False, fix_selection=True, current=False): if not self.nowShowing: self.nowShowing = hdhr.guide.NowShowing(self.devices) if current: if self.nowShowing.pos > 0: self.nsPanel2 = bool(self.nowShowing.pos % 2) prev_section = True if next_section: self.nowShowing.pos += 1 try: searchResults, nextDisp, footerDisp = self.nowShowing.upNext() except hdhr.guide.EndOfNowShowingException: self.nowShowing.pos -= 1 if self.nsPanel2: self.setFocusId(self.NOW_SHOWING_PANEL1_ID) util.setGlobalProperty('ns.panel1.footer', 'END') else: self.setFocusId(self.NOW_SHOWING_PANEL2_ID) util.setGlobalProperty('ns.panel2.footer', 'END') self.nsPanel2 = not self.nsPanel2 return if self.nsPanel2: util.setGlobalProperty('ns.panel2.heading', nextDisp) util.setGlobalProperty('ns.panel2.footer', footerDisp) self.fillNSPanel2(searchResults) if fix_selection: off1 = self.nowShowingPanel1.getSelectedPosition() % 5 if self.nowShowingPanel2.positionIsValid(off1): self.nowShowingPanel2.selectItem(off1) self.setFocusId(self.NOW_SHOWING_PANEL2_ID) self.slideNSUp() else: util.setGlobalProperty('ns.panel1.heading', nextDisp) util.setGlobalProperty('ns.panel1.footer', footerDisp) self.fillNSPanel1(searchResults) if fix_selection: off2 = self.nowShowingPanel2.getSelectedPosition() % 5 if self.nowShowingPanel1.positionIsValid(off2): self.nowShowingPanel1.selectItem(off2) self.setFocusId(self.NOW_SHOWING_PANEL1_ID) self.slideNSUp() elif prev_section: searchResults, prevDisp, footerDisp = self.nowShowing.upNext() if self.nsPanel2: util.setGlobalProperty('ns.panel2.heading', prevDisp) util.setGlobalProperty('ns.panel2.footer', footerDisp) self.fillNSPanel2(searchResults) if fix_selection: off1 = (self.nowShowingPanel1.getSelectedPosition() + 1) % 5 off2 = self.nowShowingPanel2.size() % 5 if off1 < off2: self.nowShowingPanel2.selectItem((self.nowShowingPanel2.size() - 1) - (off2 - off1)) elif off2 < off1: self.nowShowingPanel2.selectItem((self.nowShowingPanel2.size() - 6) + (off1 - off2)) else: self.nowShowingPanel2.selectItem((self.nowShowingPanel2.size() - 1)) self.setFocusId(self.NOW_SHOWING_PANEL2_ID) self.slideNSDown() else: util.setGlobalProperty('ns.panel1.heading', prevDisp) util.setGlobalProperty('ns.panel1.footer', footerDisp) self.fillNSPanel1(searchResults) if fix_selection: off1 = self.nowShowingPanel1.size() % 5 off2 = (self.nowShowingPanel2.getSelectedPosition() + 1) % 5 if off2 < off1: self.nowShowingPanel1.selectItem((self.nowShowingPanel1.size() - 1) - (off1 - off2)) elif off1 < off2: self.nowShowingPanel1.selectItem((self.nowShowingPanel1.size() - 6) + (off2 - off1)) else: self.nowShowingPanel1.selectItem((self.nowShowingPanel1.size() - 1)) self.setFocusId(self.NOW_SHOWING_PANEL1_ID) self.slideNSDown() else: self.nowShowing.pos = 0 searchResults, nowDisp, nextDisp = self.nowShowing.nowShowing() util.setGlobalProperty('ns.panel1.heading', 'NOW SHOWING') self.nsPanel2 = False util.setGlobalProperty('ns.panel2.heading', nextDisp) util.setGlobalProperty('ns.panel1.footer', nextDisp) self.fillNSPanel1(searchResults) self.slideNSUp(1) self.setFocusId(self.NOW_SHOWING_PANEL1_ID) util.setGlobalProperty('NO_RESULTS',not searchResults and T(32802) or '')
def start(): util.LOG('Version: {0}'.format(util.ADDON.getAddonInfo('version'))) util.DEBUG_LOG('Current Kodi skin: {0}'.format(skin.currentKodiSkin())) util.setGlobalProperty('guide.full.detail',util.getSetting('guide.full.detail',False) and 'true' or '') util.setGlobalProperty('DVR_ENABLED','') util.setGlobalProperty('busy','') util.setGlobalProperty('window.animations',util.getSetting('window.animations',True) and '1' or '') util.setGlobalProperty('search.terms','') path = skin.getSkinPath() back = BackgroundWindow('script-hdhomerun-view-background.xml',path,'Main','1080i') back.show() if util.getSetting('touch.mode',False): util.setGlobalProperty('touch.mode','true') window = GuideOverlayWindow(skin.OVERLAY,path,'Main','1080i') window.touchMode = True else: #player.FullsceenVideoInitializer().start() util.setGlobalProperty('touch.mode','') window = GuideOverlayDialog(skin.OVERLAY,path,'Main','1080i') with util.Cron(5) as window.cron: window.doModal() window.shutdown() window.abort = True del window threads = threading.enumerate() while len(threads) > 1: util.DEBUG_LOG('Waiting on {0} threads...'.format(len(threads) - 1)) threads = threading.enumerate() for t in threads: if t != threading.currentThread(): t.join() break back.doClose() del back util.DEBUG_LOG('Finished')
def mode(self,val): if util.getGlobalProperty('DVR_MODE') == 'RULES' and val != 'RULES': self.moveRule(None) util.setGlobalProperty('DVR_MODE',val)
def onPlayBackEnded(self): util.setGlobalProperty('playing.dvr','') self.setCurrent() util.DEBUG_LOG('ON PLAYBACK ENDED') self.windowLoop()