Solved Copying a file from smb share at startup (autoexec.py)
#1
Does anyone know how to achieve the problem outlined in the title?  I came up with the below:

python:
import xbmcvfs
from shutil import copy
source = "smb://192.168.0.3/tv01/Movies_MultiFormat.xsp"
target = xbmcvfs.translatePath('special://home/userdata/playlists/video/')
copy(source, target)

but it seems the python environment isn't smb capable because I get this exception in the log:

[Errno 2] No such file or directory: 'smb://192.168.0.3/tv01/Movies_MultiFormat.xsp' 

Why do I want to do this?  I have a smart playlist which I regenerate a few times a day via a scheduled task.  This playlist is used to keep track of which movies are available in multiple resolutions e.g. 1080p, 4k.  This playlist can then be used, in combination with a few others, to make sure that devices show only one version of these movies - the version that they are capable of playing.  While I had only Nvidia Shield devices, I got around this by getting my scheduled script to copy the files to the Kodi device (Shield has an SMB server).  Now I have devices which don't have an smb server (e.g. Firesticks) and now I need a way to have each Kodi client pull this playlist from a central location.  autoexec.py seemed like the obvious solution but I'm stuck on getting it to speak smb.

Any pointers would be greatly appreciated!
Reply
#2
use the copy function from xbmcvfs instead, it is smb:// friendly

https://romanvm.github.io/Kodistubs/_aut...mcvfs.html
Reply
#3
Thank you!  Got it working thanks to your advice.  I've re-arranged things on my server so that the share it's pulling from is more sensibly named.  Also turned out my target path was incorrect so fixed that too.  Working code:

python:
import xbmcvfs
source = "smb://username:[email protected]/KodiFiles/Playlists/video/Movies_MultiFormat.xsp"
target = xbmcvfs.translatePath('special://profile/playlists/video/Movies_MultiFormat.xsp')
xbmcvfs.copy(source, target)
Reply

Logout Mark Read Team Forum Stats Members Help
Copying a file from smb share at startup (autoexec.py)0