2018-07-13 02:46:02 +10:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import absolute_import, division, unicode_literals
|
2017-05-30 01:29:29 +10:00
|
|
|
from logging import getLogger
|
2018-06-22 03:24:37 +10:00
|
|
|
|
|
|
|
from . import variables as v
|
|
|
|
from . import utils
|
2017-05-30 01:29:29 +10:00
|
|
|
###############################################################################
|
|
|
|
|
2018-06-22 03:24:37 +10:00
|
|
|
LOG = getLogger('PLEX.migration')
|
2017-05-30 01:29:29 +10:00
|
|
|
|
|
|
|
|
|
|
|
def check_migration():
|
2018-06-22 03:24:37 +10:00
|
|
|
LOG.info('Checking whether we need to migrate something')
|
|
|
|
last_migration = utils.settings('last_migrated_PKC_version')
|
2019-09-11 01:56:56 +10:00
|
|
|
# Ensure later migration if user downgraded PKC!
|
|
|
|
utils.settings('last_migrated_PKC_version', value=v.ADDON_VERSION)
|
|
|
|
|
|
|
|
if last_migration == '':
|
|
|
|
LOG.info('New, clean PKC installation - no migration necessary')
|
|
|
|
return
|
|
|
|
elif last_migration == v.ADDON_VERSION:
|
2018-06-22 03:24:37 +10:00
|
|
|
LOG.info('Already migrated to PKC version %s' % v.ADDON_VERSION)
|
2017-05-30 01:29:29 +10:00
|
|
|
return
|
|
|
|
|
2018-06-22 03:24:37 +10:00
|
|
|
if not utils.compare_version(last_migration, '1.8.2'):
|
|
|
|
LOG.info('Migrating to version 1.8.1')
|
2017-05-30 01:29:29 +10:00
|
|
|
# Set the new PKC theMovieDB key
|
2018-06-22 03:24:37 +10:00
|
|
|
utils.settings('themoviedbAPIKey',
|
|
|
|
value='19c90103adb9e98f2172c6a6a3d85dc4')
|
2017-05-30 01:29:29 +10:00
|
|
|
|
2018-06-22 03:24:37 +10:00
|
|
|
if not utils.compare_version(last_migration, '2.0.25'):
|
|
|
|
LOG.info('Migrating to version 2.0.24')
|
2018-05-15 03:42:00 +10:00
|
|
|
# Need to re-connect with PMS to pick up on plex.direct URIs
|
2018-06-22 03:24:37 +10:00
|
|
|
utils.settings('ipaddress', value='')
|
|
|
|
utils.settings('port', value='')
|
2018-05-15 03:42:00 +10:00
|
|
|
|
2019-03-10 01:18:59 +11:00
|
|
|
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()
|
|
|
|
|
2019-06-14 20:46:37 +10:00
|
|
|
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()
|
|
|
|
|
2019-06-28 23:27:02 +10:00
|
|
|
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
|
|
|
|
from .plex_db import PlexDB
|
|
|
|
with PlexDB() as plexdb:
|
|
|
|
plexdb.cursor.execute('DROP INDEX IF EXISTS ix_playlists_3')
|
|
|
|
# Index will be automatically recreated on next PKC startup
|
|
|
|
|
2019-07-07 05:22:12 +10:00
|
|
|
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()
|
|
|
|
|
2019-08-01 22:22:44 +10:00
|
|
|
if not utils.compare_version(last_migration, '2.9.3'):
|
|
|
|
LOG.info('Migrating to version 2.9.2')
|
|
|
|
# Re-sync all playlists to Kodi
|
|
|
|
utils.wipe_synched_playlists()
|
|
|
|
|
2019-08-17 21:05:22 +10:00
|
|
|
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))
|
|
|
|
|
2019-09-11 01:46:33 +10:00
|
|
|
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()
|
|
|
|
|
2018-06-22 03:24:37 +10:00
|
|
|
utils.settings('last_migrated_PKC_version', value=v.ADDON_VERSION)
|