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

    auth_url = generic_utility.auth_url()
    endpoints = generic_utility.endpoints()

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

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

    content = connect.load_netflix_site(generic_utility.evaluator_url % (generic_utility.api_url, endpoints['/pathEvaluator']), 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']
Exemplo n.º 2
0
def req_path(*paths):
    from resources import connect

    auth_url = generic_utility.auth_url()
    endpoints = generic_utility.endpoints()

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

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

    content = connect.load_netflix_site(
        generic_utility.evaluator_url %
        (generic_utility.api_url, endpoints['/pathEvaluator']), 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']
Exemplo n.º 3
0
def viewing_activity_info():
    content = connect.load_netflix_site(
        generic_utility.activity_url %
        (generic_utility.api_url,
         generic_utility.endpoints()['/viewingactivity'],
         generic_utility.get_setting('authorization_url')))
    return content
Exemplo 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, generic_utility.endpoints()['/metadata'], 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
Exemplo n.º 5
0
def viewing_activity_info():
    content = connect.load_netflix_site(generic_utility.activity_url % (generic_utility.api_url, generic_utility.endpoints()['/viewingactivity'],
                                                                        generic_utility.get_setting(
                                                                                'authorization_url')))
    return content