o
    iI                     @   st   d dl Z d dlZddlmZ ddlmZ ddlmZm	Z	m
Z
mZmZmZmZ ddlmZmZmZ G dd	 d	eZdS )
    N   )BrightcoveNewIE)InfoExtractor   )
clean_htmlint_or_noneparse_durationparse_iso8601smuggle_urlstr_or_noneurl_or_none)requiretraverse_objtrim_strc                   @   s  e Zd ZdZdZdi dddddd	d
ddddddd	dddddddddddddddddd d!d"d#d$id%d&i 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.dddd/d0d$d1d%d2i dd3dddd4d)d*gd
d5dd6dd7dd4dd6dd8dddddd9dd:dd;dddd<d=d$d1d%gZd>Zd?d@ ZdAS )BTvoIETVOzChttps?://(?:www\.)?tvo\.org/video(?:/documentaries)?/(?P<id>[\w-]+)z?https://www.tvo.org/video/how-can-ontario-survive-the-trade-warid6377531034112extmp4titlez&How Can Ontario Survive the Trade War?descriptionz$md5:e7455d9cd4b6b1270141922044161457
display_idz%how-can-ontario-survive-the-trade-wardurationi  episode
episode_idepisode_numberr   seasonzSeason 1season_numberseriesz
TVO at AMO	series_idz
tvo-at-amotagszcount:17	thumbnailzre:https?://.+	timestampiָhupload_date20250904uploader_id18140038001)url	info_dictz1https://www.tvo.org/video/documentaries/the-pitch6382500333112z	The Pitch
categoriesDocumentariesz$md5:9d4246b70dce772a3a396c4bd84c8506z	the-pitchi#  zcount:8i`i20251109)r$   r&   z6https://www.tvo.org/video/documentaries/valentines-day6387298331112zValentine's Dayz$md5:b142149beb2d3a855244816c50cd2f14zvalentines-dayi1  r   zHow We Celebratezhow-we-celebratezcount:6ii20260206zPhttps://players.brightcove.net/18140038001/default_default/index.html?videoId=%sc                 C   s,  |  |}| jd|dditjddtj|jdiddd	d
	 dd d }t
|ddthtdhf}dt t| j| ddgi||dt
|dthtfdthtttfdthtfdthfdthtfdthfdthfddthtfdthfdthfd
t
|d dthtfd!thtd"d#htfd$fS )%NzAhttps://hmy0rc1bo2.execute-api.ca-central-1.amazonaws.com/graphqlzContent-Typezapplication/jsongetVideoslug/aM  query getVideo($slug: String) {
                  getTVOOrgVideo(slug: $slug) {
                    contentCategory
                    description
                    length
                    program {
                      nodeUrl
                      title
                    }
                    programOrder
                    publishedAt
                    season
                    tags
                    thumbnail
                    title
                    videoSource {
                      brightcoveRefId
                    }
                  }
                })operationName	variablesquery),:)
separators)headersdatar:   getTVOOrgVideovideoSourcebrightcoveRefIdzBrightcove IDurl_transparentgeo_countriesCA)_typeie_keyr(   r   r   r   contentCategoryr   lengthprogramOrderr   r!   .r"   publishedAt)
r   r+   r   r   r   r   r   r!   r"   r#   programnodeUrlz
/programs/)start)r   r    )	_match_id_download_jsonjsondumpsurllibparseurlparsepathrstripencoder   r   r   r   rB   r
   BRIGHTCOVE_URL_TEMPLATEr   filterallr   r   r   r	   r   )selfr(   r   
video_databrightcove_id rZ   H/home/ubuntu/.local/lib/python3.10/site-packages/yt_dlp/extractor/tvo.py_real_extract`   sX   




zTvoIE._real_extractN)__name__
__module____qualname__IE_NAME
_VALID_URL_TESTSrT   r\   rZ   rZ   rZ   r[   r      s    	
	
	
Er   )rL   urllib.parserN   
brightcover   commonr   utilsr   r   r   r	   r
   r   r   utils.traversalr   r   r   r   rZ   rZ   rZ   r[   <module>   s    $	