kodi hanging issue
#1
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.")
Reply
#2
While the problem is kinda interesting, it's not in the interest of the Kodi.org forum to explain how to access videos on a site that well-known for pirated videos.
It would be better to ask in a forum outside of this one.
Reply
#3
fair deuce, although the argument could be had that regardless of how the code is to be used why wouldnt you discuss a legitamate video API on a media center forum (i'm sure theres YouTube discussions and such on here) and/or the cause of it hanging it Kodi?
but, cool beans

EDIT: i lol'd hard after returning to the Addon On's development plugin and seeing the thread below for the urlresolver module with 25 pages of comments XXXD
Reply
#4
Doesn't really change the conversation does it? I'm as guilty as the next with my addons - the point is this forum is a hotel and not a whorehouse, we have to respect the management or get called on it.

EDIT: urlresolver is someone else's doing, call it out if you wish, but don't make it an excuse.
Reply
#5
But to answer your question, a place to start looking is Android supports Python 2.6, whereas everything else is 2.7. Something not shown above probably has an issue with that,
Reply
#6
personally i think it does, because otherwise we're saying we can't discuss any 3rd party file storing service, kodi's sole use is if you store your files locally or on your own server
Reply
#7
(2015-10-02, 19:18)ptom Wrote: personally i think it does, because otherwise we're saying we can't discuss any 3rd party file storing service, kodi's sole use is if you store your files locally or on your own server

Well, it depends on why you're asking. It's a huge image problem for the Kodi project. Looking at your previous posts and trying not to judge, I don't think you're trying to access home movies of your kids. The issue is stated here:
Free_content (wiki)
Reply
#8
lol, so your issue isnt with the question but with me XXD thats fine but just say that to start with jeez <_<
in that arguement i completely agree, even if i was on here asking about how to write an IF statement then your point would be valid, but to take the stance of any online file storage that provides API is bad if someone once uploaded a dodgy video to it defeats the whole purpose of kodi surely?

anyways, its an odd one for sure been testing and it looks like it may be the retrieving the file storing the json string to the video url issued by openload itself, but i can't imagine why that would cause it to hang as getURL is a fairly basic function and doesn't throw any issue up elsewhere

Code:
ol=util.getURL('https://api.openload.io/1/file/dl?file='+download+'&ticket='+jsonResponse['result']['ticket'], hdr)

Code:
def getURL(url, header):
    try:
        req = urllib2.Request(url, headers=header)
        response = urllib2.urlopen(req)
        if response and response.getcode() == 200:
            if response.info().get('Content-Encoding') == 'gzip':
                buf = StringIO.StringIO( response.read())
                gzip_f = gzip.GzipFile(fileobj=buf)
                content = gzip_f.read()
            else:
                content = response.read()
            content = content.decode('utf-8', 'ignore')
            return content
        return False
    except:
        xbmc.log('Error Loading URL (Error: '+str(response.getcode())+' Encoding:'+response.info().get('Content-Encoding')+'): '+url, xbmc.LOGERROR)
        xbmc.log('Content: '+response.read(), xbmc.LOGERROR)
        return False
Reply
#9
I have absolutely no issue with any of that, just yanking your chain. I just don't think we need to make it any easier for folks to build things which tarnish the Kodi reputation - in the piracy sense.

Do you actually get to the getURL? I don't know what's coming back from the jsonResponse, but you may need to urlencode it depending on what's returned.

You can try changing getURL to something like this:
Code:
import zlib

USER_AGENT    = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36'
defaultHeaders = {'User-Agent':USER_AGENT, 'Accept':"text/html", 'Accept-Encoding':'gzip,deflate,sdch', 'Accept-Language':'en-US,en;q=0.8'}

def getURL(url, headers = defaultHeaders):

   req = urllib2.Request(url.encode(UTF8), None, headers)
   try:
      response = urllib2.urlopen(req)
      page = response.read()
      if response.info().getheader('Content-Encoding') == 'gzip':
         page = zlib.decompress(page, zlib.MAX_WBITS + 16)
   except:
      page = False
   return(page)

I know this works with 2.6 and I don't believe the code you have has an issue, but it may be worth a try. If you're crashing, could it be because of the content = content.decode('utf-8', 'ignore') ? I usually have to wrap this with a try .. except. Or possibly, but unlikely, the Android box/stick running out of RAM during the unzip?
Reply

Logout Mark Read Team Forum Stats Members Help
kodi hanging issue0