From 3825072c5edc7c2273f41b4ae44f98d29cc92aa7 Mon Sep 17 00:00:00 2001 From: croneter Date: Mon, 11 Jan 2021 16:21:37 +0100 Subject: [PATCH] Alter Plex DB table movie on PKC update to sync TMDB trailers --- resources/lib/migration.py | 77 +++----------------------------------- 1 file changed, 5 insertions(+), 72 deletions(-) diff --git a/resources/lib/migration.py b/resources/lib/migration.py index bbc0411f..2e5ecf69 100644 --- a/resources/lib/migration.py +++ b/resources/lib/migration.py @@ -22,80 +22,13 @@ def check_migration(): LOG.info('Already migrated to PKC version %s' % v.ADDON_VERSION) return - if not utils.compare_version(last_migration, '1.8.2'): - LOG.info('Migrating to version 1.8.1') - # Set the new PKC theMovieDB key - utils.settings('themoviedbAPIKey', - value='19c90103adb9e98f2172c6a6a3d85dc4') - - if not utils.compare_version(last_migration, '2.0.25'): - LOG.info('Migrating to version 2.0.24') - # Need to re-connect with PMS to pick up on plex.direct URIs - utils.settings('ipaddress', value='') - utils.settings('port', value='') - - if not utils.compare_version(last_migration, '2.7.6'): - LOG.info('Migrating to version 2.7.5') - from .library_sync.sections import delete_files - delete_files() - - if not utils.compare_version(last_migration, '2.8.3'): - LOG.info('Migrating to version 2.8.2') - from .library_sync import sections - sections.clear_window_vars() - sections.delete_videonode_files() - - if not utils.compare_version(last_migration, '2.8.7'): - LOG.info('Migrating to version 2.8.6') - # Need to delete the UNIQUE index that prevents creating several - # playlist entries with the same kodi_hash + if not utils.compare_version(last_migration, '3.0.5'): + LOG.info('Migrating to version 3.0.4') + # Add an additional column `trailer_synced` in the Plex movie table from .plex_db import PlexDB with PlexDB() as plexdb: - plexdb.cursor.execute('DROP INDEX IF EXISTS ix_playlists_3') + query = 'ALTER TABLE movie ADD trailer_synced BOOLEAN' + plexdb.cursor.execute(query) # Index will be automatically recreated on next PKC startup - if not utils.compare_version(last_migration, '2.8.9'): - LOG.info('Migrating to version 2.8.8') - from .library_sync import sections - sections.clear_window_vars() - sections.delete_videonode_files() - - if not utils.compare_version(last_migration, '2.9.3'): - LOG.info('Migrating to version 2.9.2') - # Re-sync all playlists to Kodi - from .playlists import remove_synced_playlists - remove_synced_playlists() - - if not utils.compare_version(last_migration, '2.9.7'): - LOG.info('Migrating to version 2.9.6') - # Allow for a new "Direct Stream" setting (number 2), so shift the - # last setting for "force transcoding" - current_playback_type = utils.cast(int, utils.settings('playType')) or 0 - if current_playback_type == 2: - current_playback_type = 3 - utils.settings('playType', value=str(current_playback_type)) - - if not utils.compare_version(last_migration, '2.9.8'): - LOG.info('Migrating to version 2.9.7') - # Force-scan every single item in the library - seems like we could - # loose some recently added items otherwise - # Caused by 65a921c3cc2068c4a34990d07289e2958f515156 - from . import library_sync - library_sync.force_full_sync() - - if not utils.compare_version(last_migration, '2.11.3'): - LOG.info('Migrating to version 2.11.2') - # Re-sync all playlists to Kodi - from .playlists import remove_synced_playlists - remove_synced_playlists() - - if not utils.compare_version(last_migration, '2.12.2'): - LOG.info('Migrating to version 2.12.1') - # Sign user out to make sure he needs to sign in again - utils.settings('username', value='') - utils.settings('userid', value='') - utils.settings('plex_restricteduser', value='') - utils.settings('accessToken', value='') - utils.settings('plexAvatar', value='') - utils.settings('last_migrated_PKC_version', value=v.ADDON_VERSION)