def __init__(self, addon_id, sys_argv=''): #Check if a path has been set in the addon settings if common.db_path: self.path = xbmc.translatePath(common.db_path) else: self.path = xbmc.translatePath(common.default_path) self.addon_id = addon_id self.sys_argv = sys_argv self.cache_path = common.make_dir(self.path, '') self.addon = Addon(self.addon_id, self.sys_argv) self.db = os.path.join(self.cache_path, self.local_db_name) # connect to db at class init and use it globally if DB == 'mysql': class MySQLCursorDict(database.cursor.MySQLCursor): def _row_to_python(self, rowdata, desc=None): row = super(MySQLCursorDict, self)._row_to_python(rowdata, desc) if row: return dict(zip(self.column_names, row)) return None self.dbcon = database.connect(common.db_name, common.db_user, common.db_pass, common.db_address, buffered=True, charset='utf8') self.dbcur = self.dbcon.cursor(cursor_class=MySQLCursorDict, buffered=True) else: self.dbcon = database.connect(self.db) self.dbcon.row_factory = database.Row # return results indexed by field names and not numbers so we can convert to dict self.dbcon.text_factory = str self.dbcur = self.dbcon.cursor() self._create_favorites_tables()
def __init__(self, *args, **kwargs): #Check if a path has been set in the addon settings if common.db_path: self.path = xbmc.translatePath(common.db_path) else: self.path = xbmc.translatePath(common.default_path) print common.db_path xbmc.Player.__init__(self, *args, **kwargs) self.set(*args, **kwargs) self._playbackLock = threading.Event() self._playbackLock.set() self._totalTime = 999999 self._lastPos = 0 self._sought = False self.cache_path = common.make_dir(self.path, '') self.db = os.path.join(self.cache_path, self.local_db_name) self._create_playbackengine_tables() common.addon.log('-' + HELPER + '- -' +'Created player', 2)