
    }i3                        d Z ddlmZmZ ddlZ ej
                  e      Z G d de      Z	 G d de	      Z
 G d d	e	      Z G d
 de	      Z G d de	      Z G d de      Z G d de	      Z G d de	      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d  d!e      Z G d" d#e      Z G d$ d%e      Z G d& d'e      Z G d( d)e      Z G d* d+e      Z G d, d-e      Z G d. d/e      Z G d0 d1e      Z G d2 d3e      Z  G d4 d5e      Z! G d6 d7e      Z" G d8 d9e      Z#y):z'Library specific exception definitions.    )PatternUnionNc                       e Zd ZdZy)PytubeFixErrorzBase pytubefix exception that all others inherit.

    This is done to not pollute the built-in exceptions, which *could* result
    in unintended errors being unexpectedly and incorrectly handled within
    implementers code.
    N__name__
__module____qualname____doc__     ?/usr/local/lib/python3.12/dist-packages/pytubefix/exceptions.pyr   r      s    r   r   c                   "     e Zd ZdZ fdZ xZS )MaxRetriesExceededz#Maximum number of retries exceeded.c                 $    t         |   d       y )Nz"Maximum number of retries exceeded)super__init__)self	__class__s    r   r   zMaxRetriesExceeded.__init__   s    =>r   )r   r	   r
   r   r   __classcell__r   s   @r   r   r      s    -? ?r   r   c                       e Zd ZdZy)HTMLParseErrorzHTML could not be parsedNr   r   r   r   r   r      s    "r   r   c                       e Zd ZdZy)ExtractErrorz Data extraction based exception.Nr   r   r   r   r   r      s    *r   r   c                   4     e Zd Zdef fdZed        Z xZS )	SABRErrormsgc                 F    || _         t        | 	  | j                          y N)r   r   r   )r   r   r   s     r   r   zSABRError.__init__   s    "r   c                     | j                   S r    )r   r   s    r   error_stringzSABRError.error_string#   s    xxr   r   r	   r
   strr   propertyr#   r   r   s   @r   r   r      s#    #C #  r   r   c                   6     e Zd ZdZdedeeef   f fdZ xZS )RegexMatchErrorz)Regex pattern did not return any matches.callerpatternc                 J    t         |   | d|        || _        || _        y)z
        :param str caller:
            Calling function
        :param str pattern:
            Pattern that failed to match
        z: could not find match for N)r   r   r)   r*   )r   r)   r*   r   s      r   r   zRegexMatchError.__init__*   s1     	h1';	= r   )	r   r	   r
   r   r%   r   r   r   r   r   s   @r   r(   r(   '   s'    3s U3<-@  r   r(   c                   6     e Zd Zddef fdZed        Z xZS )InterpretationErrorjs_urlc                 T    || _         || _        t        |   | j                         y r    )r.   reasonr   r   r#   )r   r.   r0   r   s      r   r   zInterpretationError.__init__:   s$    **+r   c                 \    | j                   rd| j                   d| j                    z   S dS )NzError interpreting player js: z	 reason:  )r0   r.   r"   s    r   r#   z InterpretationError.error_string?   s2    ]a]h]h/}=)DKK=@YYpnppr   r    r$   r   s   @r   r-   r-   9   s%    ,s ,
 q qr   r-   c                   8     e Zd ZdZdef fdZed        Z xZS )VideoUnavailablez
    Base video error.

    This is the base error type for all video errors.

    Call this if you can't group the error by known error type and it is not important to the developer.
    video_idc                 F    || _         t        | 	  | j                         yzN
        :param str video_id:
            A YouTube video identifier.
        N)r5   r   r   r#   r   r5   r   s     r   r   zVideoUnavailable.__init__U   s    
 !**+r   c                      | j                    dS )Nz is unavailabler5   r"   s    r   r#   zVideoUnavailable.error_string]   s    --00r   	r   r	   r
   r   r%   r   r&   r#   r   r   s   @r   r4   r4   L   s(    , , 1 1r   r4   c                   >     e Zd ZdZddedef fdZed        Z xZS )$VideoRemovedByYouTubeForViolatingTOSzfRaised when a video has been removed for violating YouTube's Community Guidelines or Terms of Service.r5   r0   c                 \    || _         |xs d| _        t        |   | j                          y)z
        :param str video_id:
            A YouTube video identifier.
        :param str reason:
            Optional reason text from YouTube.
        zIThis video has been removed for violating YouTube's Community Guidelines.Nr5   r0   r   r   r   r5   r0   r   s      r   r   z-VideoRemovedByYouTubeForViolatingTOS.__init__i   s*     !k k'r   c                 8    | j                    d| j                   S N r5   r0   r"   s    r   r#   z1VideoRemovedByYouTubeForViolatingTOS.error_stringt       --$++//r   r    r;   r   s   @r   r=   r=   f   s-    p	( 	(c 	( 0 0r   r=   c                   >     e Zd ZdZddedef fdZed        Z xZS )LiveStreamEndedz-Raised when the live event has already ended.r5   r0   c                 \    || _         |xs d| _        t        |   | j                          y)z
        :param str video_id:
            A YouTube video identifier.
        :param str reason:
            Reason for the error, defaults to a standard message.
        zThis live event has ended.Nr?   r@   s      r   r   zLiveStreamEnded.__init__~   s*     !< <'r   c                 8    | j                    d| j                   S rB   rD   r"   s    r   r#   zLiveStreamEnded.error_string   rE   r   r    r;   r   s   @r   rG   rG   {   s-    7	( 	(c 	( 0 0r   rG   c                   >     e Zd ZdZddedef fdZed        Z xZS )VideoBlockedByCopyrightzJRaised when a video is blocked in the user's country on copyright grounds.r5   r0   c                 \    || _         |xs d| _        t        |   | j                          y)
        :param str video_id:
            A YouTube video identifier.
        :param str reason:
            The reason for the error (optional).
        zQThis video contains content that is blocked in your country on copyright grounds.Nr?   r@   s      r   r   z VideoBlockedByCopyright.__init__   s*     !s s'r   c                 8    | j                    d| j                   S rB   rD   r"   s    r   r#   z$VideoBlockedByCopyright.error_string   rE   r   r    r;   r   s   @r   rK   rK      s-    T	( 	(c 	( 0 0r   rK   c                   >     e Zd ZdZddedef fdZed        Z xZS )VideoRemovedByUploaderz5Raised when a video has been removed by the uploader.r5   r0   c                 \    || _         |xs d| _        t        |   | j                          y)rM   z+This video has been removed by the uploaderNr?   r@   s      r   r   zVideoRemovedByUploader.__init__   s*     !M M'r   c                 8    | j                    d| j                   S rB   rD   r"   s    r   r#   z#VideoRemovedByUploader.error_string   rE   r   r    r;   r   s   @r   rP   rP      s-    ?	( 	(c 	( 0 0r   rP   c                   >     e Zd ZdZddedef fdZed        Z xZS )AccountTerminatedzLRaised when the YouTube account associated with a video has been terminated.r5   r0   c                 \    || _         |xs d| _        t        |   | j                          y)rM   zmThis video is no longer available because the YouTube account associated with this video has been terminated.Nr?   r@   s      r   r   zAccountTerminated.__init__   s3     ! 
> 	 	'r   c                 8    | j                    d| j                   S rB   rD   r"   s    r   r#   zAccountTerminated.error_string   rE   r   r    r;   r   s   @r   rT   rT      s-    V( (c ( 0 0r   rT   c                   4     e Zd Zdef fdZed        Z xZS )VideoPrivater5   c                 F    || _         t        | 	  | j                          yr7   r5   r   r   r8   s     r   r   zVideoPrivate.__init__       
 !'r   c                      | j                    dS )Nz is a private videor:   r"   s    r   r#   zVideoPrivate.error_string   s    -- 344r   r$   r   s   @r   rX   rX      s#    ( ( 5 5r   rX   c                   8     e Zd ZdZdef fdZed        Z xZS )MembersOnlyzVideo is members-only.

    YouTube has special videos that are only viewable to users who have
    subscribed to a content creator.
    ref: https://support.google.com/youtube/answer/7544492?hl=en
    r5   c                 F    || _         t        | 	  | j                          yr7   rZ   r8   s     r   r   zMembersOnly.__init__   r[   r   c                      | j                    dS )Nz is a members-only videor:   r"   s    r   r#   zMembersOnly.error_string   s    -- 899r   r;   r   s   @r   r^   r^      s(    ( ( : :r   r^   c                   4     e Zd Zdef fdZed        Z xZS )VideoRegionBlockedr5   c                 F    || _         t        | 	  | j                          yr7   rZ   r8   s     r   r   zVideoRegionBlocked.__init__   r[   r   c                      | j                    dS )Nz  is not available in your regionr:   r"   s    r   r#   zVideoRegionBlocked.error_string   s    -- @AAr   r$   r   s   @r   rb   rb      s%    ( ( B Br   rb   c                   4     e Zd Zdef fdZed        Z xZS )BotDetectionr5   c                 F    || _         t        | 	  | j                          yr7   rZ   r8   s     r   r   zBotDetection.__init__  r[   r   c                      | j                    dS )Nz This request was detected as a bot. DO NOT OPEN AN ISSUE! See more details at https://pytubefix.readthedocs.io/en/latest/user/po_token.htmlr:   r"   s    r   r#   zBotDetection.error_string  s     }}o ` a	br   r$   r   s   @r   rf   rf     s%    ( ( b br   rf   c                   8     e Zd Zdedef fdZed        Z xZS )PoTokenRequiredr5   client_namec                 T    || _         || _        t        |   | j                          y)z
        :param str video_id:
            A YouTube video identifier.
        :param str client_name:
            A YouTube client identifier.
        N)r5   rk   r   r   )r   r5   rk   r   s      r   r   zPoTokenRequired.__init__  s%     !&'r   c                 :    | j                    d| j                   dS )Nz The z client requires PoToken to obtain functional streams, See more details at https://pytubefix.readthedocs.io/en/latest/user/po_token.html)r5   rk   r"   s    r   r#   zPoTokenRequired.error_string  s,     }}oU4#3#3"4 5` a	br   r$   r   s   @r   rj   rj     s,    	( 	(3 	( b br   rj   c                   8     e Zd Zdedef fdZed        Z xZS )LoginRequiredr5   r0   c                 T    || _         || _        t        |   | j                          yr7   r?   r@   s      r   r   zLoginRequired.__init__'  $    
 !'r   c                 8    | j                    d| j                   S )Nz) requires login to view, YouTube reason: rD   r"   s    r   r#   zLoginRequired.error_string0  s!     }}oFt{{mT	Vr   r$   r   s   @r   ro   ro   &  s,    ( (c ( V Vr   ro   c                   4     e Zd Zdef fdZed        Z xZS )RecordingUnavailabler5   c                 F    || _         t        | 	  | j                          yr7   rZ   r8   s     r   r   zRecordingUnavailable.__init__8  r[   r   c                      | j                    dS )Nz0 does not have a live stream recording availabler:   r"   s    r   r#   z!RecordingUnavailable.error_string@  s    -- PQQr   r$   r   s   @r   rt   rt   7  s%    ( ( R Rr   rt   c                   8     e Zd ZdZdef fdZed        Z xZS )LiveStreamErrorzVideo is a live stream.r5   c                 F    || _         t        | 	  | j                          yr7   rZ   r8   s     r   r   zLiveStreamError.__init__H  r[   r   c                      | j                    dS )Nz' is streaming live and cannot be loadedr:   r"   s    r   r#   zLiveStreamError.error_stringP  s    -- GHHr   r;   r   s   @r   rx   rx   E  s(    !( ( I Ir   rx   c                   <     e Zd ZdZdedef fdZed        Z xZS )LiveStreamOfflinezThe live will start soonr5   r0   c                 T    || _         || _        t        |   | j                          y)z
        :param str video_id:
            A YouTube video identifier.
        :param str reason:
            reason for the error
        Nr?   r@   s      r   r   zLiveStreamOffline.__init__X  s$     !'r   c                 8    | j                    d| j                   S rB   rD   r"   s    r   r#   zLiveStreamOffline.error_stringc  rE   r   r;   r   s   @r   r|   r|   U  s-    "	( 	(c 	( 0 0r   r|   c                   8     e Zd ZdZdef fdZed        Z xZS )AgeRestrictedErrorz>Video is age restricted, and cannot be accessed without OAuth.r5   c                 F    || _         t        | 	  | j                          yr7   rZ   r8   s     r   r   zAgeRestrictedError.__init__l  r[   r   c                      | j                    dS )Nz= is age restricted, and can't be accessed without logging in.r:   r"   s    r   r#   zAgeRestrictedError.error_stringt  s    -- ]^^r   r;   r   s   @r   r   r   i  s(    H( ( _ _r   r   c                   4     e Zd Zdef fdZed        Z xZS )AgeCheckRequiredErrorr5   c                 F    || _         t        | 	  | j                          yr7   rZ   r8   s     r   r   zAgeCheckRequiredError.__init__z  r[   r   c                      | j                    dS )NzB has age restrictions and cannot be accessed without confirmation.r:   r"   s    r   r#   z"AgeCheckRequiredError.error_string  s    -- bccr   r$   r   s   @r   r   r   y  s%    ( ( d dr   r   c                   4     e Zd Zdef fdZed        Z xZS )AgeCheckRequiredAccountErrorr5   c                 F    || _         t        | 	  | j                          yr7   rZ   r8   s     r   r   z%AgeCheckRequiredAccountError.__init__  r[   r   c                      | j                    dS )NzZ may be inappropriate for some users. Sign in to your primary account to confirm your age.r:   r"   s    r   r#   z)AgeCheckRequiredAccountError.error_string  s     }}o O P	Qr   r$   r   s   @r   r   r     s%    ( ( Q Qr   r   c                   8     e Zd Zdedef fdZed        Z xZS )InnerTubeResponseErrorr5   clientc                 T    || _         || _        t        |   | j                          yr7   )r5   r   r   r   )r   r5   r   r   s      r   r   zInnerTubeResponseError.__init__  rq   r   c                 :    | j                    d| j                   dS )Nz : z/ client did not receive a response from YouTube)r5   r   r"   s    r   r#   z#InnerTubeResponseError.error_string  s#     }}oS-\]	_r   r$   r   s   @r   r   r     s,    ( (c ( _ _r   r   c            	       F     e Zd ZdZddedededef fdZed        Z xZS )	UnknownVideoErrorzUnknown video error.r5   statusr0   developer_messagec                    || _         || _        || _        || _        t        j                  d       t        j                  d| j                           t        j                  d| j                          t        j                  d| j                          t        j                  d| j                          t        j                  d       t        |   | j                          y)a)  
        :param str video_id:
            A YouTube video identifier.
        :param str status:
            The status code of the response.
        :param str reason:
            The reason for the error.
        :param str developer_message:
            The message from the developer.
        zUnknown Video Errorz
Video ID: zStatus: zReason: zDeveloper Message: zhPlease open an issue at https://github.com/JuanBindez/pytubefix/issues and provide the above log output.N)r5   r   r0   r   loggerwarningr   r   )r   r5   r   r0   r   r   s        r   r   zUnknownVideoError.__init__  s     !!2,-DMM?34$++/0$++/0,T-C-C,DEF0	
 	'r   c                 T    | j                    d| j                   d| j                   dS )Nz9 has an unknown error, check logs for more info [Status: z] [Reason: ])r5   r   r0   r"   s    r   r#   zUnknownVideoError.error_string  s8    -- YZ^ZeZeYffqrvr}r}q~~  A  	Ar   )NNNr;   r   s   @r   r   r     s>    ( (c (# (ad (: A Ar   r   )$r   typingr   r   logging	getLoggerr   r   	Exceptionr   r   r   r   r   r(   r-   r4   r=   rG   rK   rP   rT   rX   r^   rb   rf   rj   ro   rt   rx   r|   r   r   r   r   r   r   r   r   <module>r      s   - !  
		8	$Y ? ?#^ #+> + l $q. q&1~ 140+; 0*0& 0*0. 0*0- 0,0( 0.5# 5:" :*B) Bb# b"b& b&V$ V"R+ RI& I 0( 0(_) _ d, dQ#3 Q _- _$"A( "Ar   