예제 #1
0
def add_or_remove(video_id, is_add):

    content = connect.load_netflix_site("https://www.netflix.com/")
    falkor_cache = generic_utility.parse_falkorcache(content)

    root_list, my_list = generic_utility.extract_mylist_id(falkor_cache)
    auth = generic_utility.get_setting('authorization_url')

    track_id = get_track_id(my_list)

    if is_add:
        add_or_remove_str = 'addToList'
        add_or_remove_msg = 'added'
    else:
        add_or_remove_str = 'removeFromList'
        add_or_remove_msg = 'removed'

    post = ('{"callPath":["lolomos","%s","%s"],"params":["%s",2,["videos",%s],%s,null,null],'+\
           '"authURL":"%s"}') % (root_list, add_or_remove_str, my_list, video_id, track_id, auth)

    content = connect.load_netflix_site(generic_utility.evaluator()+'&method=call', post, options=True)

    if '"invalidated"' in content:
        generic_utility.notification('Successfully '+add_or_remove_msg)
    elif 'already exists' in content:
        generic_utility.notification('already exists')

    generic_utility.debug('add to mylist content: '+content)
예제 #2
0
def login():
    if not test:
        login_progress = xbmcgui.DialogProgress()
        login_progress.create('Netflix', generic_utility.get_string(30200) + '...')
        generic_utility.progress_window(login_progress, 25, generic_utility.get_string(30201))
    content = connect.load_netflix_site(generic_utility.main_url + 'Login', new_session=True, login_process=True)
    if not 'Sorry, Netflix ' in content:

        match = re.compile('locale: "(.+?)"', re.DOTALL|re.UNICODE).findall(content)
        locale = None
        if(len(match)) == 0:
            match = re.compile('"pageName":"login","locale":"(.+?)"', re.DOTALL|re.UNICODE).findall(content)
            if(len(match)) == 0:
                generic_utility.error('Cannot find locale on page. content: '+content)
                login_url = 'Login'
            else:
                locale = match[0]
                login_url = 'Login?locale=' + locale
        else:
            locale = match[0]
            login_url = 'Login?locale=' + locale
        generic_utility.set_setting('language', locale)

        post_data = {'authURL': generic_utility.get_setting('authorization_url'), 'email': generic_utility.get_setting('username'),
                     'password': generic_utility.get_setting('password'), 'RememberMe': 'on'}
        if not test:
            generic_utility.progress_window(login_progress, 50, generic_utility.get_string(30202))

        content = connect.load_netflix_site(
            generic_utility.main_url + login_url,
            post=post_data, login_process=True)

        if 'id="page-LOGIN"' in content:
            if not test:
                generic_utility.notification(generic_utility.get_string(30303))
            return False

        parse_data_set_cookies(content)

        if not test:
            generic_utility.progress_window(login_progress, 75, generic_utility.get_string(30203))

        profile_selection()

        if login_progress:
            if not test:
                if not generic_utility.progress_window(login_progress, 100, generic_utility.get_string(30204)):
                    return False
                xbmc.sleep(500)
                login_progress.close()
        return True
    else:
        if not test:
            generic_utility.notification(generic_utility.get_string(30300))
            if login_progress:
                login_progress.close()
        return False
예제 #3
0
def switch_profile(profile_id, login_process = True):
    auth_id = generic_utility.get_setting('authorization_url')
    profile_switch_url = generic_utility.profile_switch() + 'switchProfileGuid=' + profile_id + '&authURL=' + auth_id
    ret = connect.load_netflix_site(profile_switch_url, login_process=login_process)
#    generic_utility.log('switch-profile: '+ret)

    content = connect.load_netflix_site('http://www.netflix.com/browse')

    connect.set_chrome_netflix_cookies()
예제 #4
0
def login():
    login_progress = xbmcgui.DialogProgress()
    login_progress.create('Netflix', generic_utility.get_string(30200) + '...')
    generic_utility.progress_window(login_progress, 25,
                                    generic_utility.get_string(30201))
    content = connect.load_netflix_site(generic_utility.main_url + 'Login',
                                        new_session=True)
    if not 'Sorry, Netflix ' in content:
        match = re.compile('name="authURL" value="(.+?)"',
                           re.DOTALL | re.UNICODE).findall(content)
        #        utility.log('Setting authorization url: ' + match[0])
        generic_utility.set_setting('authorization_url', match[0])
        match = re.compile('locale: "(.+?)"',
                           re.DOTALL | re.UNICODE).findall(content)
        generic_utility.set_setting('language', match[0])
        post_data = {
            'authURL': generic_utility.get_setting('authorization_url'),
            'email': generic_utility.get_setting('username'),
            'password': generic_utility.get_setting('password'),
            'RememberMe': 'on'
        }
        generic_utility.progress_window(login_progress, 50,
                                        generic_utility.get_string(30202))
        content = connect.load_netflix_site(
            generic_utility.main_url + 'Login?locale=' +
            generic_utility.get_setting('language'),
            post=post_data)
        #        utility.log(content)

        if 'id="page-LOGIN"' in content:
            generic_utility.notification(generic_utility.get_string(30303))
            return False
        match = re.compile('"apiUrl":"(.+?)",', re.UNICODE).findall(content)
        generic_utility.set_setting('api_url', match[0])

        connect.set_chrome_netflix_cookies()

        generic_utility.progress_window(login_progress, 75,
                                        generic_utility.get_string(30203))

        profile_selection()

        if login_progress:
            if not generic_utility.progress_window(
                    login_progress, 100, generic_utility.get_string(30204)):
                return False
            xbmc.sleep(500)
            login_progress.close()
        return True
    else:
        generic_utility.notification(generic_utility.get_string(30300))
        if login_progress:
            login_progress.close()
        return False
예제 #5
0
def switch_profile(profile_id, login_process=True):
    auth_id = generic_utility.get_setting('authorization_url')
    profile_switch_url = generic_utility.profile_switch(
    ) + 'switchProfileGuid=' + profile_id + '&authURL=' + auth_id
    ret = connect.load_netflix_site(profile_switch_url,
                                    login_process=login_process)
    #    generic_utility.log('switch-profile: '+ret)

    content = connect.load_netflix_site('http://www.netflix.com/browse')

    connect.set_chrome_netflix_cookies()
예제 #6
0
def choose():
    profiles = []
    content = connect.load_netflix_site(generic_utility.profile_url)
    #    generic_utility.log('choose: '+content)
    match = json.loads(content)['profiles']
    for item in match:
        profile = {
            'name': item['firstName'],
            'token': item['guid'],
            'is_kid': item['experience'] == 'jfk'
        }
        profiles.append(profile)
    if len(match) > 0:
        dialog = xbmcgui.Dialog()
        nr = dialog.select(generic_utility.get_string(30103),
                           [profile['name'] for profile in profiles])
        if nr >= 0:
            selected_profile = profiles[nr]
        else:
            selected_profile = profiles[0]

        switch_profile(selected_profile['token'])

        generic_utility.set_setting('selected_profile',
                                    selected_profile['token'])
        generic_utility.set_setting(
            'is_kid', 'true' if selected_profile['is_kid'] else 'false')
        generic_utility.set_setting('profile_name', selected_profile['name'])
    else:
        generic_utility.log('Choose profile: no profiles were found!',
                            loglevel=xbmc.LOGERROR)
예제 #7
0
def switch_profile(profile_id):
    auth_id = generic_utility.get_setting('authorization_url')
    profile_switch_url = generic_utility.profile_switch(
    ) + 'switchProfileGuid=' + profile_id + '&authURL=' + auth_id
    ret = connect.load_netflix_site(profile_switch_url)
    #    generic_utility.log('switch-profile: '+ret)
    connect.set_chrome_netflix_cookies()
예제 #8
0
def add_or_remove(video_id, is_add):
    root_list = get_root_list()

    my_list = get_mylist(root_list)[0]
    auth = generic_utility.get_setting('authorization_url')
    track_id = get.track_id_list(my_list)

    if is_add:
        add_or_remove_str = 'addToList'
        add_or_remove_msg = 'added'
    else:
        add_or_remove_str = 'removeFromList'
        add_or_remove_msg = 'removed'

    post = ('{"callPath":["lolomos","%s","%s"],"params":["%s",2,["videos",%s],%s,null,null],' +
            '"authURL":"%s"}') % (root_list, add_or_remove_str, my_list, video_id, track_id, auth)

    content = connect.load_netflix_site(generic_utility.evaluator()+'&method=call', post, options=True)

    jsn = json.loads(content)

    generic_utility.log('mylist: '+my_list)
    generic_utility.log(str(jsn))
    if '"invalidated"' in content:
        generic_utility.notification('Successfully '+add_or_remove_msg)
    elif 'already exists' in content:
        generic_utility.notification('already exists')

    generic_utility.debug('add to mylist content: '+content)
예제 #9
0
def refresh_data():
    content = connect.load_netflix_site('https://www.netflix.com/browse')
    parse_api_url(content)

    profl = generic_utility.get_setting('selected_profile')
    if not profl:
        if login():
            profl = generic_utility.get_setting('selected_profile')
    if not profl:
        raise CannotRefreshDataException

    try:
        profiles.switch_profile(profl)
    except ValueError as vex:
        raise CannotRefreshDataException(vex)

    content = connect.load_netflix_site(generic_utility.main_url)

    parse_data_set_cookies(content)
예제 #10
0
def login():
    login_progress = xbmcgui.DialogProgress()
    login_progress.create('Netflix', generic_utility.get_string(30200) + '...')
    generic_utility.progress_window(login_progress, 25, generic_utility.get_string(30201))
    content = connect.load_netflix_site(generic_utility.main_url + 'Login', new_session=True)
    if not 'Sorry, Netflix ' in content:
        match = re.compile('name="authURL" value="(.+?)"', re.DOTALL| re.UNICODE).findall(content)
#        utility.log('Setting authorization url: ' + match[0])
        generic_utility.set_setting('authorization_url', match[0])
        match = re.compile('locale: "(.+?)"', re.DOTALL|re.UNICODE).findall(content)
        generic_utility.set_setting('language', match[0])
        post_data = {'authURL': generic_utility.get_setting('authorization_url'), 'email': generic_utility.get_setting('username'),
                     'password': generic_utility.get_setting('password'), 'RememberMe': 'on'}
        generic_utility.progress_window(login_progress, 50, generic_utility.get_string(30202))
        content = connect.load_netflix_site(
            generic_utility.main_url + 'Login?locale=' + generic_utility.get_setting('language'),
            post=post_data)
#        utility.log(content)

        if 'id="page-LOGIN"' in content:
            generic_utility.notification(generic_utility.get_string(30303))
            return False
        match = re.compile('"apiUrl":"(.+?)",', re.UNICODE).findall(content)
        generic_utility.set_setting('api_url', match[0])

        connect.set_chrome_netflix_cookies()

        generic_utility.progress_window(login_progress, 75, generic_utility.get_string(30203))

        profile_selection()

        if login_progress:
            if not generic_utility.progress_window(login_progress, 100, generic_utility.get_string(30204)):
                return False
            xbmc.sleep(500)
            login_progress.close()
        return True
    else:
        generic_utility.notification(generic_utility.get_string(30300))
        if login_progress:
            login_progress.close()
        return False
예제 #11
0
def add(video_id):
    post_data = generic_utility.my_list % generic_utility.get_setting('authorization_url')
    content = connect.load_netflix_site(generic_utility.evaluator(), post=post_data)
    match = json.loads(content)['value']['videos']
    headers = {'Access-Control-Request-Headers': 'content-type, accept','Access-Control-Request-Method': 'POST',
               'Origin': 'http://www.netflix.com'}
    connect.load_netflix_site(generic_utility.evaluator() + '&method=call', options=True, headers=headers)
    cookies = {'lhpuuidh-browse-' + generic_utility.get_setting('selected_profile'): urllib.quote_plus(
        generic_utility.get_setting('language').split('-')[1] + ':' + generic_utility.get_setting('language').upper() + ':' + generic_utility.get_setting('root_list')), 'SecureNetflixId': 'v%3D2%26mac%3DAQEAEQABABRkPnYy2LvtMo02JH3beZhI4vKJAM2mLeM.%26dt%3D1449696369549'}
    post_data = generic_utility.add_list % (generic_utility.get_setting('root_list'),
                                            generic_utility.get_setting('my_list'),
                                            video_id,
                                            generic_utility.get_setting('track_id'),
                                            unicode(len(match)),
                                            generic_utility.get_setting('authorization_url'))
    headers = {'Referer': 'http://www.netflix.com/browse',
               'Origin': 'http://www.netflix.com'}
    content = connect.load_netflix_site(generic_utility.evaluator() + '&method=call',
                                        cookies=cookies,
                                        headers=headers,
                                        post=post_data)
예제 #12
0
def add(video_id):
    post_data = generic_utility.my_list % generic_utility.get_setting(
        'authorization_url')
    content = connect.load_netflix_site(generic_utility.evaluator(),
                                        post=post_data)
    match = json.loads(content)['value']['videos']
    headers = {
        'Access-Control-Request-Headers': 'content-type, accept',
        'Access-Control-Request-Method': 'POST',
        'Origin': 'http://www.netflix.com'
    }
    connect.load_netflix_site(generic_utility.evaluator() + '&method=call',
                              options=True,
                              headers=headers)
    cookies = {
        'lhpuuidh-browse-' + generic_utility.get_setting('selected_profile'):
        urllib.quote_plus(
            generic_utility.get_setting('language').split('-')[1] + ':' +
            generic_utility.get_setting('language').upper() + ':' +
            generic_utility.get_setting('root_list')),
        'SecureNetflixId':
        'v%3D2%26mac%3DAQEAEQABABRkPnYy2LvtMo02JH3beZhI4vKJAM2mLeM.%26dt%3D1449696369549'
    }
    post_data = generic_utility.add_list % (
        generic_utility.get_setting('root_list'),
        generic_utility.get_setting('my_list'), video_id,
        generic_utility.get_setting('track_id'), unicode(
            len(match)), generic_utility.get_setting('authorization_url'))
    headers = {
        'Referer': 'http://www.netflix.com/browse',
        'Origin': 'http://www.netflix.com'
    }
    content = connect.load_netflix_site(generic_utility.evaluator() +
                                        '&method=call',
                                        cookies=cookies,
                                        headers=headers,
                                        post=post_data)
예제 #13
0
def choose():
    profiles = []
    content = connect.load_netflix_site(generic_utility.profile_url, login_process=True)
#    generic_utility.log('choose: '+content)
    match = json.loads(content)['profiles']
    for item in match:
        profile = {'name': item['firstName'], 'token': item['guid'], 'is_kid': item['experience'] == 'jfk'}
        profiles.append(profile)
    if len(match) > 0:
        dialog = xbmcgui.Dialog()
        nr = dialog.select(generic_utility.get_string(30103), [profile['name'] for profile in profiles])
        if nr >= 0:
            selected_profile = profiles[nr]
        else:
            selected_profile = profiles[0]

        switch_profile(selected_profile['token'])

        generic_utility.set_setting('selected_profile', selected_profile['token'])
        generic_utility.set_setting('is_kid', 'true' if selected_profile['is_kid'] else 'false')
        generic_utility.set_setting('profile_name', selected_profile['name'])
    else:
        generic_utility.log('Choose profile: no profiles were found!', loglevel=xbmc.LOGERROR)
예제 #14
0
def login():
    if not test:
        login_progress = xbmcgui.DialogProgress()
        login_progress.create("Netflix", generic_utility.get_string(30200) + "...")
        generic_utility.progress_window(login_progress, 25, generic_utility.get_string(30201))
    content = connect.load_netflix_site(generic_utility.main_url + "Login", new_session=True, login_process=True)
    if "Sorry, Netflix " not in content:

        match = re.compile('locale: "(.+?)"', re.DOTALL | re.UNICODE).findall(content)
        locale = None
        if (len(match)) == 0:
            match = re.compile('"pageName":"login","locale":"(.+?)"', re.DOTALL | re.UNICODE).findall(content)
            if (len(match)) == 0:
                generic_utility.error("Cannot find locale on page. content: " + content)
                login_url = "Login"
            else:
                locale = match[0]
                login_url = "Login?locale=" + locale
        else:
            locale = match[0]
            login_url = "Login?locale=" + locale
        generic_utility.set_setting("language", locale)

        post_data = {
            "authURL": generic_utility.get_setting("authorization_url"),
            "email": generic_utility.get_setting("username"),
            "password": generic_utility.get_setting("password"),
            "rememberMe": "true",
            "flow": "websiteSignUp",
            "mode": "loginPassword",
            "action": "loginAction",
            "withFields": "email,password,rememberMe,nextPage",
            "nextPage": "",
        }

        if not test:
            generic_utility.progress_window(login_progress, 50, generic_utility.get_string(30202))

        content = connect.load_netflix_site(generic_utility.main_url + login_url, post=post_data, login_process=True)

        if 'id="page-LOGIN"' in content:
            if not test:
                generic_utility.notification(generic_utility.get_string(30303))
            return False

        parse_data_set_cookies(content)

        if not test:
            generic_utility.progress_window(login_progress, 75, generic_utility.get_string(30203))

        profile_selection()

        if login_progress:
            if not test:
                if not generic_utility.progress_window(login_progress, 100, generic_utility.get_string(30204)):
                    return False
                xbmc.sleep(500)
                login_progress.close()
        return True
    else:
        if not test:
            generic_utility.notification(generic_utility.get_string(30300))
            if login_progress:
                login_progress.close()
        return False
def switch_profile(profile_id):
    auth_id = generic_utility.get_setting('authorization_url')
    profile_switch_url = generic_utility.profile_switch() + 'switchProfileGuid=' + profile_id + '&authURL=' + auth_id
    ret = connect.load_netflix_site(profile_switch_url)
#    generic_utility.log('switch-profile: '+ret)
    connect.set_chrome_netflix_cookies()