Migrate to new translatePath library

This commit is contained in:
Matt 2021-10-02 13:26:37 -04:00
commit 5e7901be27
12 changed files with 49 additions and 29 deletions

View file

@ -12,6 +12,7 @@ from kodi_six import xbmc, xbmcaddon
import database
from helper import get_filesystem_encoding
from helper.utils import translate_path
from . import settings
from . import kodi_version
@ -19,7 +20,7 @@ from . import kodi_version
##################################################################################################
__addon__ = xbmcaddon.Addon(id='plugin.video.jellyfin')
__pluginpath__ = xbmc.translatePath(__addon__.getAddonInfo('path'))
__pluginpath__ = translate_path(__addon__.getAddonInfo('path'))
##################################################################################################

View file

@ -12,6 +12,7 @@ from kodi_six import xbmc, xbmcvfs
import client
import requests
from helper import LazyLogger
from helper.utils import translate_path
from . import translate, settings, window, dialog, api
@ -548,7 +549,7 @@ class PlayUtils(object):
''' Download external subtitles to temp folder
to be able to have proper names to streams.
'''
temp = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/temp/")
temp = translate_path("special://profile/addon_data/plugin.video.jellyfin/temp/")
if not xbmcvfs.exists(temp):
xbmcvfs.mkdir(temp)

View file

@ -551,3 +551,15 @@ def find_library(server, item):
LOG.error('No ancestor found, not syncing item with ID: {}'.format(item['Id']))
return {}
def translate_path(path):
'''
Use new library location for translate path starting in Kodi 19
'''
version = kodi_version()
if version > 18:
return xbmcvfs.translatePath(path)
else:
return xbmc.translatePath(path)

View file

@ -9,6 +9,7 @@ import xml.etree.ElementTree as etree
from kodi_six import xbmc
from helper import LazyLogger
from helper.utils import translate_path
from . import translate, dialog, settings
@ -47,7 +48,7 @@ def advanced_settings():
if settings('useDirectPaths') != "0":
return
path = xbmc.translatePath("special://profile/")
path = translate_path("special://profile/")
file = os.path.join(path, 'advancedsettings.xml')
try: