2006-01-07, 07:35
hi,
i am having some trouble getting python to play a file with special characters in the name. here is the path that is trying to play:
xbms://192.168.0.1/tv3_alla älskar raymond_200512061440p3919.mpg
the problem was originally found because an exception was being thrown when i was trying to convert it to an ascii string to use in the xbmc.player().play() command as it does not seem to work unless i format the variable as a string. eg:
fnamenew = "xbms://" + mpsettings.ip + "/" + fnamenew[1]
p = xbmc.player()
p.play(str(fnamenew))
to get around this problem i am encoding the variable to utf-8 which works fine for all files without any special characters using the following:
fnamenew = "xbms://" + mpsettings.ip + "/" + fnamenew[1]
p = xbmc.player()
p.play(fnamenew.encode('utf_8'))
the variable is taken from an xml string which was already utf-8 encoded so it should be fine.
however now after converting the string to utf-8 i get an error in xbmc error log saying that the file can not be found. the log file has a different filename in it as it mis-represents the special character; this may be an issue with the encoding of the log though, not sure. i have checked what is passed to the emulation script on my dev machine and it prints out the path that i have included at the start of my problem.
i had a quick look at using the http api but could not get it to work. the file plays fine if i browse to it using my videos.
i am new to all this language and encoding stuff so any help would be greatly appreciated.
i am having some trouble getting python to play a file with special characters in the name. here is the path that is trying to play:
xbms://192.168.0.1/tv3_alla älskar raymond_200512061440p3919.mpg
the problem was originally found because an exception was being thrown when i was trying to convert it to an ascii string to use in the xbmc.player().play() command as it does not seem to work unless i format the variable as a string. eg:
fnamenew = "xbms://" + mpsettings.ip + "/" + fnamenew[1]
p = xbmc.player()
p.play(str(fnamenew))
to get around this problem i am encoding the variable to utf-8 which works fine for all files without any special characters using the following:
fnamenew = "xbms://" + mpsettings.ip + "/" + fnamenew[1]
p = xbmc.player()
p.play(fnamenew.encode('utf_8'))
the variable is taken from an xml string which was already utf-8 encoded so it should be fine.
however now after converting the string to utf-8 i get an error in xbmc error log saying that the file can not be found. the log file has a different filename in it as it mis-represents the special character; this may be an issue with the encoding of the log though, not sure. i have checked what is passed to the emulation script on my dev machine and it prints out the path that i have included at the start of my problem.
i had a quick look at using the http api but could not get it to work. the file plays fine if i browse to it using my videos.
i am new to all this language and encoding stuff so any help would be greatly appreciated.