Kodi Community Forum
How to handle files on library SMB locations in python? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: How to handle files on library SMB locations in python? (/showthread.php?tid=211821)



How to handle files on library SMB locations in python? - vidarak - 2014-12-19

If this is too noob question for experienced developers I apologize upfront. I'm not really a developer. I just want so bad to fix the chapter/scene selector script that 999unreal modified (http://forum.kodi.tv/showthread.php?tid=163190&pid=1857449#pid1857449) to work with SMB paths as I have all my content stored on SMB shares.

Question: Does anyone know how to check for and open files on existing SMB connections in python?

Current script code:
Code:
if os.path.exists(movieHalfPath.decode('utf-8') + ".chapter.xml"):
            chaptersFile = (movieHalfPath + ".chapter.xml")

This fails for SMB paths...


RE: How to handle files on library SMB locations in python? - Martijn - 2014-12-19

http://mirrors.xbmc.org/docs/python-docs/13.0-gotham/xbmcvfs.html#-exists


RE: How to handle files on library SMB locations in python? - Lunatixz - 2014-12-20

Use Xbmcvfs


RE: How to handle files on library SMB locations in python? - pkscout - 2014-12-20

So the slightly longer answer is that the python module os doesn't understand network directories. The Kodi folks have written an abstraction layer so that programers don't have to worry about the various possible file systems available, and one of the things that abstraction layer (xbmcvfs) supports in SMB volumes. So, as Lunatixz indicated, use the xbmcvfs module for any file calls, and that would do it. Now finding all the file calls is another story all together...


RE: How to handle files on library SMB locations in python? - vidarak - 2014-12-20

Thanks guys. I was able to sort it out using xbmcvfs in the chapter add-on.