
    V|h                     R    S SK r S SKrSSKJrJr  SSKJr  SSKJr   " S S\5      r	g)	    N   )YoutubeTabBaseInfoExtractorYoutubeTabIE)	YoutubeIE   )traverse_objc                   P    \ rS rSrSrSrSrSrSSS.SSS./rS	 r	S
 r
S rS rSrg)YoutubeNotificationsIE	   zyoutube:notifz<YouTube notifications; ":ytnotif" keyword (requires cookies)z:ytnotif(?:ication)?s?Tz:ytnotif)urlonly_matchingz:ytnotificationsc              #      #    [        USS[        S9=(       d    / nS US'   U HL  nU R                  UR                  S5      5      nU(       a  Uv   UR                  S5      nU(       d  MH  XbS'   MN     g 7f)N)	actionsr   openPopupActionpopupmultiPageMenuRenderersectionsr   (multiPageMenuNotificationSectionRendereritems)r   r   appendContinuationItemsActioncontinuationItemsexpected_typer   notificationRenderercontinuationItemRenderer)r   list_extract_notification_rendererget)selfresponsecontinuation_listnotification_listitementrycontinuations          a/home/james-whalen/.local/lib/python3.13/site-packages/yt_dlp/extractor/youtube/_notifications.py_extract_notification_menu1YoutubeNotificationsIE._extract_notification_menu   s     ( TP	  & $&	 	
  $!%D77AW8XYE88$>?L|'3!$ &s   A%A4+	A4c                    [        US[        S9nSU 3nS nU(       dc  [        US[        S9nU R                  [        US[        S95      nU R	                  S[        US[        S9SS S	9nU(       a  U(       d  g S
U SU 3n[        US[        S9nU R                  US5      nU(       a  UR                  SS5      nU R	                  [        R                  " U=(       d    S5       S3USS S	9n	U R                  S[        S9(       a!  U R                  U R                  US5      5      OS n
SUU(       a  [        O[        R                  5       UU	UUUU R                  US5      U
S.
$ )N)navigationEndpointwatchEndpointvideoIdr   z https://www.youtube.com/watch?v=)r*   browseEndpointbrowseIdz
/post/(.+)canonicalBaseUrlzpost id)defaultz https://www.youtube.com/channel/z/community?lb=)	contextualMenumenuRendererr   r   menuServiceItemRenderertextrunsr   r4   shortMessage   ­ z[^:]+: (.+)zvideo titleapproximate_date)ie_keysentTimeTextr   videoThumbnail)
_typer   r:   video_idtitle
channel_idchanneluploader
thumbnails	timestamp)r   strdictucid_or_none_search_regex	_get_textreplacereescape_configuration_argr   _parse_time_textr   r:   _extract_thumbnails)r   notificationr>   r   r@   	browse_eppost_idrA   notification_titler?   rD   s              r&   r   5YoutubeNotificationsIE._extract_notification_renderer%   s   L\_a0
;
$FVZ\I**<	:]`+abJ((|I7IY\]4 ) )G W4ZLwiXC~ "^^L.I!3!;!;FB!G""		'-R()57I4 # ) //0B</X **4>>,+WX 	 $,y,FFH $22<AQR"
 	
    c              #   8  #    S /nS n[         R                  " S5       Hu  n[        US[        S9nU R	                  SU 3U(       a  SU0O0 USSU R                  XR                  U5      S9S	9nU R                  X25       S h  vN   US
   (       a  Mu    g    g  N7f)Nr   )r   continuationEndpointgetNotificationMenuEndpointctokenr   zpage rY   z"notification/get_notification_menur   )ytcfgvisitor_data)item_idqueryrZ   epcheck_get_keysheadersr   )	itertoolscountr   rE   _extract_responsegenerate_api_headers_extract_visitor_datar'   )r   rZ   r!   r    pagerY   s         r&   _notification_menu_entries1YoutubeNotificationsIE._notification_menu_entriesP   s     !FOOA&D!!#gwz|F--vFx.@PRZ_7	11LfLfgoLp1q . sH 66xSSS$Q'' ' Ts   B BBBBc                     SnU R                   (       d  U R                  SU5      O0 nU R                  U5        U R                  U R	                  U5      X"5      $ )Nnotificationsweb)skip_webpage_download_ytcfg_report_playlist_authcheckplaylist_resultrg   )r   r   
display_idrZ   s       r&   _real_extract$YoutubeNotificationsIE._real_extract^   sP    $
?C?P?P$$UJ7VX''.##D$C$CE$JJccrU    N)__name__
__module____qualname____firstlineno__IE_NAMEIE_DESC
_VALID_URL_LOGIN_REQUIRED_TESTSr'   r   rg   rq   __static_attributes__rs   rU   r&   r
   r
   	   sK    GLG*JO "F4)
VdrU   r
   )
ra   rK   _tabr   r   _videor   utilsr   r
   rs   rU   r&   <module>r      s%     	 ;  !Yd8 YdrU   