2014-09-13, 11:13
i am trying to create an addon that given a list of paths will scan for new tv episodes
the problem i am facing is the scan does not seem to be working properly.
I have it at the moment where it does scan each path, but think its not waiting for
previous path to finish scanning, hence i think its not working properely.
can anyone help.
thanks
the problem i am facing is the scan does not seem to be working properly.
I have it at the moment where it does scan each path, but think its not waiting for
previous path to finish scanning, hence i think its not working properely.
Code:
import sys
import os
import subprocess
import xbmc, xbmcaddon,xbmcgui
xaddon = xbmcaddon.Addon(id='script.runmyscan')
addonpath = xaddon.getAddonInfo('path')
if xbmc.getCondVisibility('Library.IsScanning'):
dialog = xbmcgui.Dialog()
dialog.ok('Scanning..', "Scan is already running. Stop Current Scan and try again")
else:
text_file = open(addonpath + "/paths.txt", "r")
#lines = text_file.readlines()
lines = text_file.read().split('\n')
print lines
for path in lines:
#print path
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "params": {"directory": "' + path + '" }, "id": 1 }}')
xbmc.sleep(200)
while xbmc.getCondVisibility('Library.IsScanning'):
xbmc.sleep(200)
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": 1 }}')
can anyone help.
thanks