
    9ie                         S r SSKrSSKrSSKrSSKJr  SSKJr  SSKJ	r	  SSK
Jr  SSK
Jr  SSK
Jr  SS	K
Jr  SS
K
Jr  SSKJr  SSKJr  SSKJr  SSKJr  \R.                  " \5      r " S S\5      rg)z0
This module provides a client class for Media.
    N)BceBaseClient)bce_v1_signer)BceResponse)bce_http_client)handler)http_content_types)http_headers)http_methods)BceClientError)BceServerError)media_handler)requiredc                      \ rS rSrSrSrS5S jr\" \\	4S9    S6S j5       r
\" \\	4\\S9S5S	 j5       r\" \\	4S
9S5S j5       r\" \\	4S
9S5S j5       r\" \\	4\\	4S9S5S j5       rS5S jr\" \\	4\\	4\\	4S9   S7S j5       r\" \\	4\\4S9 S5S j5       r\" \\	4S9S5S j5       r\" \\	4S9S5S j5       r\" \\	4S9S5S j5       rS5S jr\" \\	4\\	4S9          S8S j5       r\" \\	4\\4S9 S5S j5       r\" \\	4S9S5S j5       r\" \\	4S9S5S j5       r\" \\	4S9S5S  j5       r\" \\	4\S!9S7S" j5       r\" \\	4S
9S5S# j5       r\" \\	4S9    S6S$ j5       r\" \\	4\\	4\ \ S%9     S9S& j5       r!\" \\	4S'9S5S( j5       r"S5S) jr#\" \\	4S'9S5S* j5       r$S5S+ jr%\" \\	4\\	4S,9 S5S- j5       r&\" \\	4S.9S5S/ j5       r'\" \\	4S.9S5S0 j5       r(S1 r)\*S2 5       r+   S9S3 jr,S4r-g):MediaClient%   z
sdk client
z/v3Nc                 0    [         R                  " X5        g N)r   __init__selfconfigs     d/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/baidubce/services/media/media_client.pyr   MediaClient.__init__,   s    t,    )pipeline_namec                     US:X  a  [        S5      eSU0nUb  X&S'   Ub  X6S'   Ub  XFS'   U R                  [        R                  SUUS9$ )	a?  
List jobs by pipelineName and jobStatus

:param pipelineName: The pipeline name
:type  pipelineName: string or unicode
:param job_status: The job status, will not filter if None
:type  job_status: string or unicode
:param begin: The createTime should be later than or equals with begin, will not check if None
:type  begin: string or unicode
:param end: The createTime should be earlier than or equals with end, will not check if None
:type  end: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
 #pipeline_name can't be empty stringpipelineName	jobStatusbeginend/job/transcodingparamsr   r   _send_requestr
   GETr   r   
job_statusr!   r"   r   	my_paramss          r   	list_jobsMediaClient.list_jobs/   sy    . B !GHH
	 !%/k"!&g?"e!!	 "  	r   )r   sourcetargetc           
          US:X  a  [        S5      eU R                  [        R                  S[        R
                  " UUUS.5      [        R                  [        R                  0US9$ )a  
Create a job

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param source: source
:type source: array
:param target: source
:type target: array
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   r   r#   )r   r.   r/   bodyheadersr   
r   r'   r
   POSTjsondumpsr	   CONTENT_TYPEr   JSON)r   r   r.   r/   r   s        r   
create_jobMediaClient.create_jobW   sp      B !GHH!! -  " # "..0B0G0GH "  	r   )job_idc                 h    US:X  a  [        S5      eU R                  [        R                  SU-   US9$ )z
Get the specific job information

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   job_id can't be empty stringz/job/transcoding/r   r&   r   r<   r   s      r   get_jobMediaClient.get_jobs   sC     R< !@AA!!&( "  	r   c                     US:X  a  [        S5      eU R                  [        R                  SU-   [        R
                  US9$ )a$  
Get transcoding job encryption key

:param job_id: The job Id want to query transcoding encryption key.
:type job_id: string
:param config: None
:type config: BceClientConfiguration
:returns: Response Object contains transcoding encryption Aes key.
:rtype: baidubce.bce_response.BceResponse
r   r>   z/transcoding/key/)body_parserr   )r   r'   r
   r(   r   parse_secret_key_responser@   s      r   get_transcoding_encryption_key*MediaClient.get_transcoding_encryption_key   sL     R< !@AA!!&(%??	 "  	r   bucketkeyc                     US:X  a  [        S5      eUS:X  a  [        S5      eU R                  [        R                  SUUS.US9$ )z
Get the media info of media information

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   bucket can't be empty stringkey can't be empty stringz
/mediainforH   r$   r&   )r   rI   rJ   r   s       r   get_mediainfo_of_file!MediaClient.get_mediainfo_of_file   s^     R< !@AA"9 !=>>!!   "  	r   c                 @    U R                  [        R                  SUS9$ )z
List pipelines

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
	/pipeliner?   r'   r
   r(   r   s     r   list_pipelinesMediaClient.list_pipelines   s"     !!,"2"2K!OOr   )r   source_buckettarget_bucketc                 R   0 nUb  XGS'   OSUS'   Ub  XWS'   US:X  a  [        S5      eUS:X  a  [        S5      eUS:X  a  [        S5      eXS'   X'S'   X7S	'   U R                  [        R                  S
[        R
                  " U5      [        R                  [        R                  0US9$ )z
Create a pipeline

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
descriptionr   r   r   z#source_bucket can't be empty stringz#target_bucket can't be empty stringr   sourceBuckettargetBucketrQ   r1   r4   )r   r   rU   rV   rX   pipeline_configr   body_contents           r   create_pipelineMediaClient.create_pipeline   s    , "*5'*,L'&%4"B !GHHB !GHHB !GHH'4^$'4^$'4^$!!L)!..0B0G0GH "  	r   )r   pipelinec           	          U R                  [        R                  SU-   [        R                  " US S9[
        R                  [        R                  0US9$ )a  
Update a pipeline

:param pipeline_name: the preset name
:type pipeline_name: string
:param pipeline: the update body
:type pipeline: Object
:returns:
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse

/pipeline/c                     U R                   $ r   __dict__os    r   <lambda>-MediaClient.update_pipeline.<locals>.<lambda>  s    

r   defaultr1   	r'   r
   PUTr6   r7   r	   r8   r   r9   )r   r   r_   r   s       r   update_pipelineMediaClient.update_pipeline   sT    & !!=(H.BC!..0B0G0GH "  	r   )pipelien_namec                     US:X  a  [        S5      eU R                  [        R                  SU-   U[        R
                  S9$ )a  
Get the specific pipeline information without converting camel key to a "pythonic" name

:param pipeline_name: The pipeline name
:type pipeline_name: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   r   ra   r   rD   r   r'   r
   r(   r   
parse_jsonr   r   r   s      r   get_pipeline_for_update#MediaClient.get_pipeline_for_update  sL     B !GHH!!,"2"2L=4P)/]=U=U " W 	Wr   c                 h    US:X  a  [        S5      eU R                  [        R                  SU-   US9$ )z
Get the specific pipeline information

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   r   ra   r?   r&   rt   s      r   get_pipelineMediaClient.get_pipeline  s<     B !GHH!!,"2"2L=4PY_!``r   c                 h    US:X  a  [        S5      eU R                  [        R                  SU-   US9$ )z
Delete the specific pipeline

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   r   ra   r?   r   r'   r
   DELETErt   s      r   delete_pipelineMediaClient.delete_pipeline'  s<     B !GHH!!,"5"5|m7S\b!ccr   c                 @    U R                  [        R                  SUS9$ )z|
List presets

:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
/presetr?   rR   r   s     r   list_presetsMediaClient.list_presets7  s"     !!,"2"2If!MMr   )preset_name	containerc                    [        5       nUS:X  a  [        S5      eUS:X  a  [        S5      eXS'   X-S'   Uc  SUS'   OXMS'   Ub  X=S'   Ub  X]S'   Ub  XmS	'   Ub  X}S
'   Ub  XS'   U	b  XS'   U
b  XS'   Ub  XS'   U R                  [        R                  S[
        R                  " U5      [        R                  [        R                  0US9$ )z
Create a preset

:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   !preset_name can't be empty stringzcontainer can't be empty string
presetNamer   rX   transmuxclipaudiovideo
encryptionwatermarkIdextraCfgtransCfgr   r1   )dictr   r'   r
   r5   r6   r7   r	   r8   r   r9   )r   r   r   r   rX   r   r   r   r   watermark_idextra_configtrans_configr   r\   s                 r   create_presetMediaClient.create_presetB  s   0 v" !EFF? !CDD%0\"$-[!*,L'*5''/$#' $)!$)!!)3&#*6'#'3$#'3$!!L)!..0B0G0GH "  	r   )r   presetc           	          U R                  [        R                  SU-   [        R                  " US S9[
        R                  [        R                  0US9$ )z
Update a preset

:param preset_name: the preset name
:type preset_name: string
:param preset: the update body
:type preset: Object
:returns:
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
/preset/c                     U R                   $ r   rc   re   s    r   rg   +MediaClient.update_preset.<locals>.<lambda>  s    ajjr   ri   r1   rk   )r   r   r   r   s       r   update_presetMediaClient.update_preset|  sT    & !!$F,@A!..0B0G0GH "  	r   )r   c                 h    US:X  a  [        S5      eU R                  [        R                  SU-   US9$ )z
Get the specific preset information

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   r   r   r?   r&   r   r   r   s      r   
get_presetMediaClient.get_preset  s<     " !EFF!!,"2"2J4LU[!\\r   c                     US:X  a  [        S5      eU R                  [        R                  SU-   U[        R
                  S9$ )a  
Get the specific preset information without converting camel key to a "pythonic" name

:param preset_name: The preset name
:type preset_name: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   r   r   rq   rr   r   s      r   get_preset_for_update!MediaClient.get_preset_for_update  sL     " !EFF!!,"2"2J4L)/]=U=U " W 	Wr   c                 h    US:X  a  [        S5      eU R                  [        R                  SU-   US9$ )z
Delete a preset

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   r   r   r?   r{   r   s      r   delete_presetMediaClient.delete_preset  s<     " !EFF!!,"5"5zK7OX^!__r   )r   r.   c                     0 nUS:X  a  [        S5      eUb  X6S'   Ub  XFS'   XS'   X&S'   U R                  [        R                  S[        R
                  " U5      [        R                  [        R                  0US9$ )	z
Create thumbnail job

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   r   r/   capturer   r.   /job/thumbnailr1   r4   )r   r   r.   r/   r   r   r\   s          r   create_thumbnail_job MediaClient.create_thumbnail_job  s     B !GHH%+"&-#'4^$!'X!!L)!..0B0G0GH "  	r   c                 h    US:X  a  [        S5      eU R                  [        R                  SU-   US9$ )z
Get thumbnail job

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   r>   z/job/thumbnail/r?   r&   r@   s      r   get_thumbnail_jobMediaClient.get_thumbnail_job  s<     R< !@AA!!,"2"24E4NW]!^^r   c                     US:X  a  [        S5      eSU0nUb  X&S'   Ub  X6S'   Ub  XFS'   U R                  [        R                  SUUS9$ )	aD  
List thumbnail jobs by pipelineName

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param job_status: The thumbnail job status, will not filter if None
:type  job_status: string or unicode
:param begin: The createTime should be later than or equals with begin, will not check if None
:type  begin: string or unicode
:param end: The createTime should be earlier than or equals with end, will not check if None
:type  end: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   r   r   r    r!   r"   r   r$   r&   r)   s          r   list_thumbnail_jobs_by_pipeline+MediaClient.list_thumbnail_jobs_by_pipeline  sy    0 B !GHH
	 !%/k"!&g?"e!!	 "  	r   )rI   rJ   vertical_offset_in_pixelhori_offset_in_pixelc                 8   US:X  a  [        S5      eUS:X  a  [        S5      e0 nXS'   X(S'   Ub  X8S'   Ub  XHS'   Ub  XXS'   Ub  XhS	'   U R                  [        R                  S
[        R
                  " U5      [        R                  [        R                  0US9$ )z
Create watermark

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   rL   rM   rI   rJ   verticalAlignmenthorizontalAlignmentverticalOffsetInPixelhorizontalOffsetInPixel
/watermarkr1   r4   )	r   rI   rJ   vertical_alignmenthorizontal_alignmentr   r   r   r\   s	            r   create_watermarkMediaClient.create_watermark  s    0 R< !@AA"9 !=>>!'X!U)0B,-+2F./#/4L01+6J23!!L)!..0B0G0GH "  	r   )r   c                 h    US:X  a  [        S5      eU R                  [        R                  SU-   US9$ )z
Get the specific watermark information

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   "watermark_id can't be empty string/watermark/r?   r&   r   r   r   s      r   get_watermarkMediaClient.get_watermarkJ  s<     2 !FGG!!,"2"2ML4PY_!``r   c                 @    U R                  [        R                  SUS9$ )z
List watermarks

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   r?   rR   r   s     r   list_watermarksMediaClient.list_watermarksZ  s"     !!,"2"2L!PPr   c                 h    US:X  a  [        S5      eU R                  [        R                  SU-   US9$ )z
Delete the specific watermark

:param pipelineName: The pipeline name
:type pipelineName: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   r   r   r?   r{   r   s      r   delete_watermarkMediaClient.delete_watermarkg  s<     2 !FGG!!,"5"5}|7S\b!ccr   c                 @    U R                  [        R                  SUS9$ )z
List notifications

:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
/notificationr?   rR   r   s     r   list_notificationsMediaClient.list_notificationsw  s"     !!,"2"2OF!SSr   nameendpointc                     US:X  a  [        S5      eUS:X  a  [        S5      eUUS.nU R                  [        R                  S[        R
                  " U5      [        R                  [        R                  0US9$ )a  
Create a notification

:param name: The notification name
:type name: string or unicode
:param endpoint: The endpoint
:type endpoint: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   name can't be empty stringzendpoint can't be empty stringr   r   r1   r4   )r   r   r   r   r\   s        r   create_notificationMediaClient.create_notification  s    ( 2: !>??r> !BCC $$,.!!L)!..0B0G0GH "  	r   )r   c                 h    US:X  a  [        S5      eU R                  [        R                  SU-   US9$ )z
Get the specific notification information

:param name: The notification name
:type name: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   r   /notification/r?   r&   r   r   r   s      r   get_notificationMediaClient.get_notification  s<     2: !>??!!,"2"24Dt4KTZ![[r   c                 h    US:X  a  [        S5      eU R                  [        R                  SU-   US9$ )z
Delete the specific notification

:param name: The notification name
:type name: string or unicode
:param config: None
:type config: BceClientConfiguration
:returns:
:rtype: baidubce.bce_response.BceResponse
r   r   r   r?   r{   r   s      r   delete_notificationMediaClient.delete_notification  s<     2: !>??!!,"5"57G$7NW]!^^r   c                 X    S nUb  [        X5      nUb  U$ [        U R                  U5      $ r   )getattrr   )r   r   attrresults       r   _get_config_parameter!MediaClient._get_config_parameter  s3    V*FMt{{D))r   c                     Uc  U R                   $ [        R                  " U R                   5      nUR                  U5        U$ r   )r   copymerge_non_none_values)r   r   
new_configs      r   _merge_configMediaClient._merge_config  s7    >;;4;;/J,,V4r   c           
      
   U R                  X5      nUc  [        R                  n[        R                  U-   n[
        R                  " U[        R                  [        R                  U/U[        R                  U5      X4U5      $ r   )r   r   rs   r   prefixr   send_requestr   signparse_errorstrencode)	r   http_methodpathr2   r3   r%   r   rD   realpaths	            r   r'   MediaClient._send_request  st    
 ##D1!,,K%%,++M&&)<)<k(JH-tfF 	Fr    r   )NNNN)NNN)
NNNNNNNNNN)NNNNN).__name__
__module____qualname____firstlineno____doc__r   r   r   bytesr   r,   r   r:   rA   rF   rN   rS   r]   r   rm   ru   rx   r}   r   r   r   r   r   r   r   r   r   intr   r   r   r   r   r   r   r   r   staticmethodr   r'   __static_attributes__r   r   r   r   r   %   s    F- UCL) "% *%N UCLdC D6 eS\" #$ eS\" #& eS\s|4 5.P clclcl$  '	$'R UCLK3FG
 	 H2 UCL)W *W  UCL)a *a UCL)d *d	N 5#,5#,?
 7 @7r 5#,T/BC
 	 D2 5#,'] (] 5#,'W (W  5#,'` (` UCL6 76 eS\"_ #_ UCL) 48.2,0/3& *&P s|CL!$ 	"  $!%%)!%'"
'R E3<(a )aQ E3<(d )d	T S\ 	< E3< \ !\ E3< _ !_*   -1	Fr   r   )r   r   r6   loggingbaidubce.bce_base_clientr   baidubce.authr   baidubce.bce_responser   baidubce.httpr   r   r   r	   r
   baidubce.exceptionr   r   baidubce.services.mediar   baidubce.utilsr   	getLoggerr   _loggerr   r   r   r   <module>r     sY       2 ' - ) ! , & & - - 1 #


H
%z
F- z
Fr   