+
    W²Õi«  ã                   ó~   € R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHtH	t	 ^ RI
t
^RIHt ^RIHt RtRt ! R	 R
4      tR# )zÝDRM module is used to handle DRM operations with clock skew correction.
Currently the only DRM operation is generating the Sec-MS-GEC token value
used in all API requests to Microsoft Edge's online text-to-speech service.N)Údatetime)Útimezone)ÚDictÚOptional)ÚTRUSTED_CLIENT_TOKEN)ÚSkewAdjustmentErrorl    !l
 g    eÍÍAc                   óø   a € ] tR t^t o RtRt]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t	]V 3R	 lR
 l4       t
]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       tV 3R ltRtV tR# )ÚDRMz<
Class to handle DRM operations with clock skew correction.
g        c                ó$   <€ V ^8„  d   QhRS[ RR/# )é   Úskew_secondsÚreturnN©Úfloat)ÚformatÚ__classdict__s   "€ÚK/home/ubuntu/hermes-agent/venv/lib/python3.14/site-packages/edge_tts/drm.pyÚ__annotate__ÚDRM.__annotate__   s   ø€ ÷ /ñ /©Uð /°tñ /ó    c                ó@   € \         ;P                  V ,          un        R# )a  
Adjust the clock skew in seconds in case the system clock is off.

This method updates the `clock_skew_seconds` attribute of the DRM class
to the specified number of seconds.

Args:
    skew_seconds (float): The number of seconds to adjust the clock skew to.

Returns:
    None
N)r	   Úclock_skew_seconds)r   s   &r   Úadj_clock_skew_secondsÚDRM.adj_clock_skew_seconds   s   € ô 	×Ò ,Õ.×r   c                ó    <€ V ^8„  d   QhRS[ /# ©r   r   r   )r   r   s   "€r   r   r   ,   s   ø€ ÷ Cñ C¡ñ Cr   c                 ó   € \         P                  ! \        P                  4      P	                  4       \
        P                  ,           # )z
Gets the current timestamp in Unix format with clock skew correction.

Returns:
    float: The current timestamp in Unix format with clock skew correction.
)ÚdtÚnowÚtzÚutcÚ	timestampr	   r   © r   r   Úget_unix_timestampÚDRM.get_unix_timestamp+   s*   € ô vŠv”b—f‘f‹~×'Ñ'Ó)¬C×,BÑ,BÕBÐBr   c                ó6   <€ V ^8„  d   QhRS[ RS[S[,          /# )r   Údater   )Ústrr   r   )r   r   s   "€r   r   r   6   s   ø€ ÷ ñ ¡ð ©±%­ñ r   c                ó®   €  \         P                  ! V R4      P                  \        P                  R7      P                  4       #   \         d     R# i ; i)a  
Parses an RFC 2616 date string into a Unix timestamp.

This function parses an RFC 2616 date string into a Unix timestamp.

Args:
    date (str): RFC 2616 date string to parse.

Returns:
    Optional[float]: Unix timestamp of the parsed date string, or None if parsing failed.
z%a, %d %b %Y %H:%M:%S %Z)ÚtzinfoN)r   ÚstrptimeÚreplacer   r    r!   Ú
ValueError)r&   s   &r   Úparse_rfc2616_dateÚDRM.parse_rfc2616_date5   sF   € ð	ä—’˜DÐ"<Ó=ß‘¤§¡Ó'ß‘“ðøô
 ô 	Úð	ús   ‚AA ÁAÁAc                ó8   <€ V ^8„  d   QhRS[ P                  RR/# )r   Úer   N)ÚaiohttpÚClientResponseError)r   r   s   "€r   r   r   L   s%   ø€ ÷ Eñ E©×(CÑ(Cð EÈñ Er   c                ó˜  € V P                   f   \        R4      V hV P                   P                  RR4      pVe   \        V\        4      '       g   \        R4      V h\
        P                  V4      pVe   \        V\        4      '       g   \        RV 24      V h\
        P                  4       p\
        P                  W#,
          4       R# )a  
Handle a client response error.

This method adjusts the clock skew based on the server date in the response headers
and raises a SkewAdjustmentError if the server date is missing or invalid.

Args:
    e (Exception): The client response error to handle.

Returns:
    None
NzNo server date in headers.ÚDatezFailed to parse server date: )
Úheadersr   ÚgetÚ
isinstancer'   r	   r-   r   r#   r   )r0   Úserver_dateÚserver_date_parsedÚclient_dates   &   r   Úhandle_client_response_errorÚ DRM.handle_client_response_errorK   s°   € ð 9‰9ÒÜ%Ð&BÓCÈÐJØ%&§Y¡Y§]¡]°6¸4Ó%@ˆØÒ¤j°¼c×&BÒ&BÜ%Ð&BÓCÈÐJÜ.1×.DÑ.DÀ[Ó.QÐØÒ%¬ZÐ8JÌE×-RÒ-RÜ%Ø/°¨}Ð=óàðô ×,Ñ,Ó.ˆÜ×"Ñ"Ð#5Õ#CÖDr   c                ó    <€ V ^8„  d   QhRS[ /# r   ©r'   )r   r   s   "€r   r   r   g   s   ø€ ÷ Oñ O¡ñ Or   c                 ó"  € \         P                  4       p V \        ,          p W R,          ,          p V \        ^d,          ,          p V R \         2p\
        P                  ! VP                  R4      4      P                  4       P                  4       # )a¥  
Generates the Sec-MS-GEC token value.

This function generates a token value based on the current time in Windows file time format
adjusted for clock skew, and rounded down to the nearest 5 minutes. The token is then hashed
using SHA256 and returned as an uppercased hex digest.

Returns:
    str: The generated Sec-MS-GEC token value.

See Also:
    https://github.com/rany2/edge-tts/issues/290#issuecomment-2464956570
i,  z.0fÚascii)
r	   r#   Ú	WIN_EPOCHÚS_TO_NSr   ÚhashlibÚsha256ÚencodeÚ	hexdigestÚupper)ÚticksÚstr_to_hashs     r   Úgenerate_sec_ms_gecÚDRM.generate_sec_ms_gecf   s~   € ô" ×&Ñ&Ó(ˆð 	”Õˆð 	˜•Õˆð 	”˜3•Õˆð ˜s˜Ô$8Ð#9Ð:ˆô ~Š~˜k×0Ñ0°Ó9Ó:×DÑDÓF×LÑLÓNÐNr   c                ó    <€ V ^8„  d   QhRS[ /# r   r>   )r   r   s   "€r   r   r   ‰   s   ø€ ÷ -ñ -™3ñ -r   c                 óJ   € \         P                  ! ^4      P                  4       # )zA
Generates a random MUID.

Returns:
    str: The generated MUID.
)ÚsecretsÚ	token_hexrG   r"   r   r   Úgenerate_muidÚDRM.generate_muidˆ   s   € ô × Ò  Ó$×*Ñ*Ó,Ð,r   c                óR   <€ V ^8„  d   QhRS[ S[S[3,          RS[ S[S[3,          /# )r   r5   r   )r   r'   )r   r   s   "€r   r   r   “   s+   ø€ ÷  ñ  ¡4©©S¨¥>ð  ±d¹3Á¸8µnñ  r   c                ón   € V P                  4       pRV9  g   Q hR\        P                  4        R2VR&   V# )z®
Returns a copy of the given headers with the MUID header added.

Args:
    headers (dict): The original headers.

Returns:
    dict: The headers with the MUID header added.
ÚCookiezmuid=Ú;)Úcopyr	   rP   )r5   Úcombined_headerss   & r   Úheaders_with_muidÚDRM.headers_with_muid’   sC   € ð #Ÿ<™<›>ÐØÐ/Ô/Ð/Ð/Ø',¬S×->Ñ->Ó-@Ð,AÀÐ%CÐ˜Ñ"ØÐr   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # )r   r   r   )r   r   s   "€r   r   r      s   ø‡ ‚ ñ
 Ñ#ò r   r"   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ústaticmethodr   r#   r-   r;   rJ   rP   rX   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__)r   s   @r   r	   r	      s«   ø‡ € ñð !$Ðà÷/ó ð/ð ÷Có ðCð ÷ó ðð* ÷Eó ðEð4 ÷Oó ðOðB ÷-ó ð-ð ÷ ó ð ÷ ƒ r   r	   )r_   rC   rN   r   r   r   r   Útypingr   r   r1   Ú	constantsr   Ú
exceptionsr   rA   rB   r	   r"   r   r   Ú<module>rg      s;   ðñOó Û Ý #Ý #ß !ã å +Ý +à€	Ø
€÷L ó L r   