more unicode fixes: os.path functions use unicode depending on the OS
This commit is contained in:
parent
2bd1d139c1
commit
eae4fea76a
7 changed files with 30 additions and 13 deletions
|
@ -185,7 +185,10 @@ 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.decode('utf-8'),file.decode('utf-8')))
|
if os.path.supports_unicode_filenames:
|
||||||
|
xbmcvfs.delete(os.path.join(path+dir.decode('utf-8'),file.decode('utf-8')))
|
||||||
|
else:
|
||||||
|
xbmcvfs.delete(os.path.join(path.encode('utf-8')+dir,file))
|
||||||
|
|
||||||
# remove all existing data from texture DB
|
# remove all existing data from texture DB
|
||||||
textureconnection = utils.kodiSQL('texture')
|
textureconnection = utils.kodiSQL('texture')
|
||||||
|
|
|
@ -76,7 +76,10 @@ class ClientInfo():
|
||||||
return clientId
|
return clientId
|
||||||
|
|
||||||
addon_path = self.addon.getAddonInfo('path').decode('utf-8')
|
addon_path = self.addon.getAddonInfo('path').decode('utf-8')
|
||||||
GUID_file = xbmc.translatePath(os.path.join(addon_path, "machine_guid")).decode('utf-8')
|
if os.path.supports_unicode_filenames:
|
||||||
|
GUID_file = xbmc.translatePath(os.path.join(addon_path, "machine_guid")).decode('utf-8')
|
||||||
|
else:
|
||||||
|
GUID_file = xbmc.translatePath(os.path.join(addon_path.encode("utf-8"), "machine_guid")).decode('utf-8')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
GUID = xbmcvfs.File(GUID_file)
|
GUID = xbmcvfs.File(GUID_file)
|
||||||
|
|
|
@ -326,7 +326,7 @@ class DownloadUtils():
|
||||||
elif r.status_code == requests.codes.ok:
|
elif r.status_code == requests.codes.ok:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# UTF-8 - JSON object
|
# UNICODE - JSON object
|
||||||
r = r.json()
|
r = r.json()
|
||||||
self.logMsg("====== 200 Success ======", 2)
|
self.logMsg("====== 200 Success ======", 2)
|
||||||
self.logMsg("Response: %s" % r, 2)
|
self.logMsg("Response: %s" % r, 2)
|
||||||
|
|
|
@ -990,7 +990,10 @@ def getExtraFanArt():
|
||||||
for backdrop in backdrops:
|
for backdrop in backdrops:
|
||||||
# Same ordering as in artwork
|
# Same ordering as in artwork
|
||||||
tag = tags[count]
|
tag = tags[count]
|
||||||
fanartFile = os.path.join(fanartDir, "fanart%s.jpg" % tag)
|
if os.path.supports_unicode_filenames:
|
||||||
|
fanartFile = os.path.join(fanartDir, "fanart%s.jpg" % tag)
|
||||||
|
else:
|
||||||
|
fanartFile = os.path.join(fanartDir.encode("utf-8"), "fanart%s.jpg" % tag.encode("utf-8"))
|
||||||
li = xbmcgui.ListItem(tag, path=fanartFile)
|
li = xbmcgui.ListItem(tag, path=fanartFile)
|
||||||
xbmcplugin.addDirectoryItem(
|
xbmcplugin.addDirectoryItem(
|
||||||
handle=int(sys.argv[1]),
|
handle=int(sys.argv[1]),
|
||||||
|
|
|
@ -2208,8 +2208,10 @@ class Music(Items):
|
||||||
filename = API.getFilePath()
|
filename = API.getFilePath()
|
||||||
rating = 0
|
rating = 0
|
||||||
emby_rating = int(round(emby_rating, 0))
|
emby_rating = int(round(emby_rating, 0))
|
||||||
file_rating, comment = musicutils.getSongTags(filename)
|
|
||||||
|
|
||||||
|
#get file rating and comment tag from file itself.
|
||||||
|
#TODO: should we make this an optional setting if it impacts sync speed too much ?
|
||||||
|
file_rating, comment = musicutils.getSongTags(filename)
|
||||||
|
|
||||||
emby_dbitem = self.emby_db.getItem_byId(embyid)
|
emby_dbitem = self.emby_db.getItem_byId(embyid)
|
||||||
try:
|
try:
|
||||||
|
@ -2228,7 +2230,6 @@ class Music(Items):
|
||||||
elif file_rating is None and not currentvalue:
|
elif file_rating is None and not currentvalue:
|
||||||
return (emby_rating, comment)
|
return (emby_rating, comment)
|
||||||
|
|
||||||
file_rating = int(round(file_rating,0))
|
|
||||||
self.logMsg("getSongRatingAndComment --> embyid: %s - emby_rating: %s - file_rating: %s - current rating in kodidb: %s" %(embyid, emby_rating, file_rating, currentvalue))
|
self.logMsg("getSongRatingAndComment --> embyid: %s - emby_rating: %s - file_rating: %s - current rating in kodidb: %s" %(embyid, emby_rating, file_rating, currentvalue))
|
||||||
|
|
||||||
updateFileRating = False
|
updateFileRating = False
|
||||||
|
|
|
@ -72,7 +72,7 @@ class KodiMonitor(xbmc.Monitor):
|
||||||
self.logMsg("Method: %s Data: %s" % (method, data), 1)
|
self.logMsg("Method: %s Data: %s" % (method, data), 1)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
data = json.loads(data)
|
data = json.loads(data,'utf-8')
|
||||||
|
|
||||||
|
|
||||||
if method == "Player.OnPlay":
|
if method == "Player.OnPlay":
|
||||||
|
|
|
@ -19,15 +19,21 @@ def logMsg(msg, lvl=1):
|
||||||
def getRealFileName(filename):
|
def getRealFileName(filename):
|
||||||
#get the filename path accessible by python if possible...
|
#get the filename path accessible by python if possible...
|
||||||
isTemp = False
|
isTemp = False
|
||||||
|
|
||||||
if not xbmcvfs.exists(filename):
|
if not xbmcvfs.exists(filename):
|
||||||
logMsg( "File does not exist! %s" %(filename), 0)
|
logMsg( "File does not exist! %s" %(filename), 0)
|
||||||
return (False, "")
|
return (False, "")
|
||||||
|
|
||||||
|
#if we use os.path method on older python versions (sunch as some android builds), we need to pass arguments as string
|
||||||
|
if os.path.supports_unicode_filenames:
|
||||||
|
checkfile = filename
|
||||||
|
else:
|
||||||
|
checkfile = file.encode("utf-8")
|
||||||
|
|
||||||
# determine if our python module is able to access the file directly...
|
# determine if our python module is able to access the file directly...
|
||||||
if os.path.exists(filename):
|
if os.path.exists(checkfile):
|
||||||
filename = filename
|
filename = filename
|
||||||
elif os.path.exists(filename.replace("smb://","\\\\").replace("/","\\")):
|
elif os.path.exists(checkfile.replace("smb://","\\\\").replace("/","\\")):
|
||||||
filename = filename.replace("smb://","\\\\").replace("/","\\")
|
filename = filename.replace("smb://","\\\\").replace("/","\\")
|
||||||
else:
|
else:
|
||||||
#file can not be accessed by python directly, we copy it for processing...
|
#file can not be accessed by python directly, we copy it for processing...
|
||||||
|
@ -57,7 +63,7 @@ def getEmbyRatingFromKodiRating(rating):
|
||||||
|
|
||||||
def getSongTags(file):
|
def getSongTags(file):
|
||||||
# Get the actual ID3 tags for music songs as the server is lacking that info
|
# Get the actual ID3 tags for music songs as the server is lacking that info
|
||||||
rating = None
|
rating = 0
|
||||||
comment = ""
|
comment = ""
|
||||||
|
|
||||||
isTemp,filename = getRealFileName(file)
|
isTemp,filename = getRealFileName(file)
|
||||||
|
@ -84,12 +90,13 @@ def getSongTags(file):
|
||||||
else:
|
else:
|
||||||
logMsg( "Not supported fileformat or unable to access file: %s" %(filename))
|
logMsg( "Not supported fileformat or unable to access file: %s" %(filename))
|
||||||
|
|
||||||
if rating:
|
#the rating must be a round value
|
||||||
rating = int(round(rating,0))
|
rating = int(round(rating,0))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
#file in use ?
|
#file in use ?
|
||||||
logMsg("Exception in getSongTags %s" %e,0)
|
logMsg("Exception in getSongTags %s" %e,0)
|
||||||
|
return (None,"")
|
||||||
|
|
||||||
#remove tempfile if needed....
|
#remove tempfile if needed....
|
||||||
if isTemp: xbmcvfs.delete(filename)
|
if isTemp: xbmcvfs.delete(filename)
|
||||||
|
|
Loading…
Reference in a new issue