2015-10-02, 17:28
so i seem to be having some problems with a piece of code ive written that uses openloads api to get a video url, it seems to be hanging kodi, i've tested on my Mac, PC and Pi and it hangs for a few seconds (the loading spinner freezes) and then the video plays, but on some Android devices the hang cause the app to crash, just wondering if anyone has any idea on what might be causing this, i've included the code snippet below, and i think its hanging around the first getURL function (which just loads a html file and works fine throughout the rest of the app) and the json.loads section... would be interested if anyone has any thoughts on it.
Code:
download=util.extract(videourl, "https://openload.co/embed/", "/")
ol=util.getURL('https://api.openload.io/1/file/dlticket?file='+download+"&login=<api-login>&key=<api-key>", hdr)
jsonResponse=json.loads(ol)
if jsonResponse['status']!=200:
util.alert(str(jsonResponse['msg']))
else:
if jsonResponse['result']['captcha_url']!='false':
if jsonResponse['result']['wait_time']>0:
pDialog=util.progressStart("Waiting", "Fetching Video. Please Wait.")
x=1
for x in range (1, jsonResponse['result']['wait_time']):
time.sleep(1)
util.progressUpdate(pDialog, int((float(x)/jsonResponse['result']['wait_time'])*100), "Fetching Video. Please Wait.")
x+=1
util.progressStop(pDialog)
ol=util.getURL('https://api.openload.io/1/file/dl?file='+download+'&ticket='+jsonResponse['result']['ticket'], hdr)
jsonResponse=json.loads(ol)
if jsonResponse['status']!=200:
util.alert(str(jsonResponse['msg']))
xbmc.log(str(jsonResponse['msg']), xbmc.LOGERROR)
else:
videourl=jsonResponse['result']['url']
util.playMedia(params['filename'], params['poster_file'],videourl, "Video")
else:
util.alert("Haven't implemented the CAPATCHA sorry.")