Update patch

Move patch from cache to addon_data. No longer need to restart Kodi to apply the first patch.
This commit is contained in:
angelblue05 2018-10-11 20:24:33 -05:00
parent 7df7e5d4a8
commit 403e5834e0
8 changed files with 55 additions and 34 deletions

View file

@ -11,10 +11,13 @@ import xbmcaddon
#################################################################################################
cache = xbmc.translatePath('special://temp/emby').decode('utf-8')
sys.path.insert(0, cache)
__addon__ = xbmcaddon.Addon(id='plugin.video.emby').getAddonInfo('path').decode('utf-8')
__base__ = xbmc.translatePath(os.path.join(__addon__, 'resources', 'lib')).decode('utf-8')
__addon__ = xbmcaddon.Addon(id='plugin.video.emby')
__base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')).decode('utf-8')
__pcache__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('profile'), 'emby')).decode('utf-8')
__cache__ = xbmc.translatePath('special://temp/emby').decode('utf-8')
sys.path.insert(0, __cache__)
sys.path.insert(0, __pcache__)
sys.path.append(__base__)
#################################################################################################

View file

@ -11,10 +11,13 @@ import xbmcaddon
#################################################################################################
cache = xbmc.translatePath('special://temp/emby').decode('utf-8')
sys.path.insert(0, cache)
__addon__ = xbmcaddon.Addon(id='plugin.video.emby').getAddonInfo('path').decode('utf-8')
__base__ = xbmc.translatePath(os.path.join(__addon__, 'resources', 'lib')).decode('utf-8')
__addon__ = xbmcaddon.Addon(id='plugin.video.emby')
__base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')).decode('utf-8')
__pcache__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('profile'), 'emby')).decode('utf-8')
__cache__ = xbmc.translatePath('special://temp/emby').decode('utf-8')
sys.path.insert(0, __cache__)
sys.path.insert(0, __pcache__)
sys.path.append(__base__)
#################################################################################################

View file

@ -11,10 +11,13 @@ import xbmcaddon
#################################################################################################
cache = xbmc.translatePath('special://temp/emby').decode('utf-8')
sys.path.insert(0, cache)
__addon__ = xbmcaddon.Addon(id='plugin.video.emby').getAddonInfo('path').decode('utf-8')
__base__ = xbmc.translatePath(os.path.join(__addon__, 'resources', 'lib')).decode('utf-8')
__addon__ = xbmcaddon.Addon(id='plugin.video.emby')
__base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')).decode('utf-8')
__pcache__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('profile'), 'emby')).decode('utf-8')
__cache__ = xbmc.translatePath('special://temp/emby').decode('utf-8')
sys.path.insert(0, __cache__)
sys.path.insert(0, __pcache__)
sys.path.append(__base__)
#################################################################################################

View file

@ -11,6 +11,7 @@ from datetime import datetime
import xbmc
import xbmcvfs
import xbmcaddon
from libraries import requests
from helper.utils import should_stop, delete_folder
@ -23,6 +24,7 @@ from emby.core.exceptions import HTTPException
LOG = logging.getLogger("EMBY."+__name__)
LIMIT = min(int(settings('limitIndex') or 50), 50)
CACHE = xbmc.translatePath(os.path.join(xbmcaddon.Addon(id='plugin.video.emby').getAddonInfo('profile').decode('utf-8'), 'emby')).decode('utf-8')
#################################################################################################
@ -352,7 +354,7 @@ def get_objects(src, filename):
''' Download objects dependency to temp cache folder.
'''
temp = xbmc.translatePath('special://temp/emby').decode('utf-8')
temp = CACHE
restart = not xbmcvfs.exists(os.path.join(temp, "objects") + '/')
path = os.path.join(temp, filename).encode('utf-8')
@ -362,7 +364,7 @@ def get_objects(src, filename):
restart = False
if not xbmcvfs.exists(path):
delete_folder()
delete_folder(CACHE)
LOG.info("From %s to %s", src, path.decode('utf-8'))
try:

View file

@ -745,10 +745,10 @@ def get_themes():
from helper.playutils import PlayUtils
from helper.xmls import tvtunes_nfo
library = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/").decode('utf-8')
library = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library").decode('utf-8')
play = settings('useDirectPaths') == "1"
if not xbmcvfs.exists(library):
if not xbmcvfs.exists(library + '/'):
xbmcvfs.mkdir(library)
if xbmc.getCondVisibility('System.HasAddon(script.tvtunes)'):

View file

@ -182,25 +182,25 @@ class Service(xbmc.Monitor):
if label == objects.version:
LOG.info("--[ objects/%s ]", objects.version)
return
return False
if get_objects(zipfile, label + '.zip'):
get_objects(zipfile, label + '.zip')
reload(objects) # to apply latest changes
LOG.info("No previous patch found.")
dialog("ok", heading="{emby}", line1=_(33135))
xbmc.executebuiltin('RestartApp')
else:
dialog("notification", heading="{emby}", message=_(33156), icon="{emby}")
dialog("notification", heading="{emby}", message=_(33156), icon="{emby}")
LOG.info("--[ new objects/%s ]", objects.version)
try:
if compare_version(self.settings['addon_version'], objects.embyversion) < 0:
dialog("ok", heading="{emby}", line1="%s %s" % (_(33160), objects.embyversion))
except Exception:
pass
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:
LOG.exception(error)
return True
def onNotification(self, sender, method, data):
''' All notifications are sent via NotifyAll built-in or Kodi.

View file

@ -373,6 +373,9 @@ def copytree(path, dest):
'''
dirs, files = xbmcvfs.listdir(path)
if not xbmcvfs.exists(dest):
xbmcvfs.mkdirs(dest)
if dirs:
copy_recursive(path, dirs, dest)
@ -401,6 +404,9 @@ def copy_file(path, dest):
''' Copy specific file.
'''
if path.endswith('.pyo'):
return
xbmcvfs.copy(path, dest)
LOG.debug("copy: %s to %s", path, dest)

View file

@ -12,14 +12,18 @@ import xbmcaddon
#################################################################################################
cache = xbmc.translatePath('special://temp/emby').decode('utf-8')
__addon__ = xbmcaddon.Addon(id='plugin.video.emby')
__base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')).decode('utf-8')
__pcache__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('profile'), 'emby')).decode('utf-8')
__cache__ = xbmc.translatePath('special://temp/emby').decode('utf-8')
if not xbmcvfs.exists(cache):
xbmcvfs.mkdir(cache)
if not xbmcvfs.exists(__pcache__ + '/'):
from resources.lib.helper.utils import copytree
sys.path.insert(0, cache)
__addon__ = xbmcaddon.Addon(id='plugin.video.emby').getAddonInfo('path').decode('utf-8')
__base__ = xbmc.translatePath(os.path.join(__addon__, 'resources', 'lib')).decode('utf-8')
copytree(os.path.join(__base__, 'objects').decode('utf-8'), os.path.join(__pcache__, 'objects').decode('utf-8'))
sys.path.insert(0, __cache__)
sys.path.insert(0, __pcache__)
sys.path.append(__base__)
#################################################################################################