
    Ği                     R    d dl Z ddlmZ ddlmZ ddlmZmZ  G d de          ZdS )	    N   )BrightcoveNewIE)InfoExtractor   )ExtractorErrortraverse_objc                       e Zd ZdZdZddddddd	d
g ddd
dddddddd	ddddgdd
dddddddd	ddd d!d"d#dd$d%d&d'd	g d(dd)d*
dd+d,d-d.d,d-d/d,d-gZd0Zd1 Zd2 Zd3S )4
NZHeraldIEnzheraldz?https?://(?:www\.)?nzherald\.co\.nz/[\w\/-]+\/(?P<id>[A-Z0-9]+)z|https://www.nzherald.co.nz/nz/queen-elizabeth-death-nz-public-holiday-announced-for-september-26/CEOPBSXO2JDCLNK3H7E3BIE2FA/6312191736112mp4z-Focus: PM holds post-Cabinet press conferenceg(\m@202209121308227299001igczre:https?://.*\.jpg$z$md5:2f17713fcbfcfbe38bb9e7dfccbb0f2e)
idexttitledurationupload_dateuploader_id	timestamptags	thumbnaildescription)url	info_dictzUhttps://www.nzherald.co.nz/travel/pencarrow-coastal-trail/HDVTPJEPP46HJ2UEMK4EGD2DFI/6261791733001zPencarrow Coastal Traili1`20210701z$md5:d361aaa0c6498f7ac1bc4fc0a0aec1e4travelvideogK7AE@)
r   r   r   r   r   r   r   r   r   r   zhttps://www.nzherald.co.nz/nz/truck-driver-captured-cutting-off-motorist-on-state-highway-1-in-canterbury/FIHNJB7PLLPHWQPK4S7ZBDUC4I/6251114530001z4Truck travelling north from Rakaia runs car off roadiM `20210429z$md5:4cae7dfb7613ac4c73b9e73a75c6b5d7)r   r   r   r   r   r   r   zvideo removed)r   r   skipz}https://www.nzherald.co.nz/nz/politics/reserve-bank-rejects-political-criticisms-stands-by-review/2JO5Q4WLZRCBBNWTLACZMOP4RA/6315123873112iŐiczBFocus: Luxon on re-appointment of Reserve Bank governor Adrian Orr20221107z$md5:df2f1f7033a8160c66e28e4743f5d934)r   znz herald focuspoliticszpolitics videosgL7A`X@)
r   r   r   r   r   r   r   r   r   r   z}https://www.nzherald.co.nz/kahu/kaupapa-companies-my-taiao-supporting-maori-in-study-and-business/PQBO2J25WCG77VGRX7W7BVYEAI/T)r   only_matchingzthttps://nzherald.co.nz/the-country/video/focus-nzs-first-mass-covid-19-vaccination-event/N5I7IL3BRFLZSD33TLDLYJDGK4/z|https://www.nzherald.co.nz/the-vision-is-clear/news/tvic-damian-roper-planting-trees-an-addiction/AN2AAEPNRK5VLISDWQAJZB6ATQzRhttp://players.brightcove.net/1308227299001/S1BXZn8t_default/index.html?videoId=%sc                     t          j        | |          }|p'|                     dt           j         d|ddd          S )z?The initial webpage may include the brightcove player embed urlz%(?:embedUrl)\"\s*:\s*\"(?P<embed_url>)z	embed urlN	embed_url)defaultgroup)r   _extract_url_search_regex
_VALID_URL)selfwebpagebc_urls      ^C:\Users\betacode\Desktop\descargarYoutube\venv\Lib\site-packages\yt_dlp/extractor/nzherald.py_extract_bc_embed_urlz NZHeraldIE._extract_bc_embed_urlT   sV     -dG<< C++R_5ORRR[$k , C C 	C    c           	         |                      |          }|                     ||          }|                     |          }|s|                     |                     d|d          |          }|                    d          }|sIt          |dt                    }|r0|                     d|t          j
        |dd          dd	
          }t          |p|dddt                    }|sHt          |t                    r$t          |          dk    rt          dd          t          d          | j        |z  }|                     |d          S )Nz'Fusion\.globalContent\s*=\s*({.+?})\s*;zfusion metadatar   )customVideoembedr   )expected_typezEhttps://www.nzherald.co.nz/pf/api/v3/content/fetch/full-content-by-idnzh)r   site)query_website)r;   brightcoveId)content_elements.referentr   F)get_allr8   r   z#This article does not have a video.T)expectedz%Failed to extract brightcove video idBrightcoveNew)	_match_id_download_webpager3   _parse_jsonr-   getr   str_download_jsonjsondumps
isinstancedictlenr   BRIGHTCOVE_URL_TEMPLATE
url_result)	r/   r   
article_idr0   r1   fusion_metadatavideo_metadatacustom_video_idbc_video_ids	            r2   _real_extractzNZHeraldIE._real_extract[   s   ^^C((
((j99++G44 	@"..""#MwXijjlvx xO -0099N! p".@^nq"r"r"r" p%)%8%8_ak(,
/SX3Y3Y(Z(Zhmnn &9 &p &pN '1/ KS2 2 2K
  Rnd33 RN8K8Kq8P8P()NY]^^^^()PQQQ1K?Fv777r4   N)	__name__
__module____qualname__IE_NAMEr.   _TESTSrN   r3   rU    r4   r2   r
   r
      sr       GSJ R%H").'4E 	
 	
" k%2').E4!7+" 
 
" [%O').E  $
 
 S%'])E.SSS4" 
 
  S!
 
 J!
 
 R!
 
CEFN sC C C8 8 8 8 8r4   r
   )	rI   
brightcover   commonr   utilsr   r   r
   r[   r4   r2   <module>r_      s     ' ' ' ' ' ' ! ! ! ! ! ! 0 0 0 0 0 0 0 0o8 o8 o8 o8 o8 o8 o8 o8 o8 o8r4   