
    VGh                     V    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
  G d de      Zy)	    N   )InfoExtractor   )	HTTPError)ExtractorErrorGeoRestrictedErrorfloat_or_nonetraverse_objtry_callc            
       <    e Zd ZdZdddddddd	g d
ddgZdZd Zy)OnDemandChinaEpisodeIEzThttps?://www\.ondemandchina\.com/\w+/watch/(?P<series>[\w-]+)/(?P<id>ep-(?P<ep>\d+))zEhttps://www.ondemandchina.com/en/watch/together-against-covid-19/ep-1264394mp4g(\q@zEP 1 The Callingu   第1集 令出如山zZhttps://d2y2efdi5wgkcl.cloudfront.net/fit-in/256x256/media-io/2020/9/11/image.d9816e81.jpgu<   疫情严峻，党政军民学、东西南北中协同应考)zSocial HumanitiesDocumentaryMedicalSocial)idextdurationtitle	alt_title	thumbnaildescriptiontags)url	info_dicta  
        query Episode($programSlug: String!, $episodeNumber: Int!) {
            episode(
                programSlug: $programSlug
                episodeNumber: $episodeNumber
                kind: "series"
                part: null
            ) {
                id
                title
                titleEn
                titleKo
                titleZhHans
                titleZhHant
                synopsis
                synopsisEn
                synopsisKo
                synopsisZhHans
                synopsisZhHant
                videoDuration
                images {
                    thumbnail
                }
            }
        }c                      j                  |      j                  ddd      \  }}} j                  ||       j                  d|ddit	        j
                  d j                  |t        |      dd	      j                         
      d   d   }	  j                  d|d    d|ddd      }g i }
}	t#        d      D ]  }|j%                  d      dk(  rI j'                  |j%                  d      |      \  }}|	j)                  |        j+                  ||
       ` j-                  d|j%                  d       |        t/        |d         t1        |j%                  d      d      t#        |d      xs  j3                  ddg      t#        |dd       xs'  j3                  d!d"g      xs  j5                        t#        |d#d$d%      t#        |d&d'd(d)d*      xs  j3                  g d+      |	|
t7         fd,      d-	S # t        $ rg}t        |j                  t              rB j                  |j                  j                  j                         |      d   }t!        |      Y d }~d }~ww xY w).Nseriesr   epz'https://odc-graphql.odkmedia.io/graphqlzContent-typezapplication/jsonEpisode)programSlugepisodeNumber)operationNamequery	variables)headersdatar'   episodez(https://odkmedia.io/odc/api/v2/playback// odc)Authorizationzservice-name)r&   detail)sources.typehlsr   )targetzUnsupported format videoDurationi  )imagesr   zog:imageztwitter:imager   titleEnzog:titleztwitter:titletitleKotitleZhHanstitleZhHant
synopsisEn
synopsisKosynopsisZhHanssynopsisZhHant	synopisis)zog:descriptionztwitter:descriptionr   c                  F     j                  d      j                  d      S )Nkeywordsz, )_html_search_metasplit)selfwebpages   b/var/www/it7/html/youtubeDownloader/venv/lib/python3.12/site-packages/yt_dlp/extractor/odkmedia.py<lambda>z6OnDemandChinaEpisodeIE._real_extract.<locals>.<lambda>h   s     T%;%;J%P%V%VW[%\     )	r   r   r   r   r   r   formats	subtitlesr   )_match_valid_urlgroup_download_webpage_download_jsonjsondumps_QUERYintencoder   
isinstancecauser   _parse_jsonresponsereadr   r
   get#_extract_m3u8_formats_and_subtitlesextend_merge_subtitlesreport_warningstrr	   r?   _html_extract_titler   )rA   r   program_slug
display_id	ep_number
video_infosource_jsone
error_datarF   rG   sourcefmtssubsrB   s   `             @rC   _real_extractz$OnDemandChinaEpisodeIE._real_extract8   s   .2.C.CC.H.N.NxY]_c.d+j)((j9((5z#%78!*#/%(^  vx ) 
  
! "+
,
	5--::d;K:LANPZ*,eD . FK  ";0@A 	\Fzz&!U*!EEfjjQVFWYcd
dt$%%d9%=##&9&**V:L9M$NPZ[	\ j&'%jnn_&EtL&z3JK \!33Z4QSZ[":w	B ;//_0MwW;11':%j)]MZ(L,8HJZ\gi m))*bdkl"\]
 	
  	5!''9-!--agg.>.>.C.C.EzRS[\
(44 .	5s   H
 
	I:AI55I:N)__name__
__module____qualname__
_VALID_URL_TESTSrN   rg    rE   rC   r   r      s?    hJV'/uYM	
 FF41
rE   r   )rL   commonr   networking.exceptionsr   utilsr   r   r	   r
   r   r   rm   rE   rC   <module>rq      s&     ! - [
] [
rE   