List of all the serialized data pulled out of the pagws <script/> tags
"""
scripts = page_soup.find_all('script', attrs={'src': None});
- self.log('Trying sloppy inline data parser')
+ self.log(msg='Trying sloppy inline data parser')
inline_data = self._sloppy_parse_inline_data(scripts=scripts)
if self._verfify_auth_and_profiles_data(data=inline_data) != False:
- self.log('Sloppy inline data parsing successfull')
+ self.log(msg='Sloppy inline data parsing successfull')
return inline_data
- self.log('Sloppy inline parser failed, trying JS parser')
+ self.log(msg='Sloppy inline parser failed, trying JS parser')
return self._accurate_parse_inline_data(scripts=scripts)
def is_logged_in (self, account):
for key in self.video_list_keys:
video_list_ids[key] = {}
+ # check if the list items are hidden behind a `value` sub key
+ # this is the case when we fetch the lists via POST, not via a GET preflight request
+ if 'value' in response_data.keys():
+ response_data = response_data['value']
+
# subcatogorize the lists by their context
video_lists = response_data['lists']
for video_list_id in video_lists.keys():
'synopsis': video['synopsis'],
'regular_synopsis': video['regularSynopsis'],
'type': video['summary']['type'],
- 'rating': video['userRating']['average'],
+ 'rating': video['userRating'].get('average', 0) if video['userRating'].get('average', None) != None else video['userRating'].get('predicted', 0),
'episode_count': season_info['episode_count'],
'seasons_label': season_info['seasons_label'],
'seasons_count': season_info['seasons_count'],
'mpaa': str(episode['maturity']['rating']['board']) + ' ' + str(episode['maturity']['rating']['value']),
'maturity': episode['maturity'],
'playcount': (0, 1)[episode['watched']],
- 'rating': episode['userRating']['average'],
+ 'rating': episode['userRating'].get('average', 0) if episode['userRating'].get('average', None) != None else episode['userRating'].get('predicted', 0),
'thumb': episode['info']['interestingMoments']['url'],
'fanart': episode['interestingMoment']['_1280x720']['jpg']['url'],
'poster': episode['boxarts']['_1280x720']['jpg']['url'],
response = self._session_get(component='browse')
return BeautifulSoup(response.text, 'html.parser')
- def fetch_video_list_ids (self, list_from=0, list_to=50):
+ def fetch_video_list_ids_via_preflight (self, list_from=0, list_to=50):
"""Fetches the JSON with detailed information based on the lists on the landing page (browse page) of Netflix
+ via the preflight (GET) request
Parameters
----------
response = self._session_get(component='video_list_ids', params=payload, type='api')
return self._process_response(response=response, component=self._get_api_url_for(component='video_list_ids'))
- def fetch_search_results (self, search_str, list_from=0, list_to=10):
- """Fetches the JSON which contains the results for the given search query
+ def fetch_video_list_ids (self, list_from=0, list_to=50):
+ """Fetches the JSON with detailed information based on the lists on the landing page (browse page) of Netflix
Parameters
----------
- search_str : :obj:`str`
- String to query Netflix search for
-
list_from : :obj:`int`
Start entry for pagination
:obj:`dict` of :obj:`dict` of :obj:`str`
Raw Netflix API call response or api call error
"""
- # properly encode the search string
- encoded_search_string = quote(search_str)
-
paths = [
- ['search', encoded_search_string, 'titles', {'from': list_from, 'to': list_to}, ['summary', 'title']],
- ['search', encoded_search_string, 'titles', {'from': list_from, 'to': list_to}, 'boxarts', '_342x192', 'jpg'],
- ['search', encoded_search_string, 'titles', ['id', 'length', 'name', 'trackIds', 'requestId']],
- ['search', encoded_search_string, 'suggestions', 0, 'relatedvideos', {'from': list_from, 'to': list_to}, ['summary', 'title']],
- ['search', encoded_search_string, 'suggestions', 0, 'relatedvideos', {'from': list_from, 'to': list_to}, 'boxarts', '_342x192', 'jpg'],
- ['search', encoded_search_string, 'suggestions', 0, 'relatedvideos', ['id', 'length', 'name', 'trackIds', 'requestId']]
+ ['lolomo', {'from': list_from, 'to': list_to}, ['displayName', 'context', 'id', 'index', 'length']]
]
- response = self._path_request(paths=paths)
- return self._process_response(response=response, component='Search results')
-
- def get_lolomo_for_kids (self):
- """Fetches the lolomo ID for Kids profiles
- Returns
- -------
- :obj:`str`
- Kids Lolomo ID
- """
- response = self._session_get(component='kids')
- for cookie in response.cookies:
- if cookie.name.find('lhpuuidh-browse-' + self.user_data['guid']) != -1 and cookie.name.rfind('-T') == -1:
- start = unquote(cookie.value).rfind(':')
- return unquote(cookie.value)[start+1:]
- return None
+ response = self._path_request(paths=paths)
+ return self._process_response(response=response, component='Video list ids')
- def fetch_lists_for_kids (self, lolomo, list_from=0, list_to=50):
- """Fetches the JSON which contains the contents of a the video list for kids users
+ def fetch_search_results (self, search_str, list_from=0, list_to=10):
+ """Fetches the JSON which contains the results for the given search query
Parameters
----------
- lolomo : :obj:`str`
- Lolomo ID for the Kids profile
+ search_str : :obj:`str`
+ String to query Netflix search for
list_from : :obj:`int`
Start entry for pagination
:obj:`dict` of :obj:`dict` of :obj:`str`
Raw Netflix API call response or api call error
"""
+ # properly encode the search string
+ encoded_search_string = quote(search_str)
+
paths = [
- ['lists', lolomo, {'from': list_from, 'to': list_to}, ['displayName', 'context', 'genreId', 'id', 'index', 'length']]
+ ['search', encoded_search_string, 'titles', {'from': list_from, 'to': list_to}, ['summary', 'title']],
+ ['search', encoded_search_string, 'titles', {'from': list_from, 'to': list_to}, 'boxarts', '_342x192', 'jpg'],
+ ['search', encoded_search_string, 'titles', ['id', 'length', 'name', 'trackIds', 'requestId']],
+ ['search', encoded_search_string, 'suggestions', 0, 'relatedvideos', {'from': list_from, 'to': list_to}, ['summary', 'title']],
+ ['search', encoded_search_string, 'suggestions', 0, 'relatedvideos', {'from': list_from, 'to': list_to}, 'boxarts', '_342x192', 'jpg'],
+ ['search', encoded_search_string, 'suggestions', 0, 'relatedvideos', ['id', 'length', 'name', 'trackIds', 'requestId']]
]
-
response = self._path_request(paths=paths)
- res = self._process_response(response=response, component='Kids lists')
- return self.parse_video_list_ids(response_data=res['value'])
+ return self._process_response(response=response, component='Search results')
def fetch_video_list (self, list_id, list_from=0, list_to=20):
"""Fetches the JSON which contains the contents of a given video list
start = time()
response = self.session.post(url=url, data=data, params=params, headers=headers, verify=self.verify_ssl)
end = time()
- self.log('[POST] Request for "' + url + '" took ' + str(end - start) + ' seconds')
+ self.log(msg='[POST] Request for "' + url + '" took ' + str(end - start) + ' seconds')
return response
def _session_get (self, component, type='document', params={}):
start = time()
response = self.session.get(url=url, verify=self.verify_ssl, params=params)
end = time()
- self.log('[GET] Request for "' + url + '" took ' + str(end - start) + ' seconds')
+ self.log(msg='[GET] Request for "' + url + '" took ' + str(end - start) + ' seconds')
return response
def _sloppy_parse_user_and_api_data (self, key, contents):
self.esn = self._parse_esn_data(netflix_page_data=netflix_page_data)
self.api_data = self._parse_api_base_data(netflix_page_data=netflix_page_data)
self.profiles = self._parse_profile_data(netflix_page_data=netflix_page_data)
- self.log('Found ESN "' + self.esn + '"')
+ self.log(msg='Found ESN "' + self.esn + '"')
return netflix_page_data