Example #1
0
 def logout(self, api_token):
     """
     :type api_token: basestring
     """
     query_dict = self.__init_access_req_dict(api_token)
     # Nothing returned
     WebUtils.http_request(self.base_url, self.LOGOUT_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
Example #2
0
    def modify_job(self,
                   api_token,
                   job_id,
                   fidelity=None,
                   turnaround_hours=None,
                   priority=None):
        """
        Modify parameters of an already existing job. The job must be in Authorization state.
        :param api_token: The API token used for this session
        :type api_token: basestring
        :param job_id: The ID of the job which is being modified
        :type job_id: basestring
        :param fidelity: The desired fidelity of the transcription
        :type fidelity: Fidelity|basestring|None
        :param turnaround_hours: The number of hours after which the job is returned
        :type turnaround_hours: int|None
        :param priority: The desired priority of the transcription
        :type priority: Priority|basestring|None
        """
        query_dict = self.__init_job_req_dict(api_token, job_id)

        if fidelity:
            query_dict['transcription_fidelity'] = fidelity
        if priority:
            query_dict['priority'] = priority
        if turnaround_hours:
            query_dict['turnaround_hours'] = turnaround_hours

        WebUtils.http_request(self.base_url, self.MODIFY_JOB_PATH, 'POST',
                              WebUtils.BASIC_TIMEOUT, query_dict)
Example #3
0
 def authorize_job(self, api_token, job_id):
     """
     :type api_token: basestring
     :type job_id: basestring
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     # Nothing returned
     WebUtils.http_request(self.base_url, self.AUTHORIZE_JOB_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
Example #4
0
 def logout(self, api_token):
     """
     :type api_token: basestring
     """
     query_dict = self.__init_access_req_dict(api_token)
     # Nothing returned
     WebUtils.http_request(self.base_url, self.LOGOUT_PATH, 'GET',
                           WebUtils.BASIC_TIMEOUT, query_dict)
Example #5
0
 def update_password(self, api_token, new_password, sub_account=None):
     self.__assert_argument(new_password, 'New Password')
     query_dict = self.__init_access_req_dict(api_token)
     query_dict['new_password'] = new_password
     if sub_account:
         # username parameter named sub_account for clarity
         query_dict['username'] = sub_account
     # Nothing returned
     WebUtils.http_request(self.base_url, self.UPDATE_PASSWORD_PATH, 'POST', WebUtils.BASIC_TIMEOUT, None, None, urlencode(query_dict))
Example #6
0
 def authorize_job(self, api_token, job_id):
     """
     :type api_token: basestring
     :type job_id: basestring
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     # Nothing returned
     WebUtils.http_request(self.base_url, self.AUTHORIZE_JOB_PATH, 'GET',
                           WebUtils.BASIC_TIMEOUT, query_dict)
Example #7
0
 def remove_api_key(self, api_token, api_securekey):
     """
     :type api_token: basestring
     :type api_securekey: basestring
     """
     self.__assert_argument(api_securekey, 'API Secure Key')
     query_dict = self.__init_access_req_dict(api_token)
     query_dict['api_securekey'] = api_securekey
     # Nothing returned
     WebUtils.http_request(self.base_url, self.REMOVE_API_KEY_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
Example #8
0
 def remove_api_key(self, api_token, api_securekey):
     """
     :type api_token: basestring
     :type api_securekey: basestring
     """
     self.__assert_argument(api_securekey, 'API Secure Key')
     query_dict = self.__init_access_req_dict(api_token)
     query_dict['api_securekey'] = api_securekey
     # Nothing returned
     WebUtils.http_request(self.base_url, self.REMOVE_API_KEY_PATH, 'GET',
                           WebUtils.BASIC_TIMEOUT, query_dict)
Example #9
0
 def update_password(self, api_token, new_password, sub_account=None):
     """
     :type api_token: basestring
     :type new_password: basestring
     :type sub_account: basestring|None
     """
     self.__assert_argument(new_password, 'New Password')
     query_dict = self.__init_access_req_dict(api_token)
     query_dict['new_password'] = new_password
     if sub_account:
         # username parameter named sub_account for clarity
         query_dict['username'] = sub_account
     # Nothing returned
     WebUtils.http_request(self.base_url, self.UPDATE_PASSWORD_PATH, 'POST',
                           WebUtils.BASIC_TIMEOUT, None, None,
                           urlencode(query_dict))
Example #10
0
    def get_caption(self,
                    api_token,
                    job_id,
                    caption_format,
                    caption_options=None):
        """
        :type api_token: basestring
        :type job_id: basestring
        :type caption_format: CaptionFormat|basestring
        :type caption_options: TranscriptOptions|None
        :rtype: basestring
        """
        self.__assert_argument(caption_format, 'Caption Format')
        query_dict = self.__init_job_req_dict(api_token, job_id)
        query_dict['caption_format'] = caption_format
        if caption_options:
            query_dict.update(caption_options.get_dict())

        response = WebUtils.http_request(self.base_url, self.GET_CAPTION_PATH,
                                         'GET', WebUtils.DOWNLOAD_TIMEOUT,
                                         query_dict)
        if caption_options and caption_options.build_url:  # If build_url is true
            return JSONDecoder().decode(response)[
                'CaptionUrl']  # Return Caption URL
        else:
            return response  # Else return raw caption text
Example #11
0
 def get_transcript(self, api_token, job_id, transcript_options=None):
     """
     :type api_token: basestring
     :type job_id: basestring
     :type transcript_options: TranscriptOptions|None
     :rtype: basestring
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     if transcript_options:
         query_dict.update(transcript_options.get_dict())
     # Returns raw transcript text
     return WebUtils.http_request(self.base_url, self.GET_TRANSCRIPT_PATH, 'GET', WebUtils.DOWNLOAD_TIMEOUT, query_dict)
Example #12
0
    def get_caption(self, api_token, job_id, caption_format, caption_options=None):
        self.__assert_argument(caption_format, 'Caption Format')
        query_dict = self.__init_job_req_dict(api_token, job_id)
        query_dict['caption_format'] = caption_format
        if caption_options:
            query_dict.update(caption_options.get_dict())

        response = WebUtils.http_request(self.base_url, self.GET_CAPTION_PATH, 'GET', WebUtils.DOWNLOAD_TIMEOUT, query_dict)
        if caption_options and caption_options.build_url:  # If build_url is true
            return JSONDecoder().decode(response)['CaptionUrl']  # Return Caption URL
        else:
            return response  # Else return raw caption text
Example #13
0
 def get_transcript(self, api_token, job_id, transcript_options=None):
     """
     :type api_token: basestring
     :type job_id: basestring
     :type transcript_options: TranscriptOptions|None
     :rtype: basestring
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     if transcript_options:
         query_dict.update(transcript_options.get_dict())
     # Returns raw transcript text
     return WebUtils.http_request(self.base_url, self.GET_TRANSCRIPT_PATH,
                                  'GET', WebUtils.DOWNLOAD_TIMEOUT,
                                  query_dict)
Example #14
0
    def modify_job(self, api_token, job_id, fidelity=None, turnaround_hours=None, priority=None):
        """
        Modify parameters of an already existing job. The job must be in Authorization state.
        :param api_token: The API token used for this session
        :type api_token: basestring
        :param job_id: The ID of the job which is being modified
        :type job_id: basestring
        :param fidelity: The desired fidelity of the transcription
        :type fidelity: Fidelity|basestring|None
        :param turnaround_hours: The number of hours after which the job is returned
        :type turnaround_hours: int|None
        :param priority: The desired priority of the transcription
        :type priority: Priority|basestring|None
        """
        query_dict = self.__init_job_req_dict(api_token, job_id)

        if fidelity:
            query_dict['transcription_fidelity'] = fidelity
        if priority:
            query_dict['priority'] = priority
        if turnaround_hours:
            query_dict['turnaround_hours'] = turnaround_hours

        WebUtils.http_request(self.base_url, self.MODIFY_JOB_PATH, 'POST', WebUtils.BASIC_TIMEOUT, query_dict)