Skip to content

Commit

Permalink
Add translate_path() function
Browse files Browse the repository at this point in the history
  • Loading branch information
dagwieers committed Sep 17, 2019
1 parent a9af351 commit a2e4664
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/inputstreamhelper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from xbmcaddon import Addon
from xbmcgui import Dialog, DialogProgress
import xbmcvfs
from .kodiutils import execute_jsonrpc, get_addon_info, get_proxies, get_setting, localize, log, set_setting
from .kodiutils import execute_jsonrpc, get_addon_info, get_proxies, get_setting, localize, log, set_setting, translate_path
from .unicodehelper import to_unicode

# NOTE: Work around issue caused by platform still using os.popen()
Expand Down Expand Up @@ -93,7 +93,7 @@ def _diskspace(cls):
@classmethod
def _temp_path(cls):
''' Return temporary path, usually ~/.kodi/userdata/addon_data/script.module.inputstreamhelper/temp '''
temp_path = xbmc.translatePath(os.path.join(get_setting('temp_path', 'special://masterprofile/addon_data/script.module.inputstreamhelper'), 'temp'))
temp_path = translate_path(os.path.join(get_setting('temp_path', 'special://masterprofile/addon_data/script.module.inputstreamhelper'), 'temp'))
if not xbmcvfs.exists(temp_path):
xbmcvfs.mkdir(temp_path)

Expand All @@ -112,7 +112,7 @@ def _mnt_path(cls):
def _ia_cdm_path(cls):
''' Return the specified CDM path for inputstream.adaptive, usually ~/.kodi/cdm '''
addon = Addon('inputstream.adaptive')
cdm_path = to_unicode(xbmc.translatePath(addon.getSetting('DECRYPTERPATH')))
cdm_path = translate_path(addon.getSetting('DECRYPTERPATH'))
if not xbmcvfs.exists(cdm_path):
xbmcvfs.mkdir(cdm_path)

Expand Down Expand Up @@ -443,7 +443,7 @@ def _supports_widevine(self):
Dialog().ok(localize(30004), localize(30010, version=config.WIDEVINE_MINIMUM_KODI_VERSION[system_os()])) # Kodi too old
return False

if 'WindowsApps' in xbmc.translatePath('special://xbmcbin/'): # uwp is not supported
if 'WindowsApps' in translate_path('special://xbmcbin/'): # uwp is not supported
log('Unsupported UWP Kodi version detected.')
Dialog().ok(localize(30004), localize(30012)) # Windows Store Kodi falls short
return False
Expand Down
7 changes: 6 additions & 1 deletion lib/inputstreamhelper/kodiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def get_setting(setting_id, default=None):
return value


def translate_path(path):
''' Translate special xbmc paths '''
return to_unicode(xbmc.translatePath(path))


def set_setting(setting_id, setting_value):
''' Set an add-on setting '''
return ADDON.setSetting(setting_id, setting_value)
Expand Down Expand Up @@ -107,7 +112,7 @@ def get_proxies():

def get_userdata_path():
''' Return the profile's userdata path '''
return to_unicode(xbmc.translatePath(ADDON.getAddonInfo('profile')))
return translate_path(ADDON.getAddonInfo('profile'))


def get_addon_info(key):
Expand Down

0 comments on commit a2e4664

Please sign in to comment.