Esempio n. 1
0
def login():
    global authorization_url, language, api_url
    content = connect.load_netflix_site(main_url + 'Login',
                                        new_session=True,
                                        login_process=True)
    if not 'Sorry, Netflix ' in content:

        set_auth_url(connect.try_to_read_auth_url(content))
        match = re.compile('locale: "(.+?)"', re.DOTALL).findall(content)
        language = match[0]
        authorization_url = connect.try_to_read_auth_url(content)

        post_data = {
            'authURL': authorization_url,
            'email': email,
            'password': password,
            'RememberMe': 'on'
        }
        content = connect.load_netflix_site(main_url + 'Login?locale=' +
                                            language,
                                            post=post_data,
                                            login_process=True)
        if 'id="page-LOGIN"' in content:
            return False
        set_api_url(content)
        authorization_url = connect.try_to_read_auth_url(content)
        dump_login_content(content)
        return True
    else:
        return False
Esempio n. 2
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
Esempio n. 3
0
def search_results(search_string):
    post_data = '{"paths":[["search","%s",{"from":0,"to":48},["summary","title"]],["search","%s",["id","length",' \
                '"name","trackIds","requestId"]]],"authURL":"%s"}' % (search_string, search_string,
                                                                      generic_utility.get_setting('authorization_url'))
    content = connect.load_netflix_site(generic_utility.evaluator(),
                                        post=post_data)
    return content
Esempio n. 4
0
def videos_matches(video_type, page, url):
    post_data = ''
    if not xbmcvfs.exists(generic_utility.cookies_file()):
        login.login()

    items_per_page = int(generic_utility.get_setting('items_per_page'))
    off_from = page * items_per_page
    off_to = off_from + items_per_page - 2

    if 'genre' in url:
        post_data = generic_utility.genre % (
            url.split('?')[1], off_from, off_to,
            generic_utility.get_setting('authorization_url'))
    elif 'list?' in url:
        data = url.split('?')[1]
        if ('mylist' in data):
            list_id = data.split('&')[0]
        else:
            list_id = data
        post_data = generic_utility.list_paths % (
            list_id, off_from, off_to,
            generic_utility.get_setting('authorization_url'))

    target_url = generic_utility.evaluator()
    response = connect.load_netflix_site(target_url, post=post_data)
    #    utility.log('response: '+response)
    video_ids = extract_other_video_ids(response, video_type)
    return video_ids
Esempio n. 5
0
def add_dynamic_lists(video_type):
    content = connect.load_netflix_site("https://www.netflix.com/")
    falkor_cache = generic_utility.parse_falkorcache(content)

    for list in read_lists(falkor_cache):
        add.directory(list['name'], 'list?' + list['id'], 'list_videos', '',
                      video_type)
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']
Esempio n. 7
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']
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']
Esempio n. 9
0
def video_playback_info(video_ids):
    ids_str = ''
    for video_id in video_ids:
        ids_str+='"'+video_id+'",'
    ids_str = ids_str[:-1]
    post_data = generic_utility.video_playback_info % (ids_str, generic_utility.get_setting('authorization_url'))
    content = connect.load_netflix_site(generic_utility.evaluator(), post=post_data)
    return content
def login():
    global authorization_url, language, api_url
    content = connect.load_netflix_site(main_url + 'Login', new_session=True)
    if not 'Sorry, Netflix ' in content:
        set_auth_url(content)
        match = re.compile('locale: "(.+?)"', re.DOTALL).findall(content)
        language = match[0]
        post_data = {'authURL': authorization_url, 'email': email,
                     'password': password, 'RememberMe': 'on'}
        content = connect.load_netflix_site(main_url + 'Login?locale=' + language,
                                            post=post_data)
        if 'id="page-LOGIN"' in content:
            return False
        set_api_url(content)
        dump_login_content(content)
        return True
    else:
        return False
Esempio n. 11
0
def genre_info(video_type):
    post_data = ''
    if video_type == 'tv':
        post_data = generic_utility.series_genre % generic_utility.get_setting('authorization_url')
    elif video_type == 'movie':
        post_data = generic_utility.movie_genre % generic_utility.get_setting('authorization_url')
    else:
        pass
    content = connect.load_netflix_site(generic_utility.evaluator(), post=post_data)
    return content
Esempio n. 12
0
def genre_info(video_type):
    post_data = ''
    if video_type == 'show':
        post_data = generic_utility.series_genre % generic_utility.get_setting('authorization_url')
    elif video_type == 'movie':
        post_data = generic_utility.movie_genre % generic_utility.get_setting('authorization_url')
    else:
        pass
    content = connect.load_netflix_site(generic_utility.evaluator(), post=post_data, headers={"Content-Type":"application/json"})
    return content
Esempio n. 13
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.get_setting('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
Esempio n. 14
0
def video_info(video_id, lock = None, ignore_cache = False):
    content = ''
    cache_file = xbmc.translatePath(generic_utility.cache_dir() + video_id + '.cache')
    if not ignore_cache and xbmcvfs.exists(cache_file):
        file_handler = xbmcvfs.File(cache_file, 'rb')
        content = generic_utility.decode(file_handler.read())
        file_handler.close()
    if not content:
        post_data = generic_utility.video_info % (video_id, video_id, video_id, video_id,
                                                  generic_utility.get_setting('authorization_url'))
        content = connect.load_netflix_site(generic_utility.evaluator(), post=post_data, lock = lock)
        file_handler = xbmcvfs.File(cache_file, 'wb')
        file_handler.write(generic_utility.encode(content))
        file_handler.close()
    return content
Esempio n. 15
0
def videos_matches(video_type, page, url):
    post_data = ''

    items_per_page = int(generic_utility.get_setting('items_per_page'))
    off_from = page * items_per_page
    off_to = off_from + items_per_page - 2

    if 'genre' in url:
        post_data = generic_utility.genre % (url.split('?')[1], off_from, off_to, generic_utility.get_setting('authorization_url'))
    elif 'list?' in url:
        data = url.split('?')[1]
        if('mylist' in data):
            list_id = data.split('&')[0]
        else:
            list_id = data
        post_data = generic_utility.list_paths % (list_id, off_from, off_to, generic_utility.get_setting('authorization_url'))

    target_url = generic_utility.evaluator()
    response = connect.load_netflix_site(target_url, post=post_data)
#    utility.log('response: '+response)
    video_ids = extract_other_video_ids(response, video_type)
    return video_ids
Esempio n. 16
0
def track_id_list(list):
    post_data = '{"paths":[["lists","%s","trackIds"]],"authURL":"%s"}' % (list, generic_utility.get_setting('authorization_url'))
    content = connect.load_netflix_site(generic_utility.evaluator(), post=post_data)
    return content
Esempio n. 17
0
def viewing_activity_info():
    content = connect.load_netflix_site(generic_utility.activity_url % (generic_utility.get_setting('api_url'),
                                                                        generic_utility.get_setting(
                                                                                   'authorization_url')))
    return content
Esempio n. 18
0
def search_results(search_string):
    post_data = '{"paths":[["search","%s",{"from":0,"to":48},["summary","title"]],["search","%s",["id","length",' \
                '"name","trackIds","requestId"]]],"authURL":"%s"}' % (search_string, search_string,
                                                                      generic_utility.get_setting('authorization_url'))
    content = connect.load_netflix_site(generic_utility.evaluator(), post=post_data)
    return content
if do_login:
    if real_login:
        if login()==True:
            print 'login successfull'
        else:
            print 'login failed!'
            exit()
    else:
        print 'loading data from disk'
        content = read_login_content()
        set_api_url(content)
        authorization_url = sys.argv[3]


#profile-switcher
content = connect.load_netflix_site('https://www.netflix.com/api/shakti/7ffaa772/profiles/switch?switchProfileGuid=HC2AFIZSMRHCDPZ76LZZRENGSI&authURL=%s' % authorization_url)

############################################################################
############################################################################

sleep(1)

#content = connect.load_netflix_site("http://www.netflix.com/browse", new_session=False)
#pprint.pprint(content)
#falkor_cache = generic_utility.parse_falkorcache(content)
#pprint.pprint(falkor_cache['videos'])


#list = '402ccb6f-4c0f-47b5-8d6e-906f40b16b16_8101754'

post = '{"paths":['
Esempio n. 20
0
if do_login:
    if real_login:
        if login() == True:
            print 'login successfull'
        else:
            print 'login failed!'
            exit()
    else:
        print 'loading data from disk'
        content = read_login_content()
        set_api_url(content)
        authorization_url = sys.argv[3]

#profile-switcher
content = connect.load_netflix_site(
    'https://www.netflix.com/api/shakti/7ffaa772/profiles/switch?switchProfileGuid=HC2AFIZSMRHCDPZ76LZZRENGSI&authURL=%s'
    % authorization_url)

############################################################################
############################################################################

sleep(1)

#content = connect.load_netflix_site("http://www.netflix.com/browse", new_session=False)
#pprint.pprint(content)
#falkor_cache = generic_utility.parse_falkorcache(content)
#pprint.pprint(falkor_cache['videos'])

#list = '402ccb6f-4c0f-47b5-8d6e-906f40b16b16_8101754'

post = '{"paths":['
Esempio n. 21
0
def add_dynamic_lists(video_type):
    content = connect.load_netflix_site("https://www.netflix.com/")
    falkor_cache = generic_utility.parse_falkorcache(content)

    for list in read_lists(falkor_cache):
        add.directory(list['name'], 'list?'+list['id'], 'list_videos', '', video_type)