Library sync dialog code optimization
This commit is contained in:
parent
8af180968b
commit
b103309ceb
2 changed files with 33 additions and 26 deletions
|
@ -63,7 +63,6 @@ class LibrarySync(Thread):
|
||||||
|
|
||||||
self.user = userclient.UserClient()
|
self.user = userclient.UserClient()
|
||||||
self.vnodes = videonodes.VideoNodes()
|
self.vnodes = videonodes.VideoNodes()
|
||||||
self.dialog = xbmcgui.Dialog()
|
|
||||||
|
|
||||||
self.syncThreadNumber = int(settings('syncThreadNumber'))
|
self.syncThreadNumber = int(settings('syncThreadNumber'))
|
||||||
self.installSyncDone = settings('SyncInstallRunDone') == 'true'
|
self.installSyncDone = settings('SyncInstallRunDone') == 'true'
|
||||||
|
@ -98,19 +97,16 @@ class LibrarySync(Thread):
|
||||||
if not forced:
|
if not forced:
|
||||||
return
|
return
|
||||||
if icon == "plex":
|
if icon == "plex":
|
||||||
self.dialog.notification(
|
dialog('notification',
|
||||||
lang(29999),
|
heading='{plex}',
|
||||||
message,
|
message=message,
|
||||||
"special://home/addons/plugin.video.plexkodiconnect/icon.png",
|
icon='{plex}',
|
||||||
5000,
|
sound=False)
|
||||||
False)
|
|
||||||
elif icon == "error":
|
elif icon == "error":
|
||||||
self.dialog.notification(
|
dialog('notification',
|
||||||
lang(29999),
|
heading='{plex}',
|
||||||
message,
|
message=message,
|
||||||
xbmcgui.NOTIFICATION_ERROR,
|
type='{error}')
|
||||||
7000,
|
|
||||||
True)
|
|
||||||
|
|
||||||
def syncPMStime(self):
|
def syncPMStime(self):
|
||||||
"""
|
"""
|
||||||
|
@ -317,13 +313,13 @@ class LibrarySync(Thread):
|
||||||
setScreensaver(value=screensaver)
|
setScreensaver(value=screensaver)
|
||||||
if window('plex_scancrashed') == 'true':
|
if window('plex_scancrashed') == 'true':
|
||||||
# Show warning if itemtypes.py crashed at some point
|
# Show warning if itemtypes.py crashed at some point
|
||||||
self.dialog.ok(lang(29999), lang(39408))
|
dialog('ok', heading='{plex}', line1=lang(39408))
|
||||||
window('plex_scancrashed', clear=True)
|
window('plex_scancrashed', clear=True)
|
||||||
elif window('plex_scancrashed') == '401':
|
elif window('plex_scancrashed') == '401':
|
||||||
window('plex_scancrashed', clear=True)
|
window('plex_scancrashed', clear=True)
|
||||||
if state.PMS_STATUS not in ('401', 'Auth'):
|
if state.PMS_STATUS not in ('401', 'Auth'):
|
||||||
# Plex server had too much and returned ERROR
|
# Plex server had too much and returned ERROR
|
||||||
self.dialog.ok(lang(29999), lang(39409))
|
dialog('ok', heading='{plex}', line1=lang(39409))
|
||||||
|
|
||||||
# Path hack, so Kodis Information screen works
|
# Path hack, so Kodis Information screen works
|
||||||
with kodidb.GetKodiDB('video') as kodi_db:
|
with kodidb.GetKodiDB('video') as kodi_db:
|
||||||
|
@ -477,7 +473,7 @@ class LibrarySync(Thread):
|
||||||
log.info('Detected new Music library - restarting now')
|
log.info('Detected new Music library - restarting now')
|
||||||
# 'New Plex music library detected. Sorry, but we need to
|
# 'New Plex music library detected. Sorry, but we need to
|
||||||
# restart Kodi now due to the changes made.'
|
# restart Kodi now due to the changes made.'
|
||||||
dialog('ok', lang(29999), lang(39711))
|
dialog('ok', heading='{plex}', line1=lang(39711))
|
||||||
from xbmc import executebuiltin
|
from xbmc import executebuiltin
|
||||||
executebuiltin('RestartApp')
|
executebuiltin('RestartApp')
|
||||||
return False
|
return False
|
||||||
|
@ -1404,7 +1400,7 @@ class LibrarySync(Thread):
|
||||||
import traceback
|
import traceback
|
||||||
log.error("Traceback:\n%s" % traceback.format_exc())
|
log.error("Traceback:\n%s" % traceback.format_exc())
|
||||||
# Library sync thread has crashed
|
# Library sync thread has crashed
|
||||||
self.dialog.ok(lang(29999), lang(39400))
|
dialog('ok', heading='{plex}', line1=lang(39400))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def run_internal(self):
|
def run_internal(self):
|
||||||
|
@ -1459,13 +1455,15 @@ class LibrarySync(Thread):
|
||||||
log.warn("Db version out of date: %s minimum version "
|
log.warn("Db version out of date: %s minimum version "
|
||||||
"required: %s" % (currentVersion, minVersion))
|
"required: %s" % (currentVersion, minVersion))
|
||||||
# DB out of date. Proceed to recreate?
|
# DB out of date. Proceed to recreate?
|
||||||
resp = self.dialog.yesno(heading=lang(29999),
|
resp = dialog('yesno',
|
||||||
line1=lang(39401))
|
heading=lang(29999),
|
||||||
|
line1=lang(39401))
|
||||||
if not resp:
|
if not resp:
|
||||||
log.warn("Db version out of date! USER IGNORED!")
|
log.warn("Db version out of date! USER IGNORED!")
|
||||||
# PKC may not work correctly until reset
|
# PKC may not work correctly until reset
|
||||||
self.dialog.ok(heading=lang(29999),
|
dialog('ok',
|
||||||
line1=(lang(29999) + lang(39402)))
|
heading='{plex}',
|
||||||
|
line1=lang(29999) + lang(39402))
|
||||||
else:
|
else:
|
||||||
reset()
|
reset()
|
||||||
break
|
break
|
||||||
|
@ -1483,7 +1481,7 @@ class LibrarySync(Thread):
|
||||||
log.error('Current Kodi version: %s' % tryDecode(
|
log.error('Current Kodi version: %s' % tryDecode(
|
||||||
xbmc.getInfoLabel('System.BuildVersion')))
|
xbmc.getInfoLabel('System.BuildVersion')))
|
||||||
# "Current Kodi version is unsupported, cancel lib sync"
|
# "Current Kodi version is unsupported, cancel lib sync"
|
||||||
self.dialog.ok(heading=lang(29999), line1=lang(39403))
|
dialog('ok', heading='{plex}', line1=lang(39403))
|
||||||
break
|
break
|
||||||
# Run start up sync
|
# Run start up sync
|
||||||
state.DB_SCAN = True
|
state.DB_SCAN = True
|
||||||
|
@ -1525,8 +1523,7 @@ class LibrarySync(Thread):
|
||||||
log.error("Startup full sync failed. Stopping sync")
|
log.error("Startup full sync failed. Stopping sync")
|
||||||
# "Startup syncing process failed repeatedly"
|
# "Startup syncing process failed repeatedly"
|
||||||
# "Please restart"
|
# "Please restart"
|
||||||
self.dialog.ok(heading=lang(29999),
|
dialog('ok', heading='{plex}', line1=lang(39404))
|
||||||
line1=lang(39404))
|
|
||||||
break
|
break
|
||||||
|
|
||||||
# Currently no db scan, so we can start a new scan
|
# Currently no db scan, so we can start a new scan
|
||||||
|
@ -1575,8 +1572,9 @@ class LibrarySync(Thread):
|
||||||
window('plex_runLibScan', clear=True)
|
window('plex_runLibScan', clear=True)
|
||||||
# Only look for missing fanart (No)
|
# Only look for missing fanart (No)
|
||||||
# or refresh all fanart (Yes)
|
# or refresh all fanart (Yes)
|
||||||
self.fanartSync(refresh=self.dialog.yesno(
|
self.fanartSync(refresh=dialog(
|
||||||
heading=lang(29999),
|
'yesno',
|
||||||
|
heading='{plex}',
|
||||||
line1=lang(39223),
|
line1=lang(39223),
|
||||||
nolabel=lang(39224),
|
nolabel=lang(39224),
|
||||||
yeslabel=lang(39225)))
|
yeslabel=lang(39225)))
|
||||||
|
|
|
@ -140,6 +140,15 @@ def dialog(typus, *args, **kwargs):
|
||||||
Displays xbmcgui Dialog. Pass a string as typus:
|
Displays xbmcgui Dialog. Pass a string as typus:
|
||||||
'yesno', 'ok', 'notification', 'input', 'select', 'numeric'
|
'yesno', 'ok', 'notification', 'input', 'select', 'numeric'
|
||||||
|
|
||||||
|
kwargs:
|
||||||
|
heading='{plex}' title bar (here PlexKodiConnect)
|
||||||
|
message=lang(30128), Actual dialog content. Don't use with OK
|
||||||
|
line1=str(), For 'OK' and 'yesno' dialogs use line1...line3!
|
||||||
|
time=5000,
|
||||||
|
sound=True,
|
||||||
|
nolabel=str(), For 'yesno' dialogs
|
||||||
|
yeslabel=str(), For 'yesno' dialogs
|
||||||
|
|
||||||
Icons:
|
Icons:
|
||||||
icon='{plex}' Display Plex standard icon
|
icon='{plex}' Display Plex standard icon
|
||||||
icon='{info}' xbmcgui.NOTIFICATION_INFO
|
icon='{info}' xbmcgui.NOTIFICATION_INFO
|
||||||
|
|
Loading…
Reference in a new issue