def onInit(self): self.getControl(32502).setLabel(translate(32008)) self.setProperty("screensaver-atv4-loading", "1") if self.videoplaylist: self.clearProperty("screensaver-atv4-loading") self.atv4player = atvplayer.ATVPlayer() self.atv4player.play(self.videoplaylist, windowed=True) # DPMS logic self.max_allowed_time = None if self.isDPMSactive and addon.getSetting("check-dpms") == "1": self.max_allowed_time = self.DPMStime elif addon.getSetting("check-dpms") == "2": self.max_allowed_time = int( addon.getSetting("manual-dpms")) * 60 xbmc.log(msg="check dpms:" + str(addon.getSetting("check-dpms")), level=xbmc.LOGDEBUG) xbmc.log(msg="before supervision:" + str(self.max_allowed_time), level=xbmc.LOGDEBUG) if self.max_allowed_time: delta = 0 while self.active: if delta >= self.max_allowed_time: self.activateDPMS() break xbmc.sleep(1000) delta += 1 else: self.novideos()
def activateDPMS(self): xbmc.log(msg="[Aerial Screensaver] Manually activating DPMS!", level=xbmc.LOGDEBUG) self.active = False #take action on the video enable_window_placeholder = False if addon.getSetting("dpms-action") == "0": self.atv4player.pause() else: self.clearAll() enable_window_placeholder = True if addon.getSetting("toggle-displayoff") == "true" or addon.getSetting( "toggle-cecoff") == "true": xbmc.sleep(1000) if addon.getSetting("toggle-displayoff") == "true": try: xbmc.executebuiltin('ToggleDPMS') except Exception, e: xbmc.log(msg="[Aerial Screensaver] Failed to toggle DPMS: %s" % (str(e)), level=xbmc.LOGDEBUG)
def run(): if not xbmc.getCondVisibility("Player.HasMedia"): if addon.getSetting("is_locked") == "false": if addon.getSetting("show-notifications") == "true": notification(translate(32000), translate(32017)) if addon.getSetting("show-previewwindow") == "true": #Start window screensaver = ScreensaverPreview( 'screensaver-atv4.xml', addon_path, 'default', '', ) screensaver.doModal() xbmc.sleep(100) del screensaver else: monitor = ScreensaverPreview.ExitMonitor( ScreensaverPreview.runAddon()) ScreensaverPreview.send_input() else: #Transparent placeholder trans = ScreensaverTrans( 'screensaver-atv4-trans.xml', addon_path, 'default', '', ) trans.doModal() xbmc.sleep(100) del trans else: # Just call deactivate ScreensaverPreview.send_input()
class Screensaver(xbmcgui.WindowXML): def __init__(self, *args, **kwargs): self.DPMStime = json.loads( xbmc.executeJSONRPC( '{"jsonrpc":"2.0","method":"Settings.GetSettingValue","params":{"setting":"powermanagement.displaysoff"},"id":2}' ))['result']['value'] * 60 self.isDPMSactive = bool(self.DPMStime > 0) self.active = True atvPlaylist = playlist.AtvPlaylist() self.videoplaylist = atvPlaylist.getPlaylist() xbmc.log(msg="kodi dpms time:" + str(self.DPMStime), level=xbmc.LOGDEBUG) xbmc.log(msg="kodi dpms active:" + str(self.isDPMSactive), level=xbmc.LOGDEBUG) def onInit(self): self.getControl(32502).setLabel(translate(32008)) self.setProperty("screensaver-atv4-loading", "1") if self.videoplaylist: self.clearProperty("screensaver-atv4-loading") self.atv4player = atvplayer.ATVPlayer() self.atv4player.play(self.videoplaylist, windowed=True) # DPMS logic self.max_allowed_time = None if self.isDPMSactive and addon.getSetting("check-dpms") == "1": self.max_allowed_time = self.DPMStime elif addon.getSetting("check-dpms") == "2": self.max_allowed_time = int( addon.getSetting("manual-dpms")) * 60 xbmc.log(msg="check dpms:" + str(addon.getSetting("check-dpms")), level=xbmc.LOGDEBUG) xbmc.log(msg="before supervision:" + str(self.max_allowed_time), level=xbmc.LOGDEBUG) if self.max_allowed_time: delta = 0 while self.active: if delta >= self.max_allowed_time: self.activateDPMS() break xbmc.sleep(1000) delta += 1 else: self.novideos() def activateDPMS(self): xbmc.log(msg="[Aerial Screensaver] Manually activating DPMS!", level=xbmc.LOGDEBUG) self.active = False #take action on the video enable_window_placeholder = False if addon.getSetting("dpms-action") == "0": self.atv4player.pause() else: self.clearAll() enable_window_placeholder = True if addon.getSetting("toggle-displayoff") == "true" or addon.getSetting( "toggle-cecoff") == "true": xbmc.sleep(1000) if addon.getSetting("toggle-displayoff") == "true": try: xbmc.executebuiltin('ToggleDPMS') except Exception, e: xbmc.log(msg="[Aerial Screensaver] Failed to toggle DPMS: %s" % (str(e)), level=xbmc.LOGDEBUG) if addon.getSetting("toggle-cecoff") == "true": try: xbmc.executebuiltin('CECStandby') except Exception, e: xbmc.log( msg= "[Aerial Screensaver] Failed to toggle device off via CEC: %s" % (str(e)), level=xbmc.LOGDEBUG)
def getPlaylist(self, ): current_time = xbmc.getInfoLabel("System.Time") am_pm = xbmc.getInfoLabel("System.Time(xx)") current_hour = current_time.split(":")[0] if am_pm == "PM": if int(current_hour) < 12: current_hour = int(current_hour) + 12 else: current_hour = int(current_hour) else: current_hour = int(current_hour) day_night = '' if current_hour < 19: if current_hour > 7: day_night = 'day' else: day_night = 'night' if current_hour > 19: day_night = 'night' self.playlist = xbmc.PlayList(1) self.playlist.clear() if self.html: for block in self.html: for video in block['assets']: label = video['accessibilityLabel'] + ' by ' + str( video['timeOfDay']) item = xbmcgui.ListItem(label) item.setLabel(label) item.setInfo('video', {'Title': label}) item.setArt( {'thumb': os.path.join(addon_path, 'icon.png')}) url = video['url'] item.setPath(url) # check if file exists on disk movie = url.split("/")[-1] localfilemov = os.path.join( addon.getSetting("download-folder"), movie) if xbmcvfs.exists(localfilemov): url = localfilemov # check for existence of the trancoded file .mp4 only localfilemp4 = os.path.join( addon.getSetting("download-folder"), movie.replace('.mov', '.mp4')) if xbmcvfs.exists(localfilemp4): url = localfilemp4 # build setting thisvideosetting = "enable-" + video[ 'accessibilityLabel'].lower().replace(" ", "") if addon.getSetting(thisvideosetting) == "true": if video['timeOfDay'] == 'day': if addon.getSetting( "time-of-day") == '0' or addon.getSetting( "time-of-day") == '1': self.playlist.add(url, item) if addon.getSetting("time-of-day") == '3': if day_night == 'day': self.playlist.add(url, item) if video['timeOfDay'] == 'night': if addon.getSetting( "time-of-day") == '0' or addon.getSetting( "time-of-day") == '2': self.playlist.add(url, item) if addon.getSetting("time-of-day") == '3': if day_night == 'night': self.playlist.add(url, item) self.playlist.shuffle() return self.playlist else: return None