PlexKodiConnect/resources/lib/migration.py

40 lines
1.5 KiB
Python
Raw Normal View History

#!/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')
2017-05-30 01:29:29 +10:00
if last_migration == v.ADDON_VERSION:
2018-06-22 03:24:37 +10:00
LOG.info('Already migrated to PKC version %s' % v.ADDON_VERSION)
# Ensure later migration if user downgraded PKC!
2018-06-22 03:24:37 +10:00
utils.settings('last_migrated_PKC_version', value=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')
# 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='')
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()
2018-06-22 03:24:37 +10:00
utils.settings('last_migrated_PKC_version', value=v.ADDON_VERSION)