Fix PKC not starting by importing playlist module only when sync enabled

- Fixes #521
This commit is contained in:
croneter 2018-08-05 18:09:48 +02:00
parent 04da98bcc6
commit 53c10b0847
5 changed files with 14 additions and 15 deletions

View file

@ -110,7 +110,7 @@ msgstr ""
# PKC settings sync options # PKC settings sync options
msgctxt "#30020" msgctxt "#30020"
msgid "Sync Plex playlists" msgid "Sync Plex playlists (reboot Kodi!)"
msgstr "" msgstr ""
# PKC settings sync options # PKC settings sync options

View file

@ -51,7 +51,6 @@ STATE_SETTINGS = {
'forceReloadSkinOnPlaybackStop': 'FORCE_RELOAD_SKIN', 'forceReloadSkinOnPlaybackStop': 'FORCE_RELOAD_SKIN',
'fetch_pms_item_number': 'FETCH_PMS_ITEM_NUMBER', 'fetch_pms_item_number': 'FETCH_PMS_ITEM_NUMBER',
'imageSyncNotifications': 'IMAGE_SYNC_NOTIFICATIONS', 'imageSyncNotifications': 'IMAGE_SYNC_NOTIFICATIONS',
'enablePlaylistSync': 'SYNC_PLAYLISTS',
'syncSpecificPlexPlaylists': 'SYNC_SPECIFIC_PLEX_PLAYLISTS', 'syncSpecificPlexPlaylists': 'SYNC_SPECIFIC_PLEX_PLAYLISTS',
'syncSpecificKodiPlaylists': 'SYNC_SPECIFIC_KODI_PLAYLISTS' 'syncSpecificKodiPlaylists': 'SYNC_SPECIFIC_KODI_PLAYLISTS'
} }

View file

@ -20,10 +20,16 @@ from . import plex_functions as PF
from .plex_api import API from .plex_api import API
from .library_sync import get_metadata, process_metadata, fanart, sync_info from .library_sync import get_metadata, process_metadata, fanart, sync_info
from . import music from . import music
from . import playlists
from . import variables as v from . import variables as v
from . import state from . import state
if utils.settings('enablePlaylistSync') == 'true':
# Xbox cannot use watchdog, a dependency for PKC playlist features
from . import playlists
PLAYLIST_SYNC_ENABLED = True
else:
PLAYLIST_SYNC_ENABLED = False
############################################################################### ###############################################################################
LOG = getLogger('PLEX.librarysync') LOG = getLogger('PLEX.librarysync')
@ -265,7 +271,7 @@ class LibrarySync(Thread):
repair) repair)
if not self._full_sync(): if not self._full_sync():
return False return False
if not playlists.full_sync(): if PLAYLIST_SYNC_ENABLED and not playlists.full_sync():
return False return False
return True return True
@ -1186,7 +1192,7 @@ class LibrarySync(Thread):
continue continue
status = int(item['state']) status = int(item['state'])
if typus == 'playlist': if typus == 'playlist':
if not state.SYNC_PLAYLISTS: if not PLAYLIST_SYNC_ENABLED:
continue continue
playlists.websocket(plex_id=unicode(item['itemID']), playlists.websocket(plex_id=unicode(item['itemID']),
status=status) status=status)
@ -1560,6 +1566,7 @@ class LibrarySync(Thread):
initial_sync_done = True initial_sync_done = True
kodi_db_version_checked = True kodi_db_version_checked = True
last_sync = utils.unix_timestamp() last_sync = utils.unix_timestamp()
if PLAYLIST_SYNC_ENABLED:
playlist_monitor = playlists.kodi_playlist_monitor() playlist_monitor = playlists.kodi_playlist_monitor()
self.sync_fanart() self.sync_fanart()
self.fanartthread.start() self.fanartthread.start()
@ -1612,6 +1619,7 @@ class LibrarySync(Thread):
initial_sync_done = True initial_sync_done = True
last_sync = utils.unix_timestamp() last_sync = utils.unix_timestamp()
LOG.info('Done initial sync on Kodi startup') LOG.info('Done initial sync on Kodi startup')
if PLAYLIST_SYNC_ENABLED:
playlist_monitor = playlists.kodi_playlist_monitor() playlist_monitor = playlists.kodi_playlist_monitor()
artwork.Artwork().cache_major_artwork() artwork.Artwork().cache_major_artwork()
self.sync_fanart() self.sync_fanart()

View file

@ -113,9 +113,6 @@ def full_sync():
Full sync of playlists between Kodi and Plex. Returns True is successful, Full sync of playlists between Kodi and Plex. Returns True is successful,
False otherwise False otherwise
""" """
if not state.SYNC_PLAYLISTS:
LOG.debug('Not syncing playlists')
return True
LOG.info('Starting playlist full sync') LOG.info('Starting playlist full sync')
with state.LOCK_PLAYLISTS: with state.LOCK_PLAYLISTS:
return _full_sync() return _full_sync()
@ -282,9 +279,6 @@ class PlaylistEventhandler(events.FileSystemEventHandler):
:type event: :type event:
:class:`FileSystemEvent` :class:`FileSystemEvent`
""" """
if not state.SYNC_PLAYLISTS:
# Sync is deactivated
return
path = event.dest_path if event.event_type == events.EVENT_TYPE_MOVED \ path = event.dest_path if event.event_type == events.EVENT_TYPE_MOVED \
else event.src_path else event.src_path
if not sync_kodi_playlist(path): if not sync_kodi_playlist(path):

View file

@ -57,8 +57,6 @@ FORCE_RELOAD_SKIN = True
SYNC_DIALOG = True SYNC_DIALOG = True
# Shall Kodi show dialogs for syncing/caching images? (e.g. images left to sync) # Shall Kodi show dialogs for syncing/caching images? (e.g. images left to sync)
IMAGE_SYNC_NOTIFICATIONS = True IMAGE_SYNC_NOTIFICATIONS = True
# Sync playlists from Plex to Kodi and vice-versa?
SYNC_PLAYLISTS = True
# Only sync specific Plex playlists to Kodi? # Only sync specific Plex playlists to Kodi?
SYNC_SPECIFIC_PLEX_PLAYLISTS = False SYNC_SPECIFIC_PLEX_PLAYLISTS = False
# Only sync specific Kodi playlists to Plex? # Only sync specific Kodi playlists to Plex?