Exemplo n.º 1
0
 def _get_owner_user_id_token(self):
     """A way to get the user token id of owner profile"""
     # In order to get a user id token of another (non-owner) profile you must make a request with SWITCH_PROFILE
     # authentication scheme (a custom authentication for netflix), and this request can be directly included
     # in the MSL manifest request.
     # But in order to execute this switch profile, you need to have the user id token of the main (owner) profile.
     # The only way (found to now) to get it immediately, is send a logblob event request, and save the
     # user id token obtained in the response.
     LOG.debug('Requesting logblog')
     endpoint_url = ENDPOINTS['logblobs'] + create_req_params(0, 'bind')
     response = self.chunked_request(endpoint_url,
                                     self.build_request_data('/logblob', generate_logblobs_params()),
                                     get_esn(),
                                     force_auth_credential=True)
     LOG.debug('Response of logblob request: {}', response)
 def _process_event_request(self, event_type, event_data, player_state):
     """Build and make the event post request"""
     if event_type == EVENT_START:
         # We get at every new video playback a fresh LoCo data
         self.loco_data = self.nfsession.get_loco_data()
     url = event_data['manifest']['links']['events']['href']
     from resources.lib.services.nfsession.msl.msl_request_builder import MSLRequestBuilder
     request_data = MSLRequestBuilder.build_request_data(
         url,
         self._build_event_params(event_type, event_data, player_state,
                                  event_data['manifest'], self.loco_data))
     # Request attempts can be made up to a maximum of 3 times per event
     LOG.info('EVENT [{}] - Executing request', event_type)
     endpoint_url = ENDPOINTS['events'] + create_req_params(
         20 if event_type == EVENT_START else 0, f'events/{event_type}')
     try:
         response = self.chunked_request(endpoint_url,
                                         request_data,
                                         get_esn(),
                                         disable_msl_switch=False)
         # Malformed/wrong content in requests are ignored without returning any error in the response or exception
         LOG.debug('EVENT [{}] - Request response: {}', event_type,
                   response)
         if event_type == EVENT_STOP:
             if event_data['allow_request_update_loco']:
                 if 'list_context_name' in self.loco_data:
                     self.nfsession.update_loco_context(
                         self.loco_data['root_id'],
                         self.loco_data['list_context_name'],
                         self.loco_data['list_id'],
                         self.loco_data['list_index'])
                 else:
                     LOG.warn(
                         'EventsHandler: LoCo list not updated due to missing list context data'
                     )
                 video_id = request_data['params']['sessionParams'][
                     'uiplaycontext']['video_id']
                 self.nfsession.update_videoid_bookmark(video_id)
             self.loco_data = None
     except Exception as exc:  # pylint: disable=broad-except
         LOG.error('EVENT [{}] - The request has failed: {}', event_type,
                   exc)
Exemplo n.º 3
0
 def _process_event_request(self, event):
     """Do the event post request"""
     event.status = Event.STATUS_REQUESTED
     # Request attempts can be made up to a maximum of 3 times per event
     LOG.info('EVENT [{}] - Executing request', event)
     endpoint_url = ENDPOINTS['events'] + create_req_params(
         20 if event.event_type == EVENT_START else 0,
         'events/{}'.format(event))
     try:
         response = self.chunked_request(endpoint_url,
                                         event.request_data,
                                         get_esn(),
                                         disable_msl_switch=False)
         # Malformed/wrong content in requests are ignored without returning error feedback in the response
         event.set_response(response)
     except Exception as exc:  # pylint: disable=broad-except
         LOG.error('EVENT [{}] - The request has failed: {}', event, exc)
         event.set_response('RequestError')
     if event.event_type == EVENT_STOP and event.status == Event.STATUS_SUCCESS:
         self.clear_queue()
         if event.event_data['allow_request_update_loco']:
             self.nfsession.update_loco_context('continueWatching')
             self.nfsession.update_videoid_bookmark(event.get_video_id())
     return True