Ejemplo n.º 1
0
def req_path(*paths):
    from resources import connect

    auth_url = generic_utility.auth_url()
    api_url = generic_utility.api_url()

    if not auth_url or not api_url:
        connect.do_login()

    post = '{"paths":['
    for curpath in paths:
        post += curpath + ','
    post = post[:-1]
    post += '],"authURL":"%s"}' % auth_url

    content = connect.load_netflix_site(
        '%s/pathEvaluator?materialize=true&model=harris' % api_url, post)
    jsn = json.loads(content)
    if 'error' in jsn:
        err = jsn['error']
        if 'innerErrors' in err:
            inners = err['innerErrors']
            for inner_err in inners:
                if 'message' in inner_err:
                    msg = inner_err['message']
                    if 'Map cache miss' == msg:
                        raise CacheMissException(content)
        raise Exception('Invalid path response: ' + content)
    if 'value' not in jsn:
        raise Exception('Invalid path response: ' + content)

    return jsn['value']
Ejemplo n.º 2
0
def req_json_path(*paths):
    from resources import connect

    auth_url = generic_utility.auth_url()
    api_url = generic_utility.api_url()

    if not auth_url or not api_url:
        connect.do_login()

    post = '{"paths":['
    for curpath in paths:
        post += curpath + ','
    post = post[:-1]
    post += '],"authURL":"%s"}' % auth_url

    content = connect.load_netflix_site(
        generic_utility.evaluator_url % (api_url),
        post,
        headers={"Content-Type": "application/json"})
    jsn = json.loads(content)
    if 'error' in jsn:
        err = jsn['error']
        if 'innerErrors' in err:
            inners = err['innerErrors']
            for inner_err in inners:
                if 'message' in inner_err:
                    msg = inner_err['message']
                    if 'Map cache miss' == msg:
                        raise CacheMissException(content)
        raise Exception('Invalid path response: ' + content)
    if 'value' not in jsn:
        raise Exception('Invalid path response: ' + content)

    return jsn['value']
Ejemplo n.º 3
0
def req_path(*paths):
    from resources import connect

    auth_url = generic_utility.auth_url()
    api_url = generic_utility.api_url()

    if not auth_url or not api_url:
        connect.do_login()

    post = '{"paths":['
    for curpath in paths:
        post += curpath+','
    post = post[:-1]
    post += '],"authURL":"%s"}' % auth_url

    content = connect.load_netflix_site('%s/pathEvaluator?materialize=true&model=harris' % api_url, post)
    jsn = json.loads(content)
    if 'error' in jsn:
        err = jsn['error']
        if 'innerErrors' in err:
            inners = err['innerErrors']
            for inner_err in inners:
                if 'message' in inner_err:
                    msg = inner_err['message']
                    if 'Map cache miss' == msg:
                        raise CacheMissException(content)
        raise Exception('Invalid path response: ' + content)
    if 'value' not in jsn:
        raise Exception('Invalid path response: ' + content)

    return jsn['value']
Ejemplo n.º 4
0
def series_info(series_id):
    content = ''
    cache_file = xbmc.translatePath(generic_utility.cache_dir() + series_id + '_episodes.cache')
    if xbmcvfs.exists(cache_file) and (time.time() - xbmcvfs.Stat(cache_file).st_mtime() < 60 * 5):
        file_handler = xbmcvfs.File(cache_file, 'rb')
        content = generic_utility.decode(file_handler.read())
        file_handler.close()
    if not content:
        url = generic_utility.series_url % (generic_utility.api_url(), series_id)
        content = connect.load_netflix_site(url)
        file_handler = xbmcvfs.File(cache_file, 'wb')
        file_handler.write(generic_utility.encode(content))
        file_handler.close()
    return content
Ejemplo n.º 5
0
def viewing_activity_info():
    content = connect.load_netflix_site(
        generic_utility.activity_url %
        (generic_utility.api_url(),
         generic_utility.get_setting('authorization_url')))
    return content