mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-24 17: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:
|
||||
allDirs, allFiles = xbmcvfs.listdir(path+dir)
|
||||
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
|
||||
textureconnection = utils.kodiSQL('texture')
|
||||
|
|
|
@ -7,6 +7,7 @@ from uuid import uuid4
|
|||
|
||||
import xbmc
|
||||
import xbmcaddon
|
||||
import xbmcvfs
|
||||
|
||||
import utils
|
||||
|
||||
|
@ -43,7 +44,7 @@ class ClientInfo():
|
|||
|
||||
if utils.settings('deviceNameOpt') == "false":
|
||||
# Use Kodi's deviceName
|
||||
deviceName = xbmc.getInfoLabel('System.FriendlyName')
|
||||
deviceName = xbmc.getInfoLabel('System.FriendlyName').decode('utf-8')
|
||||
else:
|
||||
deviceName = utils.settings('deviceName')
|
||||
deviceName = deviceName.replace("\"", "_")
|
||||
|
@ -78,12 +79,12 @@ class ClientInfo():
|
|||
GUID_file = xbmc.translatePath(os.path.join(addon_path, "machine_guid")).decode('utf-8')
|
||||
|
||||
try:
|
||||
GUID = open(GUID_file)
|
||||
GUID = xbmcvfs.File(GUID_file)
|
||||
|
||||
except Exception as e: # machine_guid does not exists.
|
||||
self.logMsg("Generating a new deviceid: %s" % e, 1)
|
||||
clientId = str("%012X" % uuid4())
|
||||
GUID = open(GUID_file, 'w')
|
||||
GUID = xbmcvfs.File(GUID_file, 'w')
|
||||
GUID.write(clientId)
|
||||
|
||||
else: # machine_guid already exists. Get guid.
|
||||
|
|
|
@ -283,7 +283,7 @@ def getThemeMedia():
|
|||
result = doUtils.downloadUrl(url)
|
||||
|
||||
# Create nfo and write themes to it
|
||||
nfo_file = open(nfo_path, 'w')
|
||||
nfo_file = xbmcvfs.File(nfo_path, 'w')
|
||||
pathstowrite = ""
|
||||
# May be more than one theme
|
||||
for theme in result['Items']:
|
||||
|
@ -344,7 +344,7 @@ def getThemeMedia():
|
|||
result = doUtils.downloadUrl(url)
|
||||
|
||||
# Create nfo and write themes to it
|
||||
nfo_file = open(nfo_path, 'w')
|
||||
nfo_file = xbmcvfs.File(nfo_path, 'w')
|
||||
pathstowrite = ""
|
||||
# May be more than one theme
|
||||
for theme in result['Items']:
|
||||
|
@ -960,12 +960,12 @@ def getExtraFanArt():
|
|||
try:
|
||||
# for tvshows we get the embyid just from the path
|
||||
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:
|
||||
embyId = itemPath.split("/")[-2]
|
||||
else:
|
||||
#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:
|
||||
params = urlparse.parse_qs(itemPath)
|
||||
embyId = params.get('id')
|
||||
|
@ -1003,7 +1003,7 @@ def getExtraFanArt():
|
|||
# Use existing cached images
|
||||
dirs, files = xbmcvfs.listdir(fanartDir)
|
||||
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)
|
||||
xbmcplugin.addDirectoryItem(
|
||||
handle=int(sys.argv[1]),
|
||||
|
|
|
@ -45,10 +45,10 @@ def window(property, value=None, clear=False, windowid=10000):
|
|||
|
||||
if clear:
|
||||
WINDOW.clearProperty(property)
|
||||
elif value is not None:
|
||||
WINDOW.setProperty(property, value)
|
||||
else:
|
||||
return WINDOW.getProperty(property)
|
||||
elif value is not None: #setproperty accepts both string and unicode but utf-8 string seems best practice to pass
|
||||
WINDOW.setProperty(property.encode("utf-8"), value.encode("utf-8"))
|
||||
else: #getproperty returns string so convert to unicode
|
||||
return WINDOW.getProperty(property).decode("utf-8")
|
||||
|
||||
def settings(setting, value=None):
|
||||
# Get or add addon setting
|
||||
|
@ -138,11 +138,11 @@ def reset():
|
|||
path = xbmc.translatePath("special://profile/library/video/").decode('utf-8')
|
||||
dirs, files = xbmcvfs.listdir(path)
|
||||
for dir in dirs:
|
||||
if dir.startswith('Emby'):
|
||||
shutil.rmtree("%s%s" % (path, dir))
|
||||
if dir.decode('utf-8').startswith('Emby'):
|
||||
shutil.rmtree("%s%s" % (path, dir.decode('utf-8')))
|
||||
for file in files:
|
||||
if file.startswith('emby'):
|
||||
xbmcvfs.delete("%s%s" % (path, file))
|
||||
if file.decode('utf-8').startswith('emby'):
|
||||
xbmcvfs.delete("%s%s" % (path, file.decode('utf-8')))
|
||||
|
||||
# Wipe the kodi databases
|
||||
logMsg("EMBY", "Resetting the Kodi video database.")
|
||||
|
@ -223,7 +223,7 @@ def stopProfiling(pr, profileName):
|
|||
timestamp = time.strftime("%Y-%m-%d %H-%M-%S")
|
||||
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")
|
||||
for (key, value) in ps.stats.items():
|
||||
(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)
|
||||
try:
|
||||
f = open(xsppath, 'w')
|
||||
f = xbmcvfs.File(xsppath, 'w')
|
||||
except:
|
||||
logMsg("EMBY", "Failed to create playlist: %s" % xsppath, 1)
|
||||
return
|
||||
|
@ -495,5 +495,5 @@ def deletePlaylists():
|
|||
path = xbmc.translatePath("special://profile/playlists/video/").decode('utf-8')
|
||||
dirs, files = xbmcvfs.listdir(path)
|
||||
for file in files:
|
||||
if file.startswith('Emby'):
|
||||
if file.decode('utf-8').startswith('Emby'):
|
||||
xbmcvfs.delete("%s%s" % (path, file))
|
Loading…
Reference in a new issue