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
def try_to_read_auth_url(ret): match = re.compile('"authURL":"(.+?)"', re.DOTALL | re.UNICODE).findall(ret) if len(match) > 0: generic_utility.debug('Setting authorization url: ' + match[0]) if not test: generic_utility.set_setting('authorization_url', match[0]) else: match = re.compile('name="authURL" value="(.+?)"', re.DOTALL | re.UNICODE).findall(ret) if len(match) > 0: generic_utility.debug('Setting authorization url: ' + match[0]) if not test: generic_utility.set_setting('authorization_url', match[0])
def parse_api_url(content): apiroot = re.compile('"SHAKTI_API_ROOT":"(.+?)",', re.UNICODE).findall(content) apibuild = re.compile('"BUILD_IDENTIFIER":"(.+?)",', re.UNICODE).findall(content) if len(apiroot) > 0 and len(apibuild) > 0: epstr = apiroot[0] + "/" + apibuild[0] epstr = generic_utility.replace_netfix_secret_code(epstr) generic_utility.set_setting('api_url', epstr) else: generic_utility.error('Cannot find api url! Source: ' + content)
def parse_endpoints(content): match = re.compile('"endpointIdentifiers":({.+?}),', re.UNICODE).findall(content) if len(match) > 0: epstr = match[0] if epstr.endswith("}}"): epstr = epstr[:-1] epstr = generic_utility.replace_netfix_secret_code(epstr) generic_utility.set_setting("endpoints", epstr) else: generic_utility.error("Cannot find api endpoints! Source: " + content)
def parse_endpoints(content): match = re.compile('"endpointIdentifiers":({.+?}),', re.UNICODE).findall(content) if len(match) > 0: epstr = match[0] if epstr.endswith('}}'): epstr = epstr[:-1] epstr = generic_utility.replace_netfix_secret_code(epstr) generic_utility.set_setting('endpoints', epstr) else: generic_utility.error('Cannot find api endpoints! Source: ' + content)
def try_to_read_auth_url(ret): match = re.compile('"authURL":"(.+?)"', re.DOTALL | re.UNICODE).findall(ret) if len(match) > 0: authurl = generic_utility.replace_netfix_secret_code(match[0]) generic_utility.debug('Setting authorization url: ' + authurl) if not test: generic_utility.set_setting('authorization_url', authurl) else: return authurl else: match = re.compile('name="authURL" value="(.+?)"', re.DOTALL | re.UNICODE).findall(ret) if len(match) > 0: authurl = generic_utility.replace_netfix_secret_code(match[0]) generic_utility.debug('Setting authorization url: ' + authurl) if not test: generic_utility.set_setting('authorization_url', authurl) else: return authurl
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)
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
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
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)
def parse_api_url(content): match = re.compile('"apiUrl":"(.+?)",', re.UNICODE).findall(content) if len(match) > 0: generic_utility.set_setting('api_url', match[0]) else: generic_utility.error('Cannot find apiUrl! Source: ' + content)
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 parse_endpoints(content): match = re.compile('"endpointIdentifiers":({.+?}),', re.UNICODE).findall(content) if len(match) > 0: generic_utility.set_setting('endpoints', match[0]) else: generic_utility.error('Cannot find api endpoints! Source: ' + content)
def update_displayed(): menu_path = xbmc.getInfoLabel('Container.FolderPath') if menu_path and not generic_utility.get_setting('show_profiles') == 'true': generic_utility.set_setting('selected_profile', None) xbmc.executebuiltin('Container.Update(' + menu_path + ')')
def force_choose(): generic_utility.set_setting('single_profile', 'false') generic_utility.notification(generic_utility.get_string(30304)) choose()
def update_displayed(): menu_path = xbmc.getInfoLabel('Container.FolderPath') if not generic_utility.get_setting('show_profiles') == 'true': generic_utility.set_setting('selected_profile', None) xbmc.executebuiltin('Container.Update(' + menu_path + ')')