def __init__(self, name=None, addon_id=None, filepath=None, info_type=None): self._name = name self._routes = [] self._view_functions = {} # addon_id is no longer required as it can be parsed from addon.xml if addon_id: self._addon = xbmcaddon.Addon(id=addon_id) else: self._addon = xbmcaddon.Addon() self._addon_id = addon_id or self._addon.getAddonInfo('id') self._name = name or self._addon.getAddonInfo('name') self._info_type = info_type if not self._info_type: types = { 'video': 'video', 'audio': 'music', 'image': 'pictures', } self._info_type = types.get(self._addon_id.split('.')[1], 'video') # Keeps track of the added list items self._current_items = [] # Gets initialized when self.run() is called self._request = None # A flag to keep track of a call to xbmcplugin.endOfDirectory() self._end_of_directory = False # Keep track of the update_listing flag passed to # xbmcplugin.endOfDirectory() self._update_listing = False # The plugin's named logger self._log = setup_log(self._addon_id) # The path to the storage directory for the addon self._storage_path = xbmc.translatePath( 'special://profile/addon_data/%s/.storage/' % self._addon_id) if not os.path.isdir(self._storage_path): os.makedirs(self._storage_path) print self._storage_path # If we are runing in CLI, we need to load the strings.xml manually # Since resources.lib.xbmcswift2b currently relies on execution from an addon's root # directly, we can rely on cwd for now... if resources.lib.xbmcswift2b.CLI_MODE: from resources.lib.xbmcswift2b.mockxbmc import utils if filepath: addon_dir = os.path.dirname(filepath) else: addon_dir = os.getcwd() strings_fn = os.path.join(addon_dir, 'resources', 'language', 'English', 'strings.xml') utils.load_addon_strings(self._addon, strings_fn)
def temp_fn(self, path): return os.path.join(xbmc.translatePath('special://temp/'), path)