Update patch process

Add extra verification
This commit is contained in:
angelblue05 2018-09-09 02:49:56 -05:00
parent a0aa9530d4
commit 1832a54ee9
5 changed files with 50 additions and 5 deletions

View file

@ -777,3 +777,11 @@ msgstr ""
msgctxt "#33159" msgctxt "#33159"
msgid "Enable audio/subtitles selection" msgid "Enable audio/subtitles selection"
msgstr "" msgstr ""
msgctxt "#33160"
msgid "To avoid errors, please update Emby for Kodi to version: "
msgstr ""
msgctxt "#33161"
msgid "Check for updates"
msgstr ""

View file

@ -19,7 +19,7 @@ import setup
import monitor import monitor
from libraries import requests from libraries import requests
from views import Views, verify_kodi_defaults from views import Views, verify_kodi_defaults
from helper import _, window, settings, event, dialog, find from helper import _, window, settings, event, dialog, find, compare_version
from downloader import get_objects from downloader import get_objects
from emby import Emby from emby import Emby
@ -42,6 +42,7 @@ class Service(xbmc.Monitor):
def __init__(self): def __init__(self):
self.settings['addon_version'] = client.get_version()
self.settings['profile'] = xbmc.translatePath('special://profile') self.settings['profile'] = xbmc.translatePath('special://profile')
self.settings['mode'] = settings('useDirectPaths') self.settings['mode'] = settings('useDirectPaths')
self.settings['log_level'] = settings('logLevel') or "1" self.settings['log_level'] = settings('logLevel') or "1"
@ -157,6 +158,12 @@ class Service(xbmc.Monitor):
else: else:
dialog("notification", heading="{emby}", message=_(33156), icon="{emby}") dialog("notification", heading="{emby}", message=_(33156), icon="{emby}")
try:
if compare_version(self.settings['addon_version'], objects.embyversion) < 0:
dialog("ok", heading="{emby}", line1="%s %s" % (_(33160), objects.embyversion))
except Exception:
pass
except Exception as error: except Exception as error:
LOG.exception(error) LOG.exception(error)

View file

@ -13,6 +13,7 @@ from utils import values
from utils import JSONRPC from utils import JSONRPC
from utils import indent from utils import indent
from utils import write_xml from utils import write_xml
from utils import compare_version
from wrapper import progress from wrapper import progress
from wrapper import catch from wrapper import catch

View file

@ -86,6 +86,34 @@ def settings(setting, value=None):
def create_id(): def create_id():
return uuid4() return uuid4()
def compare_version(a, b):
''' -1 a is smaller
1 a is larger
0 equal
'''
a = a.split('.')
b = b.split('.')
for i in range(0, max(len(a), len(b)), 1):
try:
aVal = a[i]
except IndexError:
aVal = 0
try:
bVal = b[i]
except IndexError:
bVal = 0
if aVal < bVal:
return -1
if aVal > bVal:
return 1
return 0
def find(dict, item): def find(dict, item):
''' Find value in dictionary. ''' Find value in dictionary.
@ -231,7 +259,7 @@ def delete_folder(path=None):
''' Delete objects from kodi cache ''' Delete objects from kodi cache
''' '''
LOG.debug("--[ delete folder ]") LOG.debug("--[ delete folder ]")
delete_path = path is not None
path = path or xbmc.translatePath('special://temp/emby').decode('utf-8') path = path or xbmc.translatePath('special://temp/emby').decode('utf-8')
dirs, files = xbmcvfs.listdir(path) dirs, files = xbmcvfs.listdir(path)
@ -240,8 +268,9 @@ def delete_folder(path=None):
for file in files: for file in files:
xbmcvfs.delete(os.path.join(path, file.decode('utf-8'))) xbmcvfs.delete(os.path.join(path, file.decode('utf-8')))
if delete_path:
xbmcvfs.delete(path) xbmcvfs.delete(path)
LOG.info("deleted %s", path) LOG.info("DELETE %s", path)
def delete_recursive(path, dirs): def delete_recursive(path, dirs):

View file

@ -86,7 +86,7 @@
<setting label="30529" id="startupDelay" type="number" default="0" option="int" /> <setting label="30529" id="startupDelay" type="number" default="0" option="int" />
<setting label="30239" type="action" action="RunPlugin(plugin://plugin.video.emby?mode=reset)" option="close" /> <setting label="30239" type="action" action="RunPlugin(plugin://plugin.video.emby?mode=reset)" option="close" />
<setting label="30535" type="action" action="RunPlugin(plugin://plugin.video.emby?mode=deviceid)" option="close" /> <setting label="30535" type="action" action="RunPlugin(plugin://plugin.video.emby?mode=deviceid)" option="close" />
<setting label="24034" type="action" action="RunPlugin(plugin://plugin.video.emby?mode=checkupdate)" option="close" /> <setting label="33161" type="action" action="RunPlugin(plugin://plugin.video.emby?mode=checkupdate)" option="close" />
<setting type="sep"/> <setting type="sep"/>
<setting label="33104" type="lsep"/> <setting label="33104" type="lsep"/>