Merge pull request #44 from oddstr13/pr-codecache-cleanup-1

Remove code caching, fixing Kodi 18 Music syncing for existing installs.
This commit is contained in:
Odd Stråbø 2019-07-14 21:41:31 +02:00 committed by GitHub
commit ccdcac7f0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 7 additions and 76 deletions

View File

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

View File

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

View File

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

View File

@ -12,7 +12,6 @@ import xbmc
import xbmcvfs import xbmcvfs
import jellyfin_db import jellyfin_db
from helper.utils import delete_folder
from helper import _, settings, window, dialog from helper import _, settings, window, dialog
from objects import obj from objects import obj

View File

@ -5,15 +5,10 @@
import logging import logging
import Queue import Queue
import threading import threading
import os
import xbmc import xbmc
import xbmcvfs
import xbmcaddon
import requests import requests
from helper.utils import delete_folder from helper import settings, stop, event, window, create_id
from helper import settings, stop, event, window, unzip, create_id
from jellyfin import Jellyfin from jellyfin import Jellyfin
from jellyfin.core import api from jellyfin.core import api
from jellyfin.core.exceptions import HTTPException from jellyfin.core.exceptions import HTTPException
@ -22,7 +17,6 @@ from jellyfin.core.exceptions import HTTPException
LOG = logging.getLogger("JELLYFIN."+__name__) LOG = logging.getLogger("JELLYFIN."+__name__)
LIMIT = min(int(settings('limitIndex') or 50), 50) LIMIT = min(int(settings('limitIndex') or 50), 50)
CACHE = xbmc.translatePath(os.path.join(xbmcaddon.Addon(id='plugin.video.jellyfin').getAddonInfo('profile').decode('utf-8'), 'jellyfin')).decode('utf-8')
################################################################################################# #################################################################################################
@ -372,40 +366,3 @@ class TheVoid(object):
xbmc.sleep(100) xbmc.sleep(100)
LOG.info("--[ void/%s ]", self.data['VoidName']) LOG.info("--[ void/%s ]", self.data['VoidName'])
def get_objects(src, filename):
''' Download objects dependency to temp cache folder.
'''
temp = CACHE
restart = not xbmcvfs.exists(os.path.join(temp, "objects") + '/')
path = os.path.join(temp, filename).encode('utf-8')
if restart and (settings('appliedPatch') or "") == filename:
LOG.warn("Something went wrong applying this patch %s previously.", filename)
restart = False
if not xbmcvfs.exists(path) or filename.startswith('DEV'):
delete_folder(CACHE)
LOG.info("From %s to %s", src, path.decode('utf-8'))
try:
response = requests.get(src, stream=True, verify=True)
response.raise_for_status()
except requests.exceptions.SSLError as error:
LOG.error(error)
response = requests.get(src, stream=True, verify=False)
dl = xbmcvfs.File(path, 'w')
dl.write(response.content)
dl.close()
del response
settings('appliedPatch', filename)
unzip(path, temp, "objects")
return restart

View File

@ -17,10 +17,8 @@ import client
import library import library
import setup import setup
import monitor import monitor
import requests
from views import Views, verify_kodi_defaults from views import Views, verify_kodi_defaults
from helper import _, window, settings, event, dialog, find, compare_version from helper import _, window, settings, event, dialog, compare_version
from downloader import get_objects
from jellyfin import Jellyfin from jellyfin import Jellyfin
from database import Database, jellyfin_db, reset from database import Database, jellyfin_db, reset

View File

@ -277,13 +277,12 @@ def write_xml(content, file):
content = content.replace('?>', ' standalone="yes" ?>', 1) content = content.replace('?>', ' standalone="yes" ?>', 1)
infile.write(content) infile.write(content)
def delete_folder(path=None):
def delete_folder(path):
''' 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/jellyfin').decode('utf-8')
dirs, files = xbmcvfs.listdir(path) dirs, files = xbmcvfs.listdir(path)
delete_recursive(path, dirs) delete_recursive(path, dirs)
@ -291,11 +290,11 @@ 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("DELETE %s", path) LOG.info("DELETE %s", path)
def delete_recursive(path, dirs): def delete_recursive(path, dirs):
''' Delete files and dirs recursively. ''' Delete files and dirs recursively.
@ -309,6 +308,7 @@ def delete_recursive(path, dirs):
delete_recursive(os.path.join(path, directory.decode('utf-8')), dirs2) delete_recursive(os.path.join(path, directory.decode('utf-8')), dirs2)
xbmcvfs.rmdir(os.path.join(path, directory.decode('utf-8'))) xbmcvfs.rmdir(os.path.join(path, directory.decode('utf-8')))
def unzip(path, dest, folder=None): def unzip(path, dest, folder=None):
''' Unzip file. zipfile module seems to fail on android with badziperror. ''' Unzip file. zipfile module seems to fail on android with badziperror.

View File

@ -8,7 +8,6 @@ import threading
import sys import sys
import xbmc import xbmc
import xbmcvfs
import xbmcaddon import xbmcaddon
################################################################################################# #################################################################################################
@ -16,18 +15,8 @@ import xbmcaddon
__addon__ = xbmcaddon.Addon(id='plugin.video.jellyfin') __addon__ = xbmcaddon.Addon(id='plugin.video.jellyfin')
__base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')).decode('utf-8') __base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')).decode('utf-8')
__libraries__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'libraries')).decode('utf-8') __libraries__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'libraries')).decode('utf-8')
__pcache__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('profile'), 'jellyfin')).decode('utf-8')
__cache__ = xbmc.translatePath('special://temp/jellyfin').decode('utf-8')
sys.path.insert(0, __libraries__) sys.path.insert(0, __libraries__)
if not xbmcvfs.exists(__pcache__ + '/'):
from resources.lib.helper.utils import copytree
copytree(os.path.join(__base__, 'objects'), os.path.join(__pcache__, 'objects'))
sys.path.insert(0, __cache__)
sys.path.insert(0, __pcache__)
sys.path.append(__base__) sys.path.append(__base__)
################################################################################################# #################################################################################################