
    VGh1                     b   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mZmZmZmZmZmZmZmZmZm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!y)    N   )InfoExtractor   )HEADRequest)ExtractorErrorGeoRestrictedError
clean_htmldetermine_extfilter_dictint_or_nonejoin_nonemptyparse_durationremove_startstrip_or_nonetraverse_objtry_getunified_strdateunified_timestampupdate_url_queryurljoin
xpath_textc                   N    e Zd ZdZdgZdZd Zd
dZd Ze	d        Z
e	d        Zy	)	RaiBaseIEz7[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}ITFc                 H   | j                  ||ddd      }|D ]  }|j                  d      sd|d<   |j                  d      sd|d<   |d	   }t        j                  d
|      rd|d<   Pt        j                  d|      rd|d<   l|d   dk(  rd|d<   |d   dk(  sd|d<    |S )Nmp4hlsF)m3u8_idfatalacodecmp4avcodecavc1urlzchunklist(?:_b\d+)*_ao[_.]nonezchunklist(?:_b\d+)*_vo[_.])_extract_m3u8_formatsgetresearch)self	media_urlvideo_idfmtsfman_urls         ]/var/www/it7/html/youtubeDownloader/venv/lib/python3.12/site-packages/yt_dlp/extractor/rai.py_fix_m3u8_formatszRaiBaseIE._fix_m3u8_formats   s    ))xU * D  	)A55?$(55?$(hGyy6@$(8'B$(X;&("(AhKX;&("(AhK	)      c           
      $   d }t        j                  d|      sdd|igiS | j                  ||d|ddii | j                         dd	i
      }t	        |dd      dk7  r| j                  |       t	        |dd      dk(  }t        t	        |dd             }t	        |dd       }|s| j                  d       t	        |dd      dk(  }	t        |      }
g }|
dk(  r|j                  |dddd       n|
dk(  sd|v r"|j                  | j                  ||             n|
dk(  rDt        |j                  dd      ddd       }|j                  | j                  ||d!d"#             nN|
d$k(  r>t        t	        |d%            }|j                  ||d&kD  r|nd t!        d'|d()      d*       nt#        d+      |s|	d,u sd-|v r| j%                  | j&                  d,.       |s%|s#|j                  | j)                  ||||             t+        |||d/      S )0Nc                 ^    t        j                  dd|       } t        j                  dd|       S )Nz(\]\]>)[\r\n\t]+(</)z\1\2z(>)[\r\n\t]+(<!\[CDATA\[))r(   sub)ss    r0   	fix_cdataz3RaiBaseIE._extract_relinker_info.<locals>.fix_cdata7   s+     .!<A666!DDr2   z	https?://formatsr$   zDownloading XML metadataoutput@   z
User-AgentRai)notetransform_sourcequeryheadersz./license_urlz{}defaultz	./is_liveNYz
./durationz./url[@type="content"]z"The relinker returned no media urlz./geoprotectionmp3r%   z	https-mp3)r$   r"   r    	format_idm3u8zformat=m3u8f4mzmanifest#live_hds.f4mzmanifest.f4mz3.7.0zaasp-3.7.0.39.44)hdcorepluginhdsF)f4m_idr   r   z	./bitrater   https-delim)r$   tbrrE   zUnrecognized media file foundTz/video_no_available.mp4)	countriesmetadata_available)is_livedurationr8   )r(   match_download_xmlgeo_verification_headersr   
report_drmr   raise_no_formatsr
   appendextendr1   r   replace_extract_f4m_formatsr   r   r   raise_geo_restricted_GEO_COUNTRIES_create_http_urlsr   )r*   relinker_urlr,   
audio_onlyr7   relinkerrS   rT   r+   geoprotectionextr8   manifest_urlbitrates                 r0   _extract_relinker_infoz RaiBaseIE._extract_relinker_info6   sX   	E xxl3 5677 %%()C&xnLt446LeL & N
 h>$FOOH%X{C@CG!*X|T"RSx)A4P	!!"FG #8->LPSSI&%<NN  (	  F]my8NN411)XFGE\+!!"9>J".@ACL NN444huE 5 C DE\!*X{"CDGNN ")A+w4*7G3G  !!@AAMT16OS\6\%%0C0CX\%]'NN411)\7T\]^ 
  	r2   c                    d}d}ddgddgddgddgddgd	d
gddgddgddgddgddgddgddgdd$dfd}	 | j                  t        ||dfz        |d       D 	cg c],  }	|	j                  d      dk7  r|	j                  d      dk7  r|	. c}	t        j                  ||      }
|
sg S |
j                  d      r |
j                  d      j                  d      ndg}g }t        d |      D ]8  }| j                  d |        |j                  |||fz  d!d"d# ||             : |S # t        $ r,}| j                  | d|j                          g cY d }~S d }~ww xY wc c}	w )%NzK/(?P<id>\w+)(?:_(?P<quality>[\d\,]+))?(?:\.mp4)?(?:\.csmil)?/playlist\.m3u8z%s&overrideUserAgentRule=mp4-%si`     i   i     i  i  i  i  i     @  i   i  i  i*  i  i8  )   i  iX  rk   i   i  i  i  i`	  i  i  i  i'  c                 x    | r| dk  ryt        || z
        t        t        |       t        |      z  dz  |      k  S )z9check if the target is in the range of number +/- percentr   Fg      Y@)absminfloat)numbertargetpcroofs       r0   
percentagez/RaiBaseIE._create_http_urls.<locals>.percentage   s<    VaZv'#eFmeBi.G%.OQU*VVVr2   c           	         dd l }t        |       }t              dk(  r|sd   j                  d      }|r|dkD  r|j	                  |dz        dz  } nd} d d g}D ]  }|j                  d      r | |d         r|j                         |d<   |j                  d      |j                  d      gj                  |       k(  sh|j                         |d<   | |d   d<    |d   xs	 |d   xs i }|rwd	|  |j                  d      |j                  d      |j                  d      xs | |j                  d
      xs d|j                  d      xs d|j                  d      xs ddS d	|  |    d   |    d   | ddddS )Nr   r   rP   i,  d   rn   widthheightzhttps-r"   r#   r    r!   fps   )rE   rz   r{   rP   r"   r    r|   )mathr   lenr'   floorcopy)rP   r~   brformat_copyr.   _QUALITYr-   rw   s        r0   get_format_infoz4RaiBaseIE._create_http_urls.<locals>.get_format_info   s   S!B4yA~b!W[['b3hjjc*S0  ,K 055<!#qx0)*AEE'NAEE(O4S8II%&VVXKN,/KN5)0 &a.@KN@bK   &cU^$1%//(3"u-4%//(3=v%//(3=v"u-3   &cU^!#q)"3-*  #r2   *zChecking MP4 availabilityz(: MP4 direct download is not available: r"   r%   r    quality,z"Creating https format for quality rL   r   )r$   protocolre   )   }   )_request_webpager   r   	to_screencauser'   r(   r)   groupsplitfilterwrite_debugrZ   )r*   rf   ra   r-   r,   _MANIFEST_REG	_MP4_TMPLr   er.   mobjavailable_qualitiesr8   qr   rw   s      `          @@r0   r`   zRaiBaseIE._create_http_urls}   s   f5	 sssss**++++,$<
"	W'	T	!!Is(;;<hHce   La55?f,xF1J  L yy5IBF**YBWdjj399#>^a]b12 	AA!EFNN L!#44# "!$	 	 -  	NNhZ'OPQPWPWyYZI	
Ls#   !D0 #1E(0	E%9!E E% E%c                 l    | xs i j                         D cg c]  }|rdt        ||      i c}S c c}w )Nr$   )valuesr   )thumbsr$   	thumb_urls      r0   _get_thumbnails_listzRaiBaseIE._get_thumbnails_list   sE     #Lb002Ai 73	*
 A 	A As   1c           	         d}d}i }|j                  d      xs |j                  d      xs g }dD ]$  }|j                  d|j                  |      i       & |D ]  }|j                  d      }|st        |t              s(|j                  d      xs d}	t	        | |      }t        ||      }
|j                  |	g       j                  |
|d	       ||
k(  s||	   j                  ||d t        |        |z   d	        |S )
NstlsrtsubtitlesArraysubtitleList)	subtitlessubtitlesUrlr$   languageit)re   r$   )r'   rZ   
isinstancestrr   r
   
setdefaultr   )r$   
video_dataSTL_EXTSRT_EXTr   subtitles_arrayksubtitlesub_urlsub_langsub_exts              r0   _extract_subtitleszRaiBaseIE._extract_subtitles   s   	$..)9:bjnn^>\b`b. 	?A""E:>>!+<#=>	?' 	Hll5)G:gs3#<<
3;t!#w/'9$$Xr299"";  g%h'..&&~W6@0 	 r2   N)F)__name__
__module____qualname___UUID_REr_   _GEO_BYPASSr1   rh   r`   staticmethodr   r    r2   r0   r   r      sP    IHVNK.EN]~ A A
  r2   r   c                      e Zd Zdej                   dZd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idddd d!d"d#d$d%dd&d'id(d)d*i dd+ddd	d,dd-dd.dd/dd0dd1dd2dd3dd4d5d6dd7d8d6dd9d!d:d#d;d%d<id&d'id=gd>d?d@dAddBdCdDdEdFdGd4dHdId6dJdKdLdMdNdOdPdQddRdSdTddUdVdgdWdXdYdZd[d\d]dNd^d'd_d`d'd_dad'd_gZdb Zyc)d	RaiPlayIEz3(?P<base>https?://(?:www\.)?raiplay\.it/.+?-(?P<id>))\.(?:html|json)zbhttps://www.raiplay.it/video/2014/04/Report-del-07042014-cb27157f-9dd0-4aee-b788-b1f67643a391.html 8970abf8caf8aef4696e7b1f2adfc696idz$cb27157f-9dd0-4aee-b788-b1f67643a391re   r   titlezReport del 07/04/2014	alt_titleu6   St 2013/14 - Report - Espresso nel caffè - 07/04/2014descriptionz$md5:d730c168a58f4bb35600fc2f881ec04e	thumbnailz%re:^https?://www\.raiplay\.it/.+\.jpguploaderzRai 3creatorrT   i  seriesReportseasonz2013/14r   r   zcount:4release_yeari  episodeu    Espresso nel caffè - 07/04/2014	timestampiHNCSupload_date20140408r8   skip_downloadTr$   md5	info_dictparamszfhttps://www.raiplay.it/video/2021/11/Blanca-S1E1-Senza-occhi-b1255a4a-8e72-4a2f-b9f3-fc1308e00736.html aeda7243115380b2dd5e881fd42d949az$b1255a4a-8e72-4a2f-b9f3-fc1308e00736zBlanca - S1E1 - Senza occhiz St 1 Ep 1 - Blanca - Senza occhiz$md5:75f95d5c030ec8bac263b1212322e28cz+re:^https://www\.raiplay\.it/dl/img/.+\.jpgzRai PremiumzRai Fictioni]  BlancazSeason 1episode_numberr   i  season_numberzSenza occhiia20211119zcount:73Video not available. Likely due to geo-restriction.)r$   r   r   r   expected_warningszlhttps://www.raiplay.it/video/2012/09/S1E11---Tutto-cio-che-luccica-0cab3323-732e-45d6-8e86-7704acab6598.html a634d20e8ab2d43724c273563f6bf87az$0cab3323-732e-45d6-8e86-7704acab6598u+   Mia and Me - S1E11 - Tutto ciò che luccicau0   St 1 Ep 11 - Mia and Me - Tutto ciò che luccicaz$md5:4969e594184b1920c4c1f2b704da9deare:^https?://.*\.jpg$zRai Gulpz
Mia and Me   i  u   Tutto ciò che luccicaif`P20120924)r   re   r   r   r   r   r   r   r   r   r   r   r   r   r   )r$   r   r   zhttps://www.raiplay.it/video/2022/10/Ad-ogni-costo---Un-giorno-in-Pretura---Puntata-del-15102022-1dfd1295-ea38-4bac-b51e-f87e2881693b.html 572c6f711b7c5f2d670ba419b4ae3b08z$1dfd1295-ea38-4bac-b51e-f87e2881693bz=Ad ogni costo - Un giorno in Pretura - Puntata del 15/10/2022z1St 2022/23 - Un giorno in pretura - Ad ogni costoz$md5:4046d97b2687f74f06a8b8270ba5599fg     z@zDhttps://www.raiplay.it/dl/img/2022/10/12/1665586539957_2048x2048.pngzUn giorno in preturaz2022/23zAd ogni costoiEc20221011i  )r   re   r   r   r   r   rT   r   creatorsr   r   r   r   r   r   z^http://www.raiplay.it/video/2016/11/gazebotraindesi-efebe701-969c-4593-92f3-285f0d1ce750.html?r$   only_matchingzbhttps://www.raiplay.it/video/2020/12/Report---04-01-2021-2e90f1de-8eee-4de4-ac0e-78d21db5b600.htmlzhttps://www.raiplay.it/video/2021/06/Lo-straordinario-mondo-di-Zoey-S2E1-Lo-straordinario-ritorno-di-Zoey-3ba992de-2332-41ad-9214-73e32ab209f4.htmlc                    | j                  |      j                         \  }}| j                  | d|d      }t        |d      r| j	                  |       |d   }| j                  |d   |      }t        |j                  d      |j                  d      d	      }|j                  d
      }t        |j                  d      |j                  d      d	      }	i dt        |j                  d      d      xs |d|d|j                  d      dt        |	xs d       d|j                  d      dt        t        |d      xs |j                  d      xs d       dt        t        |d      xs |j                  d      xs d       dt        |j                  d            dt        |      d| j                  |j                  d      |      dt        |d       d!t        |      d
|r|j                         s|nd d"|j                  d#      d$t        |j                  d"            d%| j                  ||      d&t        t        |d'            |S )(N.jsonDownloading video JSON)rights_managementrightsdrmvideocontent_urldate_publishedtime_published rN   r   r   toptitle - r   ContentItem-
display_idr   namer   r   r   )program_infochannelr   r   )r   editorr   rT   r   
thumbnailsimagesr   )r   r   r   r   episode_titler   r   r   )
track_info	edit_year)_match_valid_urlgroups_download_jsonr   rX   rh   r   r'   r   r   r   r   r   r   isdigitr   )
r*   r$   baser,   mediar   relinker_infor   r   r   s
             r0   _real_extractzRaiPlayIE._real_extractf  s   ..s3::<h##fENH&>@ EFOOH%g33E-4H(S&II&'3C)DCQ8$!%))J"7:9NV[\	
,uyy?K8
(
 UYYv&
 y'8D9	

 599]3
 U$?@ 099Y'0+/1
 }U$>? /99X&/*.0
 uyy'<=
 *>:
 $33EIIh4GM
 l5*BC
  [0!
" 0@ft#
$ uyy1%
& k%))I*>?'
( 00e<)
* KU<W(XY+
, -
 	
r2   Nr   r   r   r   r   
_VALID_URL_TESTSr  r   r2   r0   r   r      s   G	HZHZG[[lmJs1
8
5
 ,
 Q	

 A
 A
 
 w
 
 h
 i
 $	*
 D
 9
 
  :!
" y#
& #D)-2 x1
8
5
 2
 ;	

 A
 G
 
 }
 
 h
 j
 a
 D
 Q
 }
  !
" :#
$ y%
( #D)ST38 ~18BKA1""   /#%
	. \18TLA_ 	,&#% 
	, p
 t eEfFP'
r2   r   c                   <    e Zd ZdZddddddddd	d
dddddd	idgZy)RaiPlayLiveIEzA(?P<base>https?://(?:www\.)?raiplay\.it/dirette/(?P<id>[^/?#&]+))z'http://www.raiplay.it/dirette/rainews24z$d784ad40-e0ae-4a69-aa76-37519d238a9c	rainews24r   zHre:^Diretta di Rai News 24 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$z$md5:4d00bcf6dc98b27c6ec480de329d1497zRai News 24TrS   20090502i<_Izcount:3)r   r   re   r   r   r   r   rS   live_statusr   r   r8   r   r$   r   r   Nr   r   r   r  r  r   r2   r0   r  r    sI    UJ88%_A%$$%# 
 #D)! Fr2   r  c                   >    e Zd ZdZdddddddd	dd
ddddgZd Zy)RaiPlayPlaylistIEz^(?P<base>https?://(?:www\.)?raiplay\.it/programmi/(?P<id>[^/?#&]+))(?:/(?P<extra_id>[^?#&]+))?z3https://www.raiplay.it/programmi/nondirloalmiocapo/nondirloalmiocapozNon dirlo al mio capoz$md5:98ab6b98f7f44c2843fd7d6f045f153br   r   r      r$   r   playlist_mincountzFhttps://www.raiplay.it/programmi/nondirloalmiocapo/episodi/stagione-2/z"Non dirlo al mio capo - Stagione 2   r$   r   playlist_countc                    | j                  |      j                         \  }}}| j                  | d|d      }|r|j                         j	                  d      }|j                  d      }g }|j                  d      xs g D ]@  }|j                  d      xs g D ]$  }	|rk|t        |j                  d      |	j                  d      d      j                  dd	      j                         k7  rTt        ||	j                  d      d
      }|	j                  d      }
|
s| j                  | d|
 d|
dd      }|s|j                  d      xs g D ]j  }|j                  d      }|st        ||      }|j                  | j                  |t        j                         t        j                  |                   l ' C | j                  |||t        |d             S )Nr   Downloading program JSON/r   blockssetsrN   r   rM   r   r   zDownloading content set JSONF)r   itemspath_id)ier,   c                     | d   d   S )Nr   r   r   xs    r0   <lambda>z1RaiPlayPlaylistIE._real_extract.<locals>.<lambda>  s    q'8'G r2   )r   r   r   upperrstripr'   r   r\   r   rZ   
url_resultr   ie_key	_match_idplaylist_resultr   )r*   r$   r   playlist_idextra_idprogramplaylist_titleentriesbr6   s_idmediasmr  	video_urls                  r0   r  zRaiPlayPlaylistIE._real_extract  s   &*&;&;C&@&G&G&I#k8%%fENK)CE ~~'..s3H V,++h'-2 	BAeeFm)r B=EE&M155=$EELWSRUEVW\W\W^_ %2>155=X]%^NuuT{,,fAdV5)42% - A  **W-3 BAeeI.G"  'W 5INN4??!i&6&6&8!*!4!4Y!? $3 $A BBB	B2 ##[.GGHJ 	Jr2   Nr   r   r   r  r  r  r   r2   r0   r  r    sP    rJ E%,A

  	 X%9A

 	F(&Jr2   r  c                   b    e Zd Zdej                   dZddddddd	d
ddddddddddidgZd Zy)RaiPlaySoundIEz8(?P<base>https?://(?:www\.)?raiplaysound\.it/.+?-(?P<id>r   zkhttps://www.raiplaysound.it/audio/2021/12/IL-RUGGITO-DEL-CONIGLIO-1ebae2a7-7cdb-42bb-842e-fe0d193e9707.htmlr   z$1ebae2a7-7cdb-42bb-842e-fe0d193e9707rD   z&Il Ruggito del Coniglio del 10/12/2021z$md5:0e6476cd57858bb0f3fcc835d305b455z$md5:2a17d2107e59a4a8faa0e18334139ee2zre:^https?://.+\.jpg$rai radio 2i5  Il Ruggito del Coniglioi|/a20211201)r   re   r   r   r   r   r   rT   r   r   r   r   r   r   Tr   c                 *   | j                  |      j                  dd      \  }}| j                  | d|d      }t        |d       }i }g }t	        t        |d            }|D ]5  }	| j                  |	|d      }|j                  |j                  d             7 t        |d	 d
 f      }
t        |dd      xs i }i ||xs ||t        |dd      t        |dt              |j                  d      t        |dt              t        |dt              t        |
      | j                  |j                  d      |      |j                  d      t        |j                  d            |j                  d      t        |j                  d            |dS )Nr   r   r   zDownloading audio JSONc                 4    t        t        | d   d      d      S )N
uniquenamer   zPage-)r   r   s    r0   r"  z.RaiPlaySoundIE._real_extract.<locals>.<lambda>  s    |L<R`4acj'k r2   ))downloadable_audioaudio)livecardsr   r=  r$   Tr8   c                 <    | d    d| j                  d      xs d S )Ncreate_dater   create_time r'   r   s    r0   r"  z.RaiPlaySoundIE._real_extract.<locals>.<lambda>  s'    a6F5Gq}I]IcacHd3e r2   c                     | d   d   S )Nr>  rA  r   r   s    r0   r"  z.RaiPlaySoundIE._real_extract.<locals>.<lambda>	  s    1V9]3K r2   podcast_info)r>  r?  r   r   r   )r   
media_name)expected_typer   )r   r   )r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r8   )r   r   r   r   setr   rh   r[   r'   r   r   r   r   )r*   r$   r   audio_idr   uidinfor8   	relinkersrr   rF  s               r0   r  zRaiPlaySoundIE._real_extract  s   ..s399&$Gh##tfENH>VWeklU,stu	 	0A..q(DADNN488I./	0 !)e)K)M N $E>;OPVTV

/"!%/B%e-IYfg 99]3$U,EUbc#E+CS`a*>:33L4D4DX4NPST"&&w/(8)<=yy1)%))I*>?
 	
r2   Nr  r   r2   r0   r5  r5    se    LYM_M_L``qrJ|18=?A1%/?$#%
 #D)% F*!
r2   r5  c                   8    e Zd ZdZdddddddd	d
ddd
ddidgZy)RaiPlaySoundLiveIEz?(?P<base>https?://(?:www\.)?raiplaysound\.it/(?P<id>[^/?#&]+)$)z"https://www.raiplaysound.it/radio2z$b00a50e6-f404-4af6-8f8c-ff3b9af73a44radio2r   z"re:Rai Radio 2 \d+-\d+-\d+ \d+:\d+z0re:^https://www\.raiplaysound\.it/dl/img/.+\.pngr6  zRai Radio 2raiplaysoundTrS   )
r   r   re   r   r   r   r   r   rS   r
  r   r  Nr  r   r2   r0   rP  rP     sC    SJ38":L%#%$
 #D) Fr2   rP  c                   <    e Zd ZdZdddddddd	d
ddddgZd Zy)RaiPlaySoundPlaylistIEz{(?P<base>https?://(?:www\.)?raiplaysound\.it/(?:programmi|playlist|audiolibri)/(?P<id>[^/?#&]+))(?:/(?P<extra_id>[^?#&]+))?z:https://www.raiplaysound.it/programmi/ilruggitodelconiglioilruggitodelconiglior7  z$md5:62a627b3a2d0635d08fa8b6e0a04f27er  A   r  zVhttps://www.raiplaysound.it/programmi/ilruggitodelconiglio/puntate/prima-stagione-1995z0ilruggitodelconiglio_puntate_prima-stagione-1995zPrima Stagione 1995)r   r   r   r  c           
         | j                  |      j                  ddd      \  }}| d}| j                  ||d      }rmj                  d      |dj	                  dd      z   z  }t        fd|j                  d	      xs g D              }| j                  t        d
|      |d      }t        |dd      xs g D cg c]E  }|j                  d      r2| j                  t        ||d         t        j                               G }}| j                  |||j                  d      t        |d            S c c}w )Nr   r   r*  r   r  r  _c              3   P   K   | ]  }|j                  d       v s|d     yw)weblinkr  NrD  ).0cr*  s     r0   	<genexpr>z7RaiPlaySoundPlaylistIE._real_extract.<locals>.<genexpr>Q  s)     khZ[Z_Z_`iZjNj)ks   &
&filterszhttps://www.raiplaysound.itz"Downloading program secondary JSONr?  )blockr?  r  )r  r   )rF  r   )r   r   r   r$  r\   nextr'   r   r   r%  r5  r&  r(  )	r*   r$   r   r)  r+  pathr\  r-  r*  s	           @r0   r  z$RaiPlaySoundPlaylistIE._real_extractI  sG   &*&;&;C&@&F&FvtU_&`#k8en%%c;8RSs+H3!1!1#s!;;;Kkgkk).D.JkkD))5t<kKoqG
 "'74FGM2!uuY OOGD!I,7N<Q<Q<SOT! !
 ##G['++g:N$0:Y$Z\ 	\!s   A
D;Nr3  r   r2   r0   rT  rT  4  sP     PJ L(.A

  	 hD*
 F&\r2   rT  c            
       |    e Zd Zdej                   dZddddddd	d
ddidgddddddddddddiddddgZd Zy)RaiIEz.https?://[^/]+\.(?:rai\.(?:it|tv))/.+?-(?P<id>z)(?:-.+?)?\.htmlzghttps://www.raisport.rai.it/dl/raiSport/media/rassegna-stampa-04a9f4bd-b563-40cf-82a6-aad3529cb4a9.htmlz$04a9f4bd-b563-40cf-82a6-aad3529cb4a9r   zTG PRIMO TEMPOzre:^https?://.*\.jpgi  20140612)r   re   r   r   rT   r   r   Tr   r$   r   r   r   zahttps://www.rai.it/dl/RaiTV/programmi/media/ContentItem-efb17665-691c-45d5-a60c-5301333cbb0c.htmlz$efb17665-691c-45d5-a60c-5301333cbb0czTG1 ore 20:00 del 03/11/2016z6TG1 edizione integrale ore 20:00 del giorno 03/11/2016r   i  20161103)r   re   r   r   r   rT   r   r  z`http://www.rai.it/dl/RaiTV/programmi/media/ContentItem-b63a4089-ac28-48cf-bca5-9f5b5bc46df5.htmlr   c                    | j                  |      }| j                  d| d|ddd      }|y d|d   v rHd	t        d
|j                  d      d      |d   |j                  d      d|j                  d      dgi}n(d|d   v r| j	                  |d   |      }nt        d      | j                  dD ci c]  }||j                  |       c}|      }|t        |j                  d      xs |j                  d            t        |j                  d            xs d |t        |j                  d            xs d t        |j                  d            t        |j                  d            | j                  ||      d|S c c}w )Nz8https://www.rai.tv/dl/RaiTV/programmi/media/ContentItem-z
.html?jsonr   Fi  )r   expected_statusAudiotyper8   rL   formatoAudiorM   rN   audioUrlr%   )rE   r$   re   r"   r    VideomediaUriznot a media file)imageimage_medium	image_300r   r   descauthordatelength)r   r   r   r   r   r   rT   r   )r'  r   r   r'   rh   r   r   r   r   r   r   )r*   r$   
content_idr   r  
image_typer   s          r0   r  zRaiIE._real_extract~  s   ^^C(
##FzlR\]0s $ T =eFm#!.w		.8QY\!] , 99^4$#ii7 M f% 77j8I:VM !344..B6 7:Z:.. 78;=

 "599V#4#J		'8JK(6):;Ct$%eii&9:Bd*599V+<=&uyy':;00e<

 

 
	
7s   5FNr  r   r2   r0   rc  rc  ^  s    B9CUCUBVVfgJx8%0%
 #D)ST s83S1%
 #D) r1F<&
r2   rc  c                       e Zd Zdej                   dZdej                   dgZddddd	d
dddddidddddddddddddidgddddgZdZd Z	y )!	RaiNewsIEz7https?://(www\.)?rainews\.it/(?!articoli)[^?#]+-(?P<id>)(?:-[^/?#]+)?\.html-<iframe[^>]+data-src="(?P<url>/iframe/[^?#]+?\.html)zhttps://www.rainews.it/video/2024/02/membri-della-croce-rossa-evacuano-gli-abitanti-di-un-villaggio-nella-regione-ucraina-di-kharkiv-il-filmato-dallucraina--31e8017c-845c-43f5-9c48-245b43c3a079.htmlz$31e8017c-845c-43f5-9c48-245b43c3a079r   z$md5:1e81364b09de4a149042bac3c7d36f0b   20240225rainewscount:2r   re   r   rT   r   r   r8   r   Tr  zhttps://www.rainews.it/dl/rainews/media/Weekend-al-cinema-da-Hollywood-arriva-il-thriller-di-Tate-Taylor-La-ragazza-del-treno-1632c009-c843-4836-bb65-80c33084a64b.htmlz$1632c009-c843-4836-bb65-80c33084a64bzXWeekend al cinema, da Hollywood arriva il thriller di Tate Taylor "La ragazza del treno"z"I film in uscita questa settimana.zre:^https?://.*\.png$iA  rf  zcount:8)r   re   r   r   r   rT   r   r8   zunable to extract player_datare  zhttps://www.rainews.it/iframe/video/2022/07/euro2022-europei-calcio-femminile-italia-belgio-gol-0-1-video-4de06a69-de75-4e32-a657-02f0885f8118.htmlr   newsc                 r   | j                  |      }| j                  ||      }| j                  d| j                   d|d|t        i       }|j                  d      }t        |dd      }|s	 t        j                  | |      S | j                  t        ||      |      }||j                  d
      xs$ |j                  d
      xs | j                  |      t        |j                  d            t        |j                  d      xs d       d|S # t        $ r  t        $ r}t        d|	      d }~ww xY w)Nz<raiz-player\s*data=\'player_data)r=   rA   r   
mediapolisr   zRelinker URL not found)r   r   rt  r   )r   r   r   r   )r'  _download_webpage_search_json_PLAYER_TAGr	   r'   r   rc  r  r   r   rh   r   _og_search_titler   r   )	r*   r$   r,   webpager  r   ra   r   r  s	            r0   r  zRaiNewsIE._real_extract  sE   >>#&((h7''D$$%%67-QY' ( 5 !__\2
#K}MH**455 33GC4NPXY  __W-j1HjDLaLabiLj*:>>&+AB%jnnX&>&F$G	

 
 	
 & ! H$%=QGGHs   .D D6$D11D6N)
r   r   r   r   r   r  _EMBED_REGEXr  r  r  r   r2   r0   ry  ry    s    KIL^L^K__stJDYEWEWDXX_`aL X8;%! 
 #D) y8o?1% 	
 #D)=>" e9 FB K
r2   ry  c            	       t    e Zd Zdej                   dZdej                   dgZddddd	d
dddddidgZdZy)RaiCulturaIEz:https?://(www\.)?raicultura\.it/(?!articoli)[^?#]+-(?P<id>rz  r{  r|  zhttps://www.raicultura.it/letteratura/articoli/2018/12/Alberto-Asor-Rosa-Letteratura-e-potere-05ba8775-82b5-45c5-a89d-dd955fbde1fb.htmlz$05ba8775-82b5-45c5-a89d-dd955fbde1fbr   z'Alberto Asor Rosa: Letteratura e poterei  20181206
raiculturar  r  r   Tr  culturaN)	r   r   r   r   r   r  r  r  r  r   r2   r0   r  r    sn    NyOaOaNbbvwJDYEWEWDXX_`aL Y8>%$ 
 #D) F Kr2   r  c            
       T    e Zd ZdZdddddddd	d
dddidddddd	ddddidgZd Zy)RaiSudtirolIEz1https?://raisudtirol\.rai\.it/.+media=(?P<id>\w+)z;https://raisudtirol.rai.it/la/index.php?media=Ptv1619729460Ptv1619729460r   z/Euro: trasmisciun d'economia - 29-04-2021 20:51zEuro: trasmisciun d'economia20210429z+re:https://raisudtirol\.rai\.it/img/.+\.jpgraisudtirolzcount:1)r   re   r   r   r   r   r   r8   r   Tr  zIhttps://raisudtirol.rai.it/it/kidsplayer.php?lang=it&media=GUGGUG_P1.smil	GUGGUG_P1z(GUGGUG! La Prospettiva - Die Perspektivezcount:6)r   re   r   r   r8   c                     | j                  |      }| j                  ||      }| j                  d|dd       }| j                  ddg|dd       }| j                  ddg|d	d       }t        |      }|d
k(  r| j	                  ||      }n6|dk(  rd| j                  |      ddddddg}ng }| j                  d|        |t        ||d      |r|nd t        |      t        d| j                  d|dd             d|dS )Nz#<span class="med_data">(.+?)</span>
video_dater@   z$<span class="med_title">(.+?)</span>ztitle: \'(.+?)\',video_titlez"sources:\s*\[\{file:\s*"(.+?)"\}\]z4<source\s+src="(.+?)"\s+type="application/x-mpegURL"r2  rF   r   z	https-mp4rl   rm   r}   r#   r!   )rE   r$   rz   r{   r|   r"   r    zUnrecognized media file: r   rN   zhttps://raisudtirol.rai.it/zimage: \'(.+?)\'video_thumbr  )r   r   r   r   r   r   r8   )
r'  r  _html_search_regexr
   r&   _proto_relative_urlrY   r   r   r   )	r*   r$   r,   r  r  r  r2  re   r8   s	            r0   r  zRaiSudtirolIE._real_extract  sf   >>#&((h7,,2G\SW - Y
--35I/K]D . 2 ++1C-E [$ , 0	
 I&&=00HEGE\(//	:   G G!!$=i["IJ ";
%H%/kT*:6 !>@W@W#WmT AX AK L%	
 		
r2   Nr3  r   r2   r0   r  r    sn    EJ M!G5%G% 	
 #D)  [?% 
 #D)F6(
r2   r  )"r(   commonr   
networkingr   utilsr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r5  rP  rT  rc  ry  r  r  r   r2   r0   <module>r     s    	 ! $    *_ _DQ
	 Q
hI ,<J <J~8
Y 8
v ('\] '\TF
I F
RB
	 B
J9 &E
I E
r2   