def GetDefaultCachePath(self): """ returns the default cache path for this channel""" # set the UZG path if AddonSettings.GetUzgCacheDuration() > 0: cachPath = AddonSettings.GetUzgCachePath() if cachPath: Logger.Trace("UZG Cache path resolved to: %s", cachPath) return cachPath cachePath = chn_class.Channel.GetDefaultCachePath(self) Logger.Trace("UZG Cache path resolved chn_class default: %s", cachePath) return cachePath
def __init__(self, pluginName, params, handle=0): """Initialises the plugin with given arguments.""" # some constants self.actionDownloadVideo = "downloadVideo".lower() # : Action used to download a video item self.actionFavourites = "favourites".lower() # : Action used to show favorites for a channel self.actionAllFavourites = "allfavourites".lower() # : Action used to show all favorites self.actionRemoveFavourite = "removefromfavourites".lower() # : Action used to remove items from favorites self.actionAddFavourite = "addtofavourites".lower() # : Action used to add items to favorites self.actionPlayVideo = "playvideo".lower() # : Action used to play a video item self.actionUpdateChannels = "updatechannels".lower() # : Action used to update channels self.actionListFolder = "listfolder".lower() # : Action used to list a folder self.actionListCategory = "listcategory" # : Action used to show the channels from a category self.actionConfigureChannel = "configurechannel" # : Action used to configure a channel self.keywordPickle = "pickle".lower() # : Keyword used for the pickle item self.keywordAction = "action".lower() # : Keyword used for the action item self.keywordChannel = "channel".lower() # : Keyword used for the channel self.keywordChannelCode = "channelcode".lower() # : Keyword used for the channelcode self.keywordCategory = "category" # : Keyword used for the category self.keywordRandomLive = "rnd" # : Keyword used for randomizing live items self.pluginName = pluginName self.handle = int(handle) # channel objects self.channelObject = None self.channelFile = "" self.channelCode = None self.contentType = "episodes" self.methodContainer = dict() # : storage for the inspect.getmembers(channel) method. Improves performance # determine the query parameters self.params = self.__GetParameters(params) Logger.Info("*********** Starting %s add-on version %s ***********", Config.appName, Config.version) Logger.Debug("Plugin Params: %s (%s) [handle=%s, name=%s, query=%s]", self.params, len(self.params), self.handle, self.pluginName, params) # are we in session? sessionActive = SessionHelper.IsSessionActive(Logger.Instance()) # fetch some environment settings envCtrl = envcontroller.EnvController(Logger.Instance()) # self.FavouritesEnabled = envCtrl.SQLiteEnabled() self.FavouritesEnabled = not envCtrl.IsPlatform(Environments.Xbox) if not sessionActive: # do add-on start stuff Logger.Info("Add-On start detected. Performing startup actions.") # print the folder structure envCtrl.DirectoryPrinter(Config, AddonSettings) # show notification XbmcWrapper.ShowNotification(None, LanguageHelper.GetLocalizedString(LanguageHelper.StartingAddonId) % ( Config.appName,), fallback=False, logger=Logger) # check for updates if envCtrl.IsPlatform(Environments.Xbox): Updater().AutoUpdate() # check if the repository is available envCtrl.IsInstallMethodValid(Config) # check for cache folder envCtrl.CacheCheck() # do some cache cleanup envCtrl.CacheCleanUp(Config.cacheDir, Config.cacheValidTime) envCtrl.CacheCleanUp(AddonSettings.GetUzgCachePath(), AddonSettings.GetUzgCacheDuration() * 24 * 3600, "xot.*") # create a session SessionHelper.CreateSession(Logger.Instance()) #=============================================================================== # Start the plugin version of progwindow #=============================================================================== if len(self.params) == 0: # Show initial start if not in a session # now show the list if AddonSettings.ShowCategories(): self.ShowCategories() else: self.ShowChannelList() #=============================================================================== # Start the plugin verion of the episode window #=============================================================================== else: try: # Determine what stage we are in. Check that there are more than 2 Parameters if len(self.params) > 1 and self.keywordChannel in self.params: # retrieve channel characteristics self.channelFile = os.path.splitext(self.params[self.keywordChannel])[0] self.channelCode = self.params[self.keywordChannelCode] Logger.Debug("Found Channel data in URL: channel='%s', code='%s'", self.channelFile, self.channelCode) # import the channel channelRegister = ChannelImporter.GetRegister() channel = channelRegister.GetSingleChannel(self.channelFile, self.channelCode) if channel is not None: self.channelObject = channel else: Logger.Critical("None or more than one channels were found, unable to continue.") return # init the channel as plugin self.channelObject.InitChannel() Logger.Info("Loaded: %s", self.channelObject.channelName) elif self.keywordCategory in self.params: # no channel needed. pass elif self.keywordAction in self.params and ( self.params[self.keywordAction] == self.actionAllFavourites or self.params[self.keywordAction] == self.actionRemoveFavourite): # no channel needed for these favourites actions. pass else: Logger.Critical("Error determining Plugin action") return #=============================================================================== # See what needs to be done. #=============================================================================== if self.keywordAction not in self.params: Logger.Critical("Action parameters missing from request. Parameters=%s", self.params) return if self.params[self.keywordAction] == self.actionListCategory: self.ShowChannelList(self.params[self.keywordCategory]) elif self.params[self.keywordAction] == self.actionConfigureChannel: self.__ConfigureChannel(self.channelObject) elif self.params[self.keywordAction] == self.actionFavourites: # we should show the favourites self.ShowFavourites(self.channelObject) elif self.params[self.keywordAction] == self.actionAllFavourites: if self.channelObject is not None: Logger.Warning("We have a self.channelObject with self.actionAllFavourites") self.ShowFavourites(None) elif self.params[self.keywordAction] == self.actionRemoveFavourite: self.RemoveFavourite() elif self.params[self.keywordAction] == self.actionAddFavourite: self.AddFavourite() elif self.params[self.keywordAction] == self.actionListFolder: # channelName and URL is present, Parse the folder self.ProcessFolderList() elif self.params[self.keywordAction] == self.actionPlayVideo: self.PlayVideoItem() elif not self.params[self.keywordAction] == "": self.OnActionFromContextMenu(self.params[self.keywordAction]) else: Logger.Warning("Number of parameters (%s) or parameter (%s) values not implemented", len(self.params), self.params) except: Logger.Critical("Error parsing for add-on", exc_info=True) self.__FetchTextures() return