def _check_database_version(self): # If we are updating from a database prior to database versioning, we must clear the meta data # Migrate from older versions before trakt username tracking if 'trakt_username' not in self.activites and tools.getSetting( 'trakt.auth') != '': tools.log( 'Upgrading Trakt Sync Database Version to support Trakt username identification' ) cursor = self._get_cursor() cursor.execute( 'ALTER TABLE activities ADD COLUMN trakt_username TEXT') cursor.execute('UPDATE activities SET trakt_username = ?', (tools.getSetting('trakt.username'), )) cursor.connection.commit() cursor.close() # Migrate from an old version before database migrations if 'seren_version' not in self.activites: tools.log('Upgrading Trakt Sync Database Version') self.clear_all_meta(False) cursor = self._get_cursor() cursor.execute( 'ALTER TABLE activities ADD COLUMN seren_version TEXT') cursor.execute('UPDATE activities SET seren_version = ?', (self.last_meta_update, )) cursor.connection.commit() cursor.close() if tools.check_version_numbers(self.activites['seren_version'], self.last_meta_update): tools.log('Upgrading Trakt Sync Database Version') self.clear_all_meta(False) cursor = self._get_cursor() cursor.execute('UPDATE activities SET seren_version=?', (self.last_meta_update, )) cursor.connection.commit() cursor.close() return if tools.check_version_numbers(tools.addonVersion, self.activites['seren_version']) and \ self.activites['seren_version'] != self.last_meta_update: tools.log('Downgrading Trakt Sync Database Version') self.clear_all_meta(False) cursor = self._get_cursor() cursor.execute('UPDATE activities SET seren_version=?', (self.last_meta_update, )) cursor.connection.commit() cursor.close() return
def check_for_addon_update(): try: if tools.getSetting('general.checkAddonUpdates') == 'false': return update_timestamp = float( tools.getSetting('addon.updateCheckTimeStamp')) if time.time() > (update_timestamp + (24 * (60 * 60))): repo_xml = requests.get( 'https://raw.githubusercontent.com/nixgates/nixgates/master/packages/addons.xml' ) if not repo_xml.status_code == 200: tools.log( 'Could not connect to repo XML, status: %s' % repo_xml.status_code, 'error') return repo_version = re.findall( r'<addon id=\"plugin.video.seren\" version=\"(\d*.\d*.\d*)\"', repo_xml.text)[0] local_verison = tools.addonVersion if tools.check_version_numbers(local_verison, repo_version): tools.showDialog.ok(tools.addonName, tools.lang(40136) % repo_version) tools.setSetting('addon.updateCheckTimeStamp', str(time.time())) except: pass
def _check_skin_for_update(self, skin_info): try: remote_meta = requests.get(skin_info['remote_meta']).json() return tools.check_version_numbers(skin_info['version'], remote_meta['version']) except: tools.log('Failed to obtain remote meta information for skin: {}'.format(skin_info['skin_name'])) return False
def _check_database_version(self): # If we are updating from a database prior to database versioning, we must clear the meta data if 'seren_version' not in self.activites: tools.log('Upgrading Trakt Sync Database Version') self.clear_all_meta(False) cursor = self._get_cursor() cursor.execute('ALTER TABLE activities ADD COLUMN seren_version TEXT') cursor.execute('UPDATE activities SET seren_version = ?', (tools.addonVersion,)) cursor.connection.commit() cursor.close() return # If you make changes to the required meta in any indexer that is cached in this database # You will need to update the below version number to match the new addon version # This will ensure that the metadata required for operations is available last_meta_update = '0.2.19' if self.activites.get('seren_version', None) is None: self.activites['seren_version'] == '0.0.0' if tools.check_version_numbers(self.activites['seren_version'], last_meta_update): tools.log('Upgrading Trakt Sync Database Version') self.clear_all_meta(False) cursor = self._get_cursor() cursor.execute('UPDATE activities SET seren_version=?', (tools.addonVersion,)) cursor.connection.commit() cursor.close() return if tools.check_version_numbers(tools.addonVersion, self.activites['seren_version']): tools.log('Downgrading Trakt Sync Database Version') self.clear_all_meta(False) cursor = self._get_cursor() cursor.execute('UPDATE activities SET seren_version=?', (tools.addonVersion,)) cursor.connection.commit() cursor.close() return
def check_version_numbers(self, current, new): return tools.check_version_numbers(current, new)
def _check_database_version(self): # If we are updating from a database prior to database versioning, we must clear the meta data # Migrate from older versions before trakt username tracking if 'trakt_username' not in self.activites and tools.getSetting( 'trakt.auth') != '': tools.traktSyncDB_lock.acquire() tools.log( 'Upgrading Trakt Sync Database Version to support Trakt username identification' ) cursor = self._get_cursor() cursor.execute( 'ALTER TABLE activities ADD COLUMN trakt_username TEXT') cursor.execute('UPDATE activities SET trakt_username = ?', (tools.getSetting('trakt.username'), )) cursor.connection.commit() cursor.close() tools.try_release_lock(tools.traktSyncDB_lock) # Migrate from an old version before database migrations if 'seren_version' not in self.activites: tools.log('Upgrading Trakt Sync Database Version') self.clear_all_meta(False) tools.traktSyncDB_lock.acquire() cursor = self._get_cursor() cursor.execute( 'ALTER TABLE activities ADD COLUMN seren_version TEXT') cursor.execute('UPDATE activities SET seren_version = ?', (self.last_meta_update, )) cursor.connection.commit() cursor.close() tools.try_release_lock(tools.traktSyncDB_lock) if tools.check_version_numbers(self.activites['seren_version'], self.last_meta_update): tools.log('Rebuilding Trakt Sync Database Version') self.re_build_database(True) return if 'movies_bookmarked' not in self.activites: tools.log( 'Upgrading Trakt Sync Database Version to support bookmark sync' ) tools.traktSyncDB_lock.acquire() cursor = self._get_cursor() cursor.execute( 'ALTER TABLE activities ADD COLUMN movies_bookmarked TEXT') cursor.execute( 'ALTER TABLE activities ADD COLUMN episodes_bookmarked TEXT') cursor.connection.commit() cursor.execute('UPDATE activities SET movies_bookmarked = ?', (self.base_date, )) cursor.execute('UPDATE activities SET episodes_bookmarked = ?', (self.base_date, )) cursor.connection.commit() cursor.close() tools.try_release_lock(tools.traktSyncDB_lock) tools.traktSyncDB_lock.acquire() cursor = self._get_cursor() cursor.execute( 'SELECT 1 FROM sqlite_master WHERE type = \'table\' AND name = \'shows\' AND sql LIKE ' '\'%air_date%\'') if len(cursor.fetchall()) == 0: cursor.execute('ALTER TABLE shows ADD COLUMN air_date DATE') cursor.connection.commit() cursor.execute( 'SELECT 1 FROM sqlite_master WHERE type = \'table\' AND name = \'episodes\' AND sql LIKE ' '\'%air_date%\'') if len(cursor.fetchall()) == 0: cursor.execute('ALTER TABLE episodes ADD COLUMN air_date DATE') cursor.connection.commit() cursor.execute( 'SELECT 1 FROM sqlite_master WHERE type = \'table\' AND name = \'seasons\' AND sql LIKE ' '\'%air_date%\'') if len(cursor.fetchall()) == 0: cursor.execute('ALTER TABLE seasons ADD COLUMN air_date DATE') cursor.connection.commit() cursor.execute( 'SELECT 1 FROM sqlite_master WHERE type = \'table\' AND name = \'movies\' AND sql LIKE ' '\'%air_date%\'') if len(cursor.fetchall()) == 0: cursor.execute('ALTER TABLE movies ADD COLUMN air_date DATE') cursor.connection.commit() cursor.execute( 'SELECT 1 FROM sqlite_master WHERE type = \'table\' AND name = \'lists\' AND sql LIKE ' '\'%slug TEXT NOT NULL)\'') if len(cursor.fetchall()) > 0: cursor.execute('ALTER TABLE lists RENAME TO lists_old') cursor.execute('CREATE TABLE IF NOT EXISTS lists (' 'trakt_id INTEGER NOT NULL, ' 'media_type TEXT NOT NULL,' 'name TEXT NOT NULL, ' 'username TEXT NOT NULL, ' 'kodi_meta TEXT NOT NULL, ' 'updated_at TEXT NOT NULL,' 'list_type TEXT NOT NULL,' 'item_count INT NOT NULL,' 'sort_by TEXT NOT NULL,' 'sort_how TEXT NOT NULL,' 'slug TEXT NOT NULL,' 'PRIMARY KEY (trakt_id, media_type)) ') cursor.execute('insert into lists select * from lists_old') cursor.execute('DROP TABLE IF EXISTS lists_old') cursor.connection.commit() tools.try_release_lock(tools.traktSyncDB_lock) if 'movies_bookmarked' not in self.activites: tools.log( 'Upgrading Trakt Sync Database Version to support bookmark sync' ) cursor = self._get_cursor() cursor.execute( 'ALTER TABLE activities ADD COLUMN movies_bookmarked TEXT') cursor.execute( 'ALTER TABLE activities ADD COLUMN episodes_bookmarked TEXT') cursor.connection.commit() cursor.execute('UPDATE activities SET movies_bookmarked = ?', (self.base_date, )) cursor.execute('UPDATE activities SET episodes_bookmarked = ?', (self.base_date, )) cursor.connection.commit() cursor.close()