Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'file_path': video_file_path,
'file_size': os.stat(video_file_path).st_size,
'file_name': os.path.basename(video_file_path)
}
try:
# Setup API client
jwplatform_client = Client(JW_API_KEY, JW_API_SECRET)
# Make /videos/create API call with multipart parameter specified
jwplatform_video_create_response = jwplatform_client.videos.create(
upload_method='multipart',
title=upload_parameters['file_name']
)
except JWPlatformError:
logging.exception('An error occurred during the uploader setup. Check that your API keys are properly '
'set up in your environment, and ensure that the video file path exists.')
return
# Construct base url for upload
upload_parameters['upload_url'] = '{protocol}://{address}{path}'.format(**jwplatform_video_create_response['link'])
logging.info('Upload URL to be used: {}'.format(upload_parameters['upload_url']))
upload_parameters['query_parameters'] = jwplatform_video_create_response['link']['query']
upload_parameters['query_parameters']['api_format'] = 'json'
upload_parameters['headers'] = {'X-Session-ID': jwplatform_video_create_response['session_id']}
# The chunk offset will be updated several times during the course of the upload
upload_parameters['chunk_offset'] = 0
# Perform the multipart upload
"""Integrity Error"""
class JWPlatformDigestMissingError(JWPlatformError):
"""Digest Missing"""
class JWPlatformDigestInvalidError(JWPlatformError):
"""Digest Invalid"""
class JWPlatformFileUploadFailedError(JWPlatformError):
"""File Upload Failed"""
class JWPlatformFileSizeMissingError(JWPlatformError):
"""File Size Missing"""
class JWPlatformFileSizeInvalidError(JWPlatformError):
"""File Size Invalid"""
class JWPlatformInternalError(JWPlatformError):
"""Internal Error"""
class JWPlatformApiKeyMissingError(JWPlatformError):
"""User Key Missing"""
class JWPlatformApiKeyInvalidError(JWPlatformError):
"""Call Failed"""
class JWPlatformCallUnavailableError(JWPlatformError):
"""Call Unavailable"""
class JWPlatformCallInvalidError(JWPlatformError):
"""Call Invalid"""
class JWPlatformParameterMissingError(JWPlatformError):
"""Missing Parameter"""
class JWPlatformParameterEmptyError(JWPlatformError):
"""Empty Parameter"""
class JWPlatformParameterEncodingError(JWPlatformError):
"""Parameter Encoding Error"""
class JWPlatformParameterInvalidError(JWPlatformError):
"""Invalid Parameter"""
class JWPlatformPreconditionFailedError(JWPlatformError):
"""Precondition Failed"""
class JWPlatformItemAlreadyExistsError(JWPlatformError):
"""No Method Specified"""
class JWPlatformNotImplementedError(JWPlatformError):
"""Method Not Implemented"""
class JWPlatformNotSupportedError(JWPlatformError):
"""Method or parameter not supported"""
class JWPlatformCallFailedError(JWPlatformError):
"""Call Failed"""
class JWPlatformCallUnavailableError(JWPlatformError):
"""Call Unavailable"""
class JWPlatformCallInvalidError(JWPlatformError):
"""Call Invalid"""
class JWPlatformParameterMissingError(JWPlatformError):
"""Missing Parameter"""
class JWPlatformParameterEmptyError(JWPlatformError):
"""Empty Parameter"""
class JWPlatformParameterEncodingError(JWPlatformError):
"""Invalid Parameter"""
class JWPlatformPreconditionFailedError(JWPlatformError):
"""Precondition Failed"""
class JWPlatformItemAlreadyExistsError(JWPlatformError):
"""Item Already Exists"""
class JWPlatformPermissionDeniedError(JWPlatformError):
"""Permission Denied"""
class JWPlatformDatabaseError(JWPlatformError):
"""Database Error"""
class JWPlatformIntegrityError(JWPlatformError):
"""Integrity Error"""
class JWPlatformDigestMissingError(JWPlatformError):
"""Digest Missing"""
class JWPlatformDigestInvalidError(JWPlatformError):
"""Digest Invalid"""
class JWPlatformFileUploadFailedError(JWPlatformError):
"""Nonce Missing"""
class JWPlatformNonceInvalidError(JWPlatformError):
"""Nonce Invalid"""
class JWPlatformSignatureMissingError(JWPlatformError):
"""Signature Missing"""
class JWPlatformSignatureInvalidError(JWPlatformError):
"""Signature Invalid"""
class JWPlatformRateLimitExceededError(JWPlatformError):
"""Rate Limit Exceeded"""
"""Not Found"""
class JWPlatformNoMethodError(JWPlatformError):
"""No Method Specified"""
class JWPlatformNotImplementedError(JWPlatformError):
"""Method Not Implemented"""
class JWPlatformNotSupportedError(JWPlatformError):
"""Method or parameter not supported"""
class JWPlatformCallFailedError(JWPlatformError):
"""Call Failed"""
class JWPlatformCallUnavailableError(JWPlatformError):
"""Call Unavailable"""
class JWPlatformCallInvalidError(JWPlatformError):
"""Call Invalid"""
class JWPlatformParameterMissingError(JWPlatformError):
"""Missing Parameter"""
class JWPlatformParameterEmptyError(JWPlatformError):
"""Precondition Failed"""
class JWPlatformItemAlreadyExistsError(JWPlatformError):
"""Item Already Exists"""
class JWPlatformPermissionDeniedError(JWPlatformError):
"""Permission Denied"""
class JWPlatformDatabaseError(JWPlatformError):
"""Database Error"""
class JWPlatformIntegrityError(JWPlatformError):
"""Integrity Error"""
class JWPlatformDigestMissingError(JWPlatformError):
"""Digest Missing"""
class JWPlatformDigestInvalidError(JWPlatformError):
"""Digest Invalid"""
class JWPlatformFileUploadFailedError(JWPlatformError):
"""File Upload Failed"""
class JWPlatformFileSizeMissingError(JWPlatformError):
"""An Unknown Error occurred"""
class JWPlatformNotFoundError(JWPlatformError):
"""Not Found"""
class JWPlatformNoMethodError(JWPlatformError):
"""No Method Specified"""
class JWPlatformNotImplementedError(JWPlatformError):
"""Method Not Implemented"""
class JWPlatformNotSupportedError(JWPlatformError):
"""Method or parameter not supported"""
class JWPlatformCallFailedError(JWPlatformError):
"""Call Failed"""
class JWPlatformCallUnavailableError(JWPlatformError):
"""Call Unavailable"""
class JWPlatformCallInvalidError(JWPlatformError):
"""Call Invalid"""
class JWPlatformParameterMissingError(JWPlatformError):