def isMusicVideoTitles(currentPath=None): folderPathId = "videodb://3/2/" # The ID for the TV Show Title changed in Gotham if Settings.getXbmcMajorVersion() > 12: folderPathId = "videodb://musicvideos/" if currentPath is None: return xbmc.getInfoLabel("container.folderpath") == folderPathId else: return currentPath == folderPathId
def isTv(): if xbmc.getCondVisibility("Container.Content(tvshows)"): return True if xbmc.getCondVisibility("Container.Content(Seasons)"): return True if xbmc.getCondVisibility("Container.Content(Episodes)"): return True folderPathId = "videodb://2/2/" # The ID for the TV Show Title changed in Gotham if Settings.getXbmcMajorVersion() > 12: folderPathId = "videodb://tvshows/titles/" if xbmc.getInfoLabel("container.folderpath") == folderPathId: return True # TvShowTitles return False
# no params passed params = {} log("params %s" % params) if params.get("backend", False): xbmc.executebuiltin('XBMC.RunScript(%s)' % (os.path.join(__resource__, "tvtunes_backend.py"))) elif params.get("mode", False) == "solo": xbmc.executebuiltin('XBMC.RunScript(%s)' % (os.path.join(__resource__, "tvtunes_scraper.py"))) else: # Close any open dialogs xbmc.executebuiltin("Dialog.Close(all, true)", True) if Settings.getXbmcMajorVersion() > 12: log("TvTunes: Running as Addon/Plugin") xbmc.executebuiltin("RunAddon(script.tvtunes)") else: log("TvTunes: Navigating to Plugin") # Default to the plugin method xbmc.executebuiltin("xbmc.ActivateWindow(Video, addons://sources/video/)", True) # It is a bit hacky, but the only way I can get it to work # After loading the plugin screen, navigate to the TvTunes entry and select it maxChecks = 100 selectedTitle = None while selectedTitle != 'TvTunes' and maxChecks > 0: maxChecks = maxChecks - 1 json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Input.Up", "params": { }, "id": 1}') json_query = unicode(json_query, 'utf-8', errors='ignore')
def run(self): try: # Before we actually start playing something, make sure it is OK # to run, need to ensure there are not multiple copies running if not TvTunesStatus.isOkToRun(): return while (not self._stop): # Check the forced TV Tunes status at the start of the loop, if this is True # then we don't want to stop themes until the next iteration, this stops the case # where some checks are done and the value changes part was through a single # loop iteration isForcedTvTunesContinue = WindowShowing.isTvTunesOverrideContinuePlaying() # If shutdown is in progress, stop quickly (no fade out) if WindowShowing.isShutdownMenu() or xbmc.abortRequested: self.stop() break # We only stop looping and exit this script if we leave the Video library # We get called when we enter the library, and the only times we will end # will be if: # 1) A Video is selected to play # 2) We exit to the main menu away from the video view if (not WindowShowing.isVideoLibrary()) or WindowShowing.isScreensaver() or Settings.isTimout(): log("TunesBackend: Video Library no longer visible") # End playing cleanly (including any fade out) and then stop everything if TvTunesStatus.isAlive(): self.themePlayer.endPlaying() self.stop() # It may be possible that we stopped for the screen-saver about to kick in # If we are using Gotham or higher, it is possible for us to re-kick off the # screen-saver, otherwise the action of us stopping the theme will reset the # timeout and the user will have to wait longer if Settings.isTimout() and (Settings.getXbmcMajorVersion() > 12): xbmc.executebuiltin("xbmc.ActivateScreensaver", True) break # There is a valid page selected and there is currently nothing playing if self.isPlayingZone() and not WindowShowing.isTvTunesOverrideContinuePrevious(): newThemes = self.getThemes() if self.newThemeFiles != newThemes: self.newThemeFiles = newThemes # Check if the file path has changed, if so there is a new file to play if self.newThemeFiles != self.oldThemeFiles and self.newThemeFiles.hasThemes(): log("TunesBackend: old path: %s" % self.oldThemeFiles.getPath()) log("TunesBackend: new path: %s" % self.newThemeFiles.getPath()) if self.start_playing(): self.oldThemeFiles = self.newThemeFiles # There is no theme at this location, so make sure we are stopped if not self.newThemeFiles.hasThemes() and self.themePlayer.isPlayingAudio() and TvTunesStatus.isAlive(): self.themePlayer.endPlaying() self.oldThemeFiles.clear() self.prevThemeFiles.clear() self.delayedStart.clear() TvTunesStatus.setAliveState(False) # This will occur when a theme has stopped playing, maybe is is not set to loop if TvTunesStatus.isAlive() and not self.themePlayer.isPlayingAudio(): log("TunesBackend: playing ends") self.themePlayer.restoreSettings() TvTunesStatus.setAliveState(False) # This is the case where the user has moved from within an area where the themes # to an area where the theme is no longer played, so it will trigger a stop and # reset everything to highlight that nothing is playing # Note: TvTunes is still running in this case, just not playing a theme if (not self.isPlayingZone()) and (not isForcedTvTunesContinue): self.newThemeFiles.clear() self.oldThemeFiles.clear() self.prevThemeFiles.clear() self.delayedStart.clear() if self.themePlayer.isPlaying() and TvTunesStatus.isAlive(): log("TunesBackend: end playing") self.themePlayer.endPlaying() TvTunesStatus.setAliveState(False) self.themePlayer.checkEnding() # Wait a little before starting the check again xbmc.sleep(200) except: log("TunesBackend: %s" % traceback.format_exc()) self.stop()
def isMovieSet(): folderPathId = "videodb://1/7/" # The ID for the TV Show Title changed in Gotham if Settings.getXbmcMajorVersion() > 12: folderPathId = "videodb://movies/sets/" return xbmc.getCondVisibility("!IsEmpty(ListItem.DBID) + SubString(ListItem.Path," + folderPathId + ",left)")
def isRecentEpisodesAdded(): folderPathId = "videodb://5/" # The ID for the Recent Episodes changed in Gotham if Settings.getXbmcMajorVersion() > 12: folderPathId = "videodb://recentlyaddedepisodes/" return xbmc.getInfoLabel("container.folderpath") == folderPathId