mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-13 21:56:11 +00:00
unicode fixes
fix for users who have redirected kodi data folders (replace open with xbmcvfs.file)
This commit is contained in:
parent
ca0906aaaf
commit
2bd1d139c1
4 changed files with 21 additions and 20 deletions
|
@ -185,7 +185,7 @@ class Artwork():
|
||||||
for dir in allDirs:
|
for dir in allDirs:
|
||||||
allDirs, allFiles = xbmcvfs.listdir(path+dir)
|
allDirs, allFiles = xbmcvfs.listdir(path+dir)
|
||||||
for file in allFiles:
|
for file in allFiles:
|
||||||
xbmcvfs.delete(os.path.join(path+dir,file))
|
xbmcvfs.delete(os.path.join(path+dir.decode('utf-8'),file.decode('utf-8')))
|
||||||
|
|
||||||
# remove all existing data from texture DB
|
# remove all existing data from texture DB
|
||||||
textureconnection = utils.kodiSQL('texture')
|
textureconnection = utils.kodiSQL('texture')
|
||||||
|
|
|
@ -7,6 +7,7 @@ from uuid import uuid4
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcaddon
|
import xbmcaddon
|
||||||
|
import xbmcvfs
|
||||||
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ class ClientInfo():
|
||||||
|
|
||||||
if utils.settings('deviceNameOpt') == "false":
|
if utils.settings('deviceNameOpt') == "false":
|
||||||
# Use Kodi's deviceName
|
# Use Kodi's deviceName
|
||||||
deviceName = xbmc.getInfoLabel('System.FriendlyName')
|
deviceName = xbmc.getInfoLabel('System.FriendlyName').decode('utf-8')
|
||||||
else:
|
else:
|
||||||
deviceName = utils.settings('deviceName')
|
deviceName = utils.settings('deviceName')
|
||||||
deviceName = deviceName.replace("\"", "_")
|
deviceName = deviceName.replace("\"", "_")
|
||||||
|
@ -78,12 +79,12 @@ class ClientInfo():
|
||||||
GUID_file = xbmc.translatePath(os.path.join(addon_path, "machine_guid")).decode('utf-8')
|
GUID_file = xbmc.translatePath(os.path.join(addon_path, "machine_guid")).decode('utf-8')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
GUID = open(GUID_file)
|
GUID = xbmcvfs.File(GUID_file)
|
||||||
|
|
||||||
except Exception as e: # machine_guid does not exists.
|
except Exception as e: # machine_guid does not exists.
|
||||||
self.logMsg("Generating a new deviceid: %s" % e, 1)
|
self.logMsg("Generating a new deviceid: %s" % e, 1)
|
||||||
clientId = str("%012X" % uuid4())
|
clientId = str("%012X" % uuid4())
|
||||||
GUID = open(GUID_file, 'w')
|
GUID = xbmcvfs.File(GUID_file, 'w')
|
||||||
GUID.write(clientId)
|
GUID.write(clientId)
|
||||||
|
|
||||||
else: # machine_guid already exists. Get guid.
|
else: # machine_guid already exists. Get guid.
|
||||||
|
|
|
@ -283,7 +283,7 @@ def getThemeMedia():
|
||||||
result = doUtils.downloadUrl(url)
|
result = doUtils.downloadUrl(url)
|
||||||
|
|
||||||
# Create nfo and write themes to it
|
# Create nfo and write themes to it
|
||||||
nfo_file = open(nfo_path, 'w')
|
nfo_file = xbmcvfs.File(nfo_path, 'w')
|
||||||
pathstowrite = ""
|
pathstowrite = ""
|
||||||
# May be more than one theme
|
# May be more than one theme
|
||||||
for theme in result['Items']:
|
for theme in result['Items']:
|
||||||
|
@ -344,7 +344,7 @@ def getThemeMedia():
|
||||||
result = doUtils.downloadUrl(url)
|
result = doUtils.downloadUrl(url)
|
||||||
|
|
||||||
# Create nfo and write themes to it
|
# Create nfo and write themes to it
|
||||||
nfo_file = open(nfo_path, 'w')
|
nfo_file = xbmcvfs.File(nfo_path, 'w')
|
||||||
pathstowrite = ""
|
pathstowrite = ""
|
||||||
# May be more than one theme
|
# May be more than one theme
|
||||||
for theme in result['Items']:
|
for theme in result['Items']:
|
||||||
|
@ -960,12 +960,12 @@ def getExtraFanArt():
|
||||||
try:
|
try:
|
||||||
# for tvshows we get the embyid just from the path
|
# for tvshows we get the embyid just from the path
|
||||||
if xbmc.getCondVisibility("Container.Content(tvshows) | Container.Content(seasons) | Container.Content(episodes)"):
|
if xbmc.getCondVisibility("Container.Content(tvshows) | Container.Content(seasons) | Container.Content(episodes)"):
|
||||||
itemPath = xbmc.getInfoLabel("ListItem.Path")
|
itemPath = xbmc.getInfoLabel("ListItem.Path").decode('utf-8')
|
||||||
if "plugin.video.emby" in itemPath:
|
if "plugin.video.emby" in itemPath:
|
||||||
embyId = itemPath.split("/")[-2]
|
embyId = itemPath.split("/")[-2]
|
||||||
else:
|
else:
|
||||||
#for movies we grab the emby id from the params
|
#for movies we grab the emby id from the params
|
||||||
itemPath = xbmc.getInfoLabel("ListItem.FileNameAndPath")
|
itemPath = xbmc.getInfoLabel("ListItem.FileNameAndPath").decode('utf-8')
|
||||||
if "plugin.video.emby" in itemPath:
|
if "plugin.video.emby" in itemPath:
|
||||||
params = urlparse.parse_qs(itemPath)
|
params = urlparse.parse_qs(itemPath)
|
||||||
embyId = params.get('id')
|
embyId = params.get('id')
|
||||||
|
@ -1003,7 +1003,7 @@ def getExtraFanArt():
|
||||||
# Use existing cached images
|
# Use existing cached images
|
||||||
dirs, files = xbmcvfs.listdir(fanartDir)
|
dirs, files = xbmcvfs.listdir(fanartDir)
|
||||||
for file in files:
|
for file in files:
|
||||||
fanartFile = os.path.join(fanartDir, file)
|
fanartFile = os.path.join(fanartDir, file.decode('utf-8'))
|
||||||
li = xbmcgui.ListItem(file, path=fanartFile)
|
li = xbmcgui.ListItem(file, path=fanartFile)
|
||||||
xbmcplugin.addDirectoryItem(
|
xbmcplugin.addDirectoryItem(
|
||||||
handle=int(sys.argv[1]),
|
handle=int(sys.argv[1]),
|
||||||
|
|
|
@ -45,10 +45,10 @@ def window(property, value=None, clear=False, windowid=10000):
|
||||||
|
|
||||||
if clear:
|
if clear:
|
||||||
WINDOW.clearProperty(property)
|
WINDOW.clearProperty(property)
|
||||||
elif value is not None:
|
elif value is not None: #setproperty accepts both string and unicode but utf-8 string seems best practice to pass
|
||||||
WINDOW.setProperty(property, value)
|
WINDOW.setProperty(property.encode("utf-8"), value.encode("utf-8"))
|
||||||
else:
|
else: #getproperty returns string so convert to unicode
|
||||||
return WINDOW.getProperty(property)
|
return WINDOW.getProperty(property).decode("utf-8")
|
||||||
|
|
||||||
def settings(setting, value=None):
|
def settings(setting, value=None):
|
||||||
# Get or add addon setting
|
# Get or add addon setting
|
||||||
|
@ -138,11 +138,11 @@ def reset():
|
||||||
path = xbmc.translatePath("special://profile/library/video/").decode('utf-8')
|
path = xbmc.translatePath("special://profile/library/video/").decode('utf-8')
|
||||||
dirs, files = xbmcvfs.listdir(path)
|
dirs, files = xbmcvfs.listdir(path)
|
||||||
for dir in dirs:
|
for dir in dirs:
|
||||||
if dir.startswith('Emby'):
|
if dir.decode('utf-8').startswith('Emby'):
|
||||||
shutil.rmtree("%s%s" % (path, dir))
|
shutil.rmtree("%s%s" % (path, dir.decode('utf-8')))
|
||||||
for file in files:
|
for file in files:
|
||||||
if file.startswith('emby'):
|
if file.decode('utf-8').startswith('emby'):
|
||||||
xbmcvfs.delete("%s%s" % (path, file))
|
xbmcvfs.delete("%s%s" % (path, file.decode('utf-8')))
|
||||||
|
|
||||||
# Wipe the kodi databases
|
# Wipe the kodi databases
|
||||||
logMsg("EMBY", "Resetting the Kodi video database.")
|
logMsg("EMBY", "Resetting the Kodi video database.")
|
||||||
|
@ -223,7 +223,7 @@ def stopProfiling(pr, profileName):
|
||||||
timestamp = time.strftime("%Y-%m-%d %H-%M-%S")
|
timestamp = time.strftime("%Y-%m-%d %H-%M-%S")
|
||||||
profile = "%s%s_profile_(%s).tab" % (profiles, profileName, timestamp)
|
profile = "%s%s_profile_(%s).tab" % (profiles, profileName, timestamp)
|
||||||
|
|
||||||
f = open(profile, 'wb')
|
f = xbmcvfs.File(profile, 'w')
|
||||||
f.write("NumbCalls\tTotalTime\tCumulativeTime\tFunctionName\tFileName\r\n")
|
f.write("NumbCalls\tTotalTime\tCumulativeTime\tFunctionName\tFileName\r\n")
|
||||||
for (key, value) in ps.stats.items():
|
for (key, value) in ps.stats.items():
|
||||||
(filename, count, func_name) = key
|
(filename, count, func_name) = key
|
||||||
|
@ -471,7 +471,7 @@ def playlistXSP(mediatype, tagname, viewtype="", delete=False):
|
||||||
}
|
}
|
||||||
logMsg("EMBY", "Writing playlist file to: %s" % xsppath, 1)
|
logMsg("EMBY", "Writing playlist file to: %s" % xsppath, 1)
|
||||||
try:
|
try:
|
||||||
f = open(xsppath, 'w')
|
f = xbmcvfs.File(xsppath, 'w')
|
||||||
except:
|
except:
|
||||||
logMsg("EMBY", "Failed to create playlist: %s" % xsppath, 1)
|
logMsg("EMBY", "Failed to create playlist: %s" % xsppath, 1)
|
||||||
return
|
return
|
||||||
|
@ -495,5 +495,5 @@ def deletePlaylists():
|
||||||
path = xbmc.translatePath("special://profile/playlists/video/").decode('utf-8')
|
path = xbmc.translatePath("special://profile/playlists/video/").decode('utf-8')
|
||||||
dirs, files = xbmcvfs.listdir(path)
|
dirs, files = xbmcvfs.listdir(path)
|
||||||
for file in files:
|
for file in files:
|
||||||
if file.startswith('Emby'):
|
if file.decode('utf-8').startswith('Emby'):
|
||||||
xbmcvfs.delete("%s%s" % (path, file))
|
xbmcvfs.delete("%s%s" % (path, file))
|
Loading…
Reference in a new issue