mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
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:
commit
ccdcac7f0b
8 changed files with 7 additions and 76 deletions
|
@ -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__)
|
||||||
|
|
||||||
|
|
|
@ -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__)
|
||||||
|
|
||||||
|
|
|
@ -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__)
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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.
|
||||||
|
|
11
service.py
11
service.py
|
@ -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__)
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
Loading…
Reference in a new issue