from utils import strip_tags
from utils import noop
class NetflixSession:
"""Helps with login/session management of Netflix users & API data fetching"""
from utils import strip_tags
from utils import noop
class NetflixSession:
"""Helps with login/session management of Netflix users & API data fetching"""
- def __init__(self, cookie_path, data_path, log_fn=noop):
+ def __init__(self, cookie_path, data_path, verify_ssl=True, log_fn=noop):
"""Stores the cookie path for later use & instanciates a requests
session with a proper user agent & stored cookies/data if available
"""Stores the cookie path for later use & instanciates a requests
session with a proper user agent & stored cookies/data if available
# gather all form fields, set an empty string as the default value
for item in login_inputs:
keys = dict(item.attrs).keys()
# gather all form fields, set an empty string as the default value
for item in login_inputs:
keys = dict(item.attrs).keys()
for script in data_scripts:
# ugly part: try to parse the data & don't care about errors (as they will be some)
try:
for script in data_scripts:
# ugly part: try to parse the data & don't care about errors (as they will be some)
try:
return False
if self._load_data(filename=self.data_path + '_' + account_hash) == False:
# load the profiles page (to verify the user)
return False
if self._load_data(filename=self.data_path + '_' + account_hash) == False:
# load the profiles page (to verify the user)
login_soup = BeautifulSoup(login_response.text)
# we know that the login was successfull if we find an HTML element with the class of 'profile-name'
login_soup = BeautifulSoup(login_response.text)
# we know that the login was successfull if we find an HTML element with the class of 'profile-name'
if response.status_code != 200:
return False
# fetch the index page again, so that we can fetch the corresponding user data
if response.status_code != 200:
return False
# fetch the index page again, so that we can fetch the corresponding user data
browse_soup = BeautifulSoup(browse_response.text)
self._parse_page_contents(page_soup=browse_soup)
account_hash = self._generate_account_hash(account=account)
browse_soup = BeautifulSoup(browse_response.text)
self._parse_page_contents(page_soup=browse_soup)
account_hash = self._generate_account_hash(account=account)
pin_response = self._process_response(response=response, component=url)
keys = pin_response.keys()
if 'success' in keys:
pin_response = self._process_response(response=response, component=url)
keys = pin_response.keys()
if 'success' in keys:
- response = self.session.post(self._get_api_url_for(component='set_video_rating'), params=params, headers=headers, data=payload)
+ response = self.session.post(self._get_api_url_for(component='set_video_rating'), params=params, headers=headers, data=payload, verify=self.verify_ssl)
return response.status_code == 200
def parse_video_list_ids (self, response_data):
return response.status_code == 200
def parse_video_list_ids (self, response_data):
return BeautifulSoup(response.text)
def fetch_video_list_ids (self, list_from=0, list_to=50):
return BeautifulSoup(response.text)
def fetch_video_list_ids (self, list_from=0, list_to=50):
return self._process_response(response=response, component=url)
def fetch_search_results (self, search_str, list_from=0, list_to=48):
return self._process_response(response=response, component=url)
def fetch_search_results (self, search_str, list_from=0, list_to=48):
return self._process_response(response=response, component=url)
def fetch_show_information (self, id, type):
return self._process_response(response=response, component=url)
def fetch_show_information (self, id, type):
Dict containing an email, country & a password property
"""
# load the profiles page (to verify the user)
Dict containing an email, country & a password property
"""
# load the profiles page (to verify the user)
# parse out the needed inline information
page_soup = BeautifulSoup(response.text)
page_data = self.extract_inline_netflix_page_data(page_soup=page_soup)
# parse out the needed inline information
page_soup = BeautifulSoup(response.text)
page_data = self.extract_inline_netflix_page_data(page_soup=page_soup)
- return self.session.post(self._get_api_url_for(component='shakti'), params=params, headers=headers, data=data)
+ return self.session.post(self._get_api_url_for(component='shakti'), params=params, headers=headers, data=data, verify=self.verify_ssl)
def _is_size_key (self, key):
"""Tiny helper that checks if a given key is called $size or size, as we need to check this often
def _is_size_key (self, key):
"""Tiny helper that checks if a given key is called $size or size, as we need to check this often
- response = self.session.post(self._get_api_url_for(component='update_my_list'), headers=headers, data=payload)
+ response = self.session.post(self._get_api_url_for(component='update_my_list'), headers=headers, data=payload, verify=self.verify_ssl)
return response.status_code == 200
def _save_data(self, filename):
return response.status_code == 200
def _save_data(self, filename):