U
    g"                     @   s  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mZ G dd deZG d	d
 d
eZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd  d eZG d!d" d"eZG d#d$ d$eZG d%d& d&eZG d'd( d(eZG d)d* d*eZ G d+d, d,eZ!G d-d. d.eZ"G d/d0 d0eZ#G d1d2 d2e"Z$G d3d4 d4e"Z%dS )5    N   )InfoExtractor   )	HTTPError)ExtractorErrordetermine_extfloat_or_noneint_or_noneremove_startstrip_or_nonetry_getunified_timestampc                   @   s@   e Zd ZdZi ZdddZdd Zdd Zd	d
 ZdddZ	dS )DPlayBaseIEz/(?P<id>[^/]+/[^/?#]+)Tc           	      C   s   ||f}|  |d}|r"|jp,| j|}|sd|i}|rLt j|d< | j|d |d|dd d d }|  |ds|| j|< d	| S )
NstrealmZdeviceIdtokenzDownloading token)querydata
attributeszBearer )Z_get_cookiesgetvalue_auth_token_cacheuuidZuuid4hex_download_json)	self
disco_base
display_idr   Zneeds_device_idkeyr   r   r    r   :/tmp/pip-unpacked-wheel-q5ljy6pj/yt_dlp/extractor/dplay.py	_get_auth   s,      
zDPlayBaseIE._get_authc                 C   sv   |  |jj dd }|d d }|d}|dkrF| j|d n|dkrZtdd	d
t|d d d d	d
d S )Nzutf-8errorsr   codezaccess.denied.geoblocked)	countries)zaccess.denied.missingpackagezinvalid.tokenzQThis video is only available for registered users. You may want to use --cookies.T)expectedZdetail)Z_parse_jsoncauseresponsereaddecoder   Zraise_geo_restrictedr   )r   egeo_countriesinfoerrorZ
error_coder   r   r    _process_errors)   s    
 zDPlayBaseIE._process_errorsc                 C   s   |  |||d|d< d S )NFAuthorization)r!   r   headersr   r   r   r   r   r    _update_disco_api_headers4   s    z%DPlayBaseIE._update_disco_api_headersc                 C   sT   | j |d | ||dd d d }g }| D ]\}}|||dd q0|S )Nzplayback/videoPlaybackInfo/)r1   r   r   	streamingurl)typer4   )r   itemsappendr   )r   r   video_idr1   r3   Zstreaming_list	format_idformat_dictr   r   r    _download_video_playback_info7   s$    
 
z)DPlayBaseIE._download_video_playback_info c           #      C   sj  |  dp|}| g}| d|i d| d}d|i}	| |	||| z,| j|d | ||	ddddd	d
dd}
W nH tk
r } z*t|jtr|jj	dkr| 
||  W 5 d }~X Y nX |
d d }|
d d }|d  }g }i }z| |||	}W nN tk
rL } z.t|jtr:|jj	dkr:| 
||  W 5 d }~X Y nX |D ]}t|tsfqR|d}|szqR|d}t|}|dks|dkr| j||ddd\}}|| | ||}nV|dks|dkr| j||ddddd\}}|| | ||}n|||d qRd  }}g }g }|
dpFg }t|tr|D ]}|d}|spqX|d} | dkr|d}n@| d kr|d!}!|!r||!t|d"t|d#d$ | d%kr|d}n$| d&krX|d}"|"rX||" qX|||t|d't|d(d)t|d*|t|d+t|d,|||||d-|id.S )/NZgeo_bypass_countryr$   zhttps:///ZRefererzcontent/videos/namezheight,src,widthzFdescription,episodeNumber,name,publishStart,seasonNumber,videoDurationzimages,primaryChannel,show,tags)zfields[channel]zfields[image]zfields[show]zfields[tag]zfields[video]include)r1   r   i  r   idr   i  r4   r5   ZdashZmpdF)Zmpd_idfatalZhlsm3u8mp4Zm3u8_native)Zentry_protocolZm3u8_idrA   )r4   r9   includedZchannelimagesrcwidthheight)r4   rG   rH   showtagdescriptionZvideoDurationi  ZpublishStartZseasonNumberZepisodeNumberreferer)r@   r   titlerK   duration	timestampseriesseason_numberepisode_numbercreatortags
thumbnailsformats	subtitlesZhttp_headers)	get_paramupperZ_initialize_geo_bypassr2   r   r   
isinstancer&   r   statusr.   stripr;   dictr   r   Z"_extract_mpd_formats_and_subtitlesextendZ_merge_subtitlesZ#_extract_m3u8_formats_and_subtitlesr7   listr	   r   r   r   )#r   r4   r   
disco_hostr   countrydomainr+   r   r1   videor*   r8   r,   rM   rV   rW   r3   r:   Z
format_urlr9   extZ	dash_fmtsZ	dash_subsZ	m3u8_fmtsZ	m3u8_subsrS   rP   rT   rU   rD   r   e_typerF   r>   r   r   r    _get_disco_api_infoC   s    
  
 

  

   

   









 zDPlayBaseIE._get_disco_api_infoN)T)r<   )
__name__
__module____qualname___PATH_REGEXr   r!   r.   r2   r;   rf   r   r   r   r    r      s   
r   c                   @   s&  e Zd Zdej Z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dddddi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/d0d1dd2dd3d4d5d6d7dd8d9d:d;d<d=d>d2dd3ddidd?dd@dAdd@dBdd@dCdd@dDdd@dEdd@dFdd@dGdd@gZdHdI ZdJS )KDPlayIEa9  (?x)https?://
        (?P<domain>
            (?:www\.)?(?P<host>d
                (?:
                    play\.(?P<country>dk|fi|jp|se|no)|
                    iscoveryplus\.(?P<plus_country>dk|es|fi|it|se|no)
                )
            )|
            (?P<subdomain_country>es|it)\.dplay\.com
        )/[^/]+zshttps://www.dplay.se/videos/nugammalt-77-handelser-som-format-sverige/nugammalt-77-handelser-som-format-sverige-101Z13628zWnugammalt-77-handelser-som-format-sverige/nugammalt-77-handelser-som-format-sverige-101rC   u    Svensken lär sig njuta av livetz$md5:d3819c9bccffd0fe458ca42451dd50d8gʡE@i+cQZ20130408zKanal 5u,   Nugammalt - 77 händelser som format Sveriger   r@   r   rd   rM   rK   rN   rO   upload_daterS   rP   rQ   rR   skip_downloadTr4   	info_dictparamszShttp://www.dplay.dk/videoer/ted-bundy-mind-of-a-monster/ted-bundy-mind-of-a-monsterZ104465z7ted-bundy-mind-of-a-monster/ted-bundy-mind-of-a-monsterzTed Bundy: Mind Of A Monsterz$md5:8b780f6f18de4dae631668b8a9637995gx@i ]Z20191010zID - Investigation Discoveryz=https://www.dplay.no/videoer/i-kongens-klr/sesong-1-episode-7Z40206z i-kongens-klr/sesong-1-episode-7	Episode 7z$md5:e3e1411b2b9aebeea36a6ec5d50c60cfgQf@ijgZZ20180123u   I kongens klær   )r@   r   rd   rM   rK   rN   rO   rm   rP   rQ   rR   Available for Premium users)r4   rp   rq   skipzZhttp://it.dplay.com/nove/biografie-imbarazzanti/luigi-di-maio-la-psicosi-di-stanislawskij/Z 2b808ffb00fc47b884a172ca5d13053cZ6918z@biografie-imbarazzanti/luigi-di-maio-la-psicosi-di-stanislawskijz*Luigi Di Maio: la psicosi di Stanislawskijz$md5:3c7a4303aef85868f867a26f5cc14813zre:^https?://.*\.jpe?gZ20160524i 
DWzBiografie imbarazzanti	Episode 1)r@   r   rd   rM   rK   	thumbnailrm   rO   rP   rQ   episoderR   )r4   md5rp   zChttps://es.dplay.com/dmax/la-fiebre-del-oro/temporada-8-episodio-1/Z21652z(la-fiebre-del-oro/temporada-8-episodio-1z
Episodio 1z$md5:b9dcff2071086e003737485210675f69zre:^https?://.*\.pngZ20180709iC[zLa fiebre del oro   zHhttps://www.dplay.fi/videot/shifting-gears-with-aaron-kaufman/episode-16r4   Zonly_matchingz*https://www.dplay.jp/video/gold-rush/24086z{https://www.discoveryplus.se/videos/nugammalt-77-handelser-som-format-sverige/nugammalt-77-handelser-som-format-sverige-101z\https://www.discoveryplus.dk/videoer/ted-bundy-mind-of-a-monster/ted-bundy-mind-of-a-monsterzEhttps://www.discoveryplus.no/videoer/i-kongens-klr/sesong-1-episode-7zdhttps://www.discoveryplus.it/videos/biografie-imbarazzanti/luigi-di-maio-la-psicosi-di-stanislawskijzLhttps://www.discoveryplus.es/videos/la-fiebre-del-oro/temporada-8-episodio-1zPhttps://www.discoveryplus.fi/videot/shifting-gears-with-aaron-kaufman/episode-16c                 C   sr   |  |}|d}t|dd}|dp@|dp@|d}|d dkrVd	| nd
}| |||d| ||S )Nr@   rb   zwww.ra   Zsubdomain_countryZplus_countryr   dz
disco-api.zeu2-prod.disco-api.comdplay)_match_valid_urlgroupr
   rf   )r   r4   Zmobjr   rb   ra   hostr   r   r    _real_extract8  s    

     zDPlayIE._real_extractN)rg   rh   ri   r   rj   
_VALID_URL_TESTSr   r   r   r   r    rk      s   	    zrk   c                   @   s,   e Zd ZdZdZdd Zdd Zdd Zd	S )
DiscoveryPlusBaseIEz/Subclasses must set _PRODUCT, _DISCO_API_PARAMSz27.43.0c              	   C   s>   | d| d| j d| j d| j | |||d d S )Nrealm=,siteLookupKey=WEB:UNKNOWN::x-disco-paramsx-disco-clientr/   update_PRODUCT_DISCO_CLIENT_VERr!   r0   r   r   r    r2   G  s
    z-DiscoveryPlusBaseIE._update_disco_api_headersc              
   C   s:   | j |d ||tddd|i d dd d d S )	Nzplayback/v3/videoPlaybackInfoF)Z	adBlockerZdrmSupported)Z
deviceInfoZvideoIdZwisteriaProperties)r1   r   r   r   r3   )r   jsondumpsencode)r   r   r8   r1   r   r   r    r;   N  s$      
			z1DiscoveryPlusBaseIE._download_video_playback_infoc                 C   s   | j || |f| jS )N)rf   Z	_match_id_DISCO_API_PARAMS)r   r4   r   r   r    r   Z  s    z!DiscoveryPlusBaseIE._real_extractN)rg   rh   ri   __doc__r   r2   r;   r   r   r   r   r    r   B  s
   r   c                   @   s^   e Zd Zdej Zdddddddd	d
d	dddddgg dddgZdZddddZdd Z	dS )HGTVDeIEz https?://de\.hgtv\.com/sendungenzNhttps://de.hgtv.com/sendungen/mein-kleinstadt-traumhaus/vom-landleben-ins-loftZ7332936rC   z0mein-kleinstadt-traumhaus/vom-landleben-ins-loftzVom Landleben ins Loftz$md5:e5f72c02c853970796dd3818f2e25745rr   rs   Season 7zMein Kleinstadt-Traumhausg     @ifZ20240910HGTVzZhttps://eu1-prod-images.disco-api.com/2024/08/09/82a386b9-c688-32c7-b9ff-0b13865f0bae.jpeg)r@   rd   r   rM   rK   rx   rR   seasonrQ   rP   rN   rO   rm   creatorsrT   rw   r4   rp   hgtveu1-prod.disco-api.comder`   r   ra   c              	   C   s&   | d| d| |||d d S Nr   zAlps:HyogaPlayer:0.0.0r   r   r!   r0   r   r   r    r2   }  s
    z"HGTVDeIE._update_disco_api_headersN
rg   rh   ri   r   rj   r   r   r   r   r2   r   r   r   r    r   ^  s4   
r   c                   @   sx   e Zd Zdej Zdddddddd	dd
ddddg dgdddddddddddddddddgZdZd d!d"d#Zd$S )%GoDiscoveryIEz&https?://(?:go\.)?discovery\.com/videoz]https://go.discovery.com/video/in-the-eye-of-the-storm-discovery-atve-us/trapped-in-a-twisterZ5352642z>in-the-eye-of-the-storm-discovery-atve-us/trapped-in-a-twisterrC   zTrapped in a TwisterzJTwisters destroy Midwest towns, trapping spotters in the eye of the storm.r   rv   Season 1zIn The Eye Of The StormgNbXyt@Z20240715ifZ	DiscoveryzZhttps://us1-prod-images.disco-api.com/2024/07/10/5e39637d-cabf-3ab3-8e9a-f4e9d37bc036.jpeg)r@   r   rd   rM   rK   rR   rx   rQ   r   rP   rN   rm   rO   rT   r   rw   r   zPhttps://go.discovery.com/video/dirty-jobs-discovery-atve-us/rodbuster-galvanizerZ4164906z1dirty-jobs-discovery-atve-us/rodbuster-galvanizerzRodbuster / GalvanizerzHMike installs rebar with a team of rodbusters, then he galvanizes steel.	   r@   r   rd   rM   rK   rQ   rR   rt   r4   rp   ru   zMhttps://discovery.com/video/dirty-jobs-discovery-atve-us/rodbuster-galvanizerTr{   Zdscz us1-prod-direct.go.discovery.comgousr   N	rg   rh   ri   r   rj   r   r   r   r   r   r   r   r    r     sP   
	%r   c                   @   sx   e Zd Zdej Zdddddddd	d
dddddg dgdddddddddddddddddgZd Zd!d"d#d$Zd%S )&TravelChannelIEz-https?://(?:watch\.)?travelchannel\.com/videozXhttps://watch.travelchannel.com/video/the-dead-files-travel-channel/protect-the-childrenZ4710177z2the-dead-files-travel-channel/protect-the-childrenrC   zProtect the ChildrenzAAn evil presence threatens an Ohio woman's children and marriage.   z	Season 14
   z
Episode 10zThe Dead FilesgʡE@ii6cZ20220930zTravel ChannelzZhttps://us1-prod-images.disco-api.com/2022/03/17/5e45eace-de5d-343a-9293-f400a2aa77d5.jpeg)r@   r   rd   rM   rK   rQ   r   rR   rx   rP   rN   rO   rm   rT   r   rw   r   zXhttps://watch.travelchannel.com/video/ghost-adventures-travel-channel/ghost-train-of-elyZ2220256z2ghost-adventures-travel-channel/ghost-train-of-elyzGhost Train of ElyzFThe crew investigates the dark history of the Nevada Northern Railway.   r   r   rt   r   Tr{   Ztravz'us1-prod-direct.watch.travelchannel.comr   r   r   Nr   r   r   r   r    r     sP   
	%r   c                   @   sx   e Zd Zdej Zdddddddd	d
dddddg dgdddddddddddddddddgZdZd d!d"d#Zd$S )%CookingChannelIEz0https?://(?:watch\.)?cookingchanneltv\.com/videoznhttps://watch.cookingchanneltv.com/video/bobbys-triple-threat-food-network-atve-us/titans-vs-marcus-samuelssonZ5350005rC   zEbobbys-triple-threat-food-network-atve-us/titans-vs-marcus-samuelssonzTitans vs Marcus SamuelssonzCMarcus Samuelsson throws his legendary global tricks at the Titans.r   rv      zSeason 3zBobby's Triple ThreatgˡE@Z20240710iݍfFood NetworkzZhttps://us1-prod-images.disco-api.com/2024/07/04/529cd095-27ec-35c5-84e9-90ebd3e5d2da.jpeg)r@   rd   r   rM   rK   rR   rx   rQ   r   rP   rN   rm   rO   rT   r   rw   r   zmhttps://watch.cookingchanneltv.com/video/carnival-eats-cooking-channel/the-postman-always-brings-rice-2348634Z2348634zDcarnival-eats-cooking-channel/the-postman-always-brings-rice-2348634zThe Postman Always Brings RicezFNoah visits the Maui Fair and the Aurora Winter Festival in Vancouver.r   r   rt   r   Tr{   Zcookz*us1-prod-direct.watch.cookingchanneltv.comr   r   r   Nr   r   r   r   r    r     sP   
	%r   c                   @   sp   e Zd Zdej Zddddddddd	d
g dgdddddddddddddddddgZdZddddZdS ) 	HGTVUsaIEz$https?://(?:watch\.)?hgtv\.com/videozahttps://watch.hgtv.com/video/flip-or-flop-the-final-flip-hgtv-atve-us/flip-or-flop-the-final-flipZ5025585zDflip-or-flop-the-final-flip-hgtv-atve-us/flip-or-flop-the-final-fliprC   zFlip or Flop: The Final FlipzFTarek and Christina are going their separate ways after one last flip!g?5^I)@Z20231101i@Aer   zZhttps://us1-prod-images.disco-api.com/2022/11/27/455caa6c-1462-3f14-b63d-a026d7a5e6d3.jpeg)r@   r   rd   rM   rK   rP   rN   rm   rO   rT   r   rw   r   zLhttps://watch.hgtv.com/video/home-inspector-joe-hgtv-atve-us/this-mold-houseZ4289736z/home-inspector-joe-hgtv-atve-us/this-mold-housezThis Mold HousezGJoe and Noel help take a familys dream home from hazardous to fabulous.r   r   rt   r   Tr{   r   zus1-prod-direct.watch.hgtv.comr   r   r   Nr   r   r   r   r    r     sH   
	!r   c                   @   sx   e Zd Zdej Zdddddddd	dd
dg dgddddddddddddddddddddgZdZdd d!d"Zd#S )$FoodNetworkIEz+https?://(?:watch\.)?foodnetwork\.com/videozVhttps://watch.foodnetwork.com/video/guys-grocery-games-food-network/wild-in-the-aislesZ2152549z2guys-grocery-games-food-network/wild-in-the-aislesrC   zWild in the AisleszGThe chefs make spaghetti and meatballs with "Out of Stock" ingredients.r   r   rv   zGuy's Grocery Gamesr   gd;OM@20230623dzZhttps://us1-prod-images.disco-api.com/2022/06/15/37fb5333-cad2-3dbb-af7c-c20ec77c89c6.jpegr@   r   rd   rM   rK   rQ   r   rR   rx   rP   rT   r   rN   rm   rO   rw   r   z`https://watch.foodnetwork.com/video/kids-baking-championship-food-network/float-like-a-butterflyZ4116449z<kids-baking-championship-food-network/float-like-a-butterflyzFloat Like a Butterflyz9The 12 kid bakers create colorful carved butterfly cakes.r   r   rt   r   Tr{   Zfoodz%us1-prod-direct.watch.foodnetwork.comr   r   r   Nr   r   r   r   r    r   =  sP   
	%r   c                   @   sx   e Zd Zdej Zdddddddd	d
ddg dgddddddddddddd
d
ddddddgZdZdd d!d"Zd#S )$DestinationAmericaIEz0https?://(?:www\.)?destinationamerica\.com/videoz\https://www.destinationamerica.com/video/bbq-pit-wars-destination-america/smoke-on-the-waterZ2218409z3bbq-pit-wars-destination-america/smoke-on-the-waterrC   zSmoke on the WaterzGThe pitmasters head to Georgia for the Smoke on the Water BBQ Festival.r   zSeason 2r   rv   zBBQ Pit WarszDestination AmericagK7m@r   r   zZhttps://us1-prod-images.disco-api.com/2020/05/11/c0f8e85d-9a10-3e6f-8e43-f6faafa81ba2.jpegr   r   zlhttps://www.destinationamerica.com/video/alaska-monsters-destination-america-atve-us/central-alaskas-bigfootZ4210904zCalaska-monsters-destination-america-atve-us/central-alaskas-bigfootzCentral Alaskas BigfootzDA team heads to central Alaska to investigate an aggressive Bigfoot.r   rt   r   Tr{   Zdamz&us1-prod-direct.destinationamerica.comr   r   r   Nr   r   r   r   r    r   l  sP   
	%r   c                   @   sx   e Zd Zdej Zdddddddd	d
dddgg ddddddddddddddddddddgZdZdd d!d"Zd#S )$InvestigationDiscoveryIEz4https?://(?:www\.)?investigationdiscovery\.com/videozhttps://www.investigationdiscovery.com/video/deadly-influence-the-social-media-murders-investigation-discovery-atve-us/rip-biancaZ5341132zTdeadly-influence-the-social-media-murders-investigation-discovery-atve-us/rip-biancarC   z
RIP BiancazJA teenage influencer discovers an online world of threat, harm and danger.r   r   r   z	Episode 3z*Deadly Influence: The Social Media MurderszInvestigation Discoverygu@Z20240618ipfzZhttps://us1-prod-images.disco-api.com/2024/06/15/b567c774-9e44-3c6c-b0ba-db860a73e812.jpeg)r@   r   rd   rM   rK   rQ   r   rR   rx   rP   r   rT   rN   rm   rO   rw   r   z^https://www.investigationdiscovery.com/video/unmasked-investigation-discovery/the-killer-clownZ2139409z1unmasked-investigation-discovery/the-killer-clownzThe Killer ClownzKA wealthy Florida woman is fatally shot in the face by a clown at her door.r   rt   r   Tr{   idsz*us1-prod-direct.investigationdiscovery.comr   r   r   Nr   r   r   r   r    r     sP   
	%r   c                   @   sx   e Zd Zdej Zdddddddd	dd
dddddgg dddddddddddddddddgZdZddd d!Zd"S )#AmHistoryChannelIEz#https?://(?:www\.)?ahctv\.com/videozThttps://www.ahctv.com/video/blood-and-fury-americas-civil-war-ahc/battle-of-bull-runZ2139199z8blood-and-fury-americas-civil-war-ahc/battle-of-bull-runrC   zBattle of Bull RunzDTwo untested armies clash in the first real battle of the Civil War.r   r   rv   z#Blood and Fury: America's Civil WargT㥛i@Z20220923i@/-cZAHCzZhttps://us1-prod-images.disco-api.com/2020/05/11/4af61bd7-d705-3108-82c4-1a6e541e20fa.jpegr@   r   rd   rM   rK   rQ   r   rR   rx   rP   rN   rm   rO   r   rT   rw   r   z2https://www.ahctv.com/video/modern-sniper-ahc/armyZ2309730zmodern-sniper-ahc/armyZArmyzISnipers today face challenges their predecessors couldve only dreamed of.r   rt   r   Tr{   Zahczus1-prod-direct.ahctv.comr   r   r   Nr   r   r   r   r    r     sP   
	%r   c                   @   sx   e Zd Zdej Zdddddddd	d
ddddddgg dddddddddd
d
ddddddgZdZdd d!d"Zd#S )$ScienceChannelIEz,https?://(?:www\.)?sciencechannel\.com/videozghttps://www.sciencechannel.com/video/spaces-deepest-secrets-science-atve-us/mystery-of-the-dead-planetsZ2347335zBspaces-deepest-secrets-science-atve-us/mystery-of-the-dead-planetsrC   zMystery of the Dead Planetsz>Astronomers unmask the truly destructive nature of the cosmos.rs   r   r   rv   zSpace's Deepest Secretsg}?5^@Z20230128iЫcZSciencezZhttps://us1-prod-images.disco-api.com/2021/03/30/3796829d-aead-3f9a-bd8d-e49048b3cdca.jpegr   r   zZhttps://www.sciencechannel.com/video/strangest-things-science-atve-us/nazi-mystery-machineZ2842849z5strangest-things-science-atve-us/nazi-mystery-machinezNazi Mystery MachinezFExperts investigate the secrets of a revolutionary encryption machine.r   rt   r   Tr{   Zsciz"us1-prod-direct.sciencechannel.comr   r   r   Nr   r   r   r   r    r     sP   
	%r   c                   @   sx   e Zd Zdej Zdddddddd	dd
dddddgg dddddddddddddddddgZdZdd d!d"Zd#S )$DiscoveryLifeIEz+https?://(?:www\.)?discoverylife\.com/videozQhttps://www.discoverylife.com/video/er-files-discovery-life-atve-us/sweet-charityZ2347614z-er-files-discovery-life-atve-us/sweet-charityrC   zSweet Charityz=The staff at Charity Hospital treat a serious foot infection.r   r   rv   zER Filesgʡx@Z20230721idzDiscovery LifezZhttps://us1-prod-images.disco-api.com/2021/03/16/4b6f0124-360b-3546-b6a4-5552db886b86.jpegr   r   zXhttps://www.discoverylife.com/video/surviving-death-discovery-life-atve-us/bodily-traumaZ2218238z4surviving-death-discovery-life-atve-us/bodily-traumazBodily Traumaz:Meet three people who tested the limits of the human body.r   r   rt   r   Tr{   Zdlfz!us1-prod-direct.discoverylife.comr   r   r   Nr   r   r   r   r    r   (  sP   
	%r   c                   @   sx   e Zd Zdej Zdddddddd	d
ddddddgg dddddddddddddddddgZd Zd!d"d#d$Zd%S )&AnimalPlanetIEz*https?://(?:www\.)?animalplanet\.com/videozthttps://www.animalplanet.com/video/mysterious-creatures-with-forrest-galante-animal-planet-atve-us/the-demon-of-peruZ4650835zQmysterious-creatures-with-forrest-galante-animal-planet-atve-us/the-demon-of-perurC   zThe Demon of PeruuI   In Peru, a farming village is being terrorized by a “man-like beast.”r   r      z	Episode 4z)Mysterious Creatures with Forrest Galanteg"t@Z20230111iPBczAnimal PlanetzZhttps://us1-prod-images.disco-api.com/2022/03/01/6dbaa833-9a2e-3fee-9381-c19eddf67c0c.jpegr   r   zRhttps://www.animalplanet.com/video/north-woods-law-animal-planet/squirrel-showdownZ3338923z/north-woods-law-animal-planet/squirrel-showdownzSquirrel ShowdownzDA woman is suspected of being in possession of flying squirrel kits.      r   rt   r   Tr{   Zaplz us1-prod-direct.animalplanet.comr   r   r   Nr   r   r   r   r    r   W  sP   
	%r   c                   @   sx   e Zd Zdej Zdddddddd	dd
dddddgg dddddddddddddddddgZdZddd d!Zd"S )#TLCIEz https?://(?:go\.)?tlc\.com/videozKhttps://go.tlc.com/video/90-day-the-last-resort-tlc-atve-us/the-last-chanceZ5186422z290-day-the-last-resort-tlc-atve-us/the-last-chancerC   zThe Last ChancezJInfidelity shakes Kalani and Asuelu's world, and Angela threatens divorce.r   r   rv   z90 Day: The Last Resortg\@Z20230815idTLCzZhttps://us1-prod-images.disco-api.com/2023/08/08/0ee367e2-ac76-334d-bf23-dbf796696a24.jpegr   r   zAhttps://go.tlc.com/video/my-600-lb-life-tlc/melissas-story-part-1Z2206540z(my-600-lb-life-tlc/melissas-story-part-1zMelissas Story (Part 1)zIAt 650 lbs, Melissa is ready to begin her seven-year weight loss journey.r   rt   r   Tr{   Ztlczus1-prod-direct.tlc.comr   r   r   Nr   r   r   r   r    r     sP   
	%r   c                   @   sn   e Zd Zdej Z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gZdZdZdd Z	dd Z
dS )DiscoveryPlusIEzbhttps?://(?:www\.)?discoveryplus\.com/(?!it/)(?:(?P<country>[a-z]{2})/)?video(?:/sport|/olympics)?zRhttps://www.discoveryplus.com/video/property-brothers-forever-home/food-and-familyZ1140794z.property-brothers-forever-home/food-and-familyrC   zFood and FamilyzCThe brothers help a Richmond family expand their single-level home.g"9.@iP	_Z20201230r   zProperty Brothers: Forever Homer   rl   rt   r   zLhttps://discoveryplus.com/ca/video/bering-sea-gold-discovery-ca/goldslingersTr{   zphttps://www.discoveryplus.com/gb/video/sport/eurosport-1-british-eurosport-1-british-sport/6-hours-of-spa-reviewzjhttps://www.discoveryplus.com/gb/video/olympics/dplus-sport-dplus-sport-sport/rugby-sevens-australia-samoaNc              	   C   s6   | d| d| j d| j | |||d d S Nr   r   zWEB:UNKNOWN:dplus_us:r   r   r0   r   r   r    r2     s
    
z)DiscoveryPlusIE._update_disco_api_headersc                 C   sb   |  |dd\}}|sd}d| | _|dkrBdd|d| _nd	d
|d| _| j||f| jS )Nr@   ra   r   Zdplus_)brcar   z!us1-prod-direct.discoveryplus.comr   r   !eu1-prod-direct.discoveryplus.comr}   )r~   r   r   r   rf   )r   r4   r8   ra   r   r   r    r     s    
zDiscoveryPlusIE._real_extract)rg   rh   ri   r   rj   r   r   r   r   r2   r   r   r   r   r    r     s>   
r   c                   @   sd   e Zd Zdej Zdddddddd	d
dddddddg dddidgZdZdddddZdd Z	dS )DiscoveryPlusIndiaIEz,https?://(?:www\.)?discoveryplus\.in/videos?z[https://www.discoveryplus.in/videos/how-do-they-do-it/fugu-and-more?seasonId=8&type=EPISODEZ27104rC   zhow-do-they-do-it/fugu-and-morezFugu and MorezEThe Japanese catch, prepare and eat the deadliest fish on the planet.gzG@i!P^Z20200221zHow Do They Do It?rz   r   zDiscovery Channelzre:https://.+\.jpegz	Episode 2zSeason 8)r@   rd   r   rM   rK   rN   rO   rm   rP   rQ   rR   rS   rw   rx   r   rT   rn   Tro   zdplus-indiaz ap2-prod-direct.discoveryplus.in
dplusindiainhttps://www.discoveryplus.in/)r`   r   ra   rb   c              	   C   s0   | d| d| j d| |||d d S )Nr   r   z:17.0.0r   )r   r   r!   r0   r   r   r    r2     s
    z.DiscoveryPlusIndiaIE._update_disco_api_headersNr   r   r   r   r    r     s<   
 r   c                   @   s   e Zd ZdZdddddddd	d
ddddddgddddddddgdddi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	d0d1d2d3d4d5d6d7d5d6d8d5d6gZd9d: Zd;d< Zd=S )>DiscoveryNetworksDeIEzhttps?://(?:www\.)?(?P<domain>(?:tlc|dmax)\.de|dplay\.co\.uk)/(?:programme|show|sendungen)/(?P<programme>[^/]+)/(?:video/)?(?P<alternate_id>[^/]+)z>https://dmax.de/sendungen/goldrausch-in-australien/german-goldZ4756322rC   zGerman Goldz$md5:f3073306553a8d9b40e6ac4cdbf09fc6z$goldrausch-in-australien/german-goldrv   r   zSeason 5   zGoldrausch in Australieng     @Z20230517i|AedZDMAXzZhttps://eu1-prod-images.disco-api.com/2023/05/09/f72fb510-7992-3b12-af7f-f16a2c22d1e3.jpegZschatzsucherZschatzZnuggetu   bodenschätzez
down underZ
australienZ
goldrausch)r@   rd   rM   rK   r   rx   rR   r   rQ   rP   rN   rm   rO   r   rw   rT   rn   rB   ro   zThttps://www.tlc.de/programme/breaking-amish/video/die-welt-da-drauen/DCB331270001100Z78867u   Die Welt da draußenz$md5:61033c12b73286e409d99a41742ef608i`8\Z20190331r   r   zBreaking Amishznew yorku
   großstadtZamischeZ	landlebenZmodernZinfosZ	traditionZherausforderungz!breaking-amish/die-welt-da-draueng5^I@zre:https://.+\.jpg)r@   rd   rM   rK   rO   rm   rS   r   rP   rR   rT   r   rx   rN   rQ   rw   z404 Not Foundr   zqhttps://www.dmax.de/programme/dmax-highlights/video/tuning-star-sidney-hoffmann-exklusiv-bei-dmax/191023082312316Tr{   zRhttps://www.dplay.co.uk/show/ghost-adventures/video/hotel-leger-103620/EHD_280313Bz;https://tlc.de/sendungen/breaking-amish/die-welt-da-drauen/c                 C   sX   |  | \}}}|dkr dnd}|dkr0dn
|dd}| || d| d||S )	Nzdplay.co.ukZGBZDEZquestuk.r<   r=   r   )r~   groupsreplacerf   )r   r4   rb   Z	programmeZalternate_idra   r   r   r   r    r   W  s        z#DiscoveryNetworksDeIE._real_extractc              	   C   s&   | d| d| |||d d S r   r   r0   r   r   r    r2   ^  s
    z/DiscoveryNetworksDeIE._update_disco_api_headersN)rg   rh   ri   r   r   r   r2   r   r   r   r    r     sj   5r   c                   @   s   e Zd Zdd Zdd ZdS )DiscoveryPlusShowBaseIEc              
   c   sb  | j d| j | j| | jd | jd}| j| j d| j d| d||dd | j d d	 }|d
 dd }| jd }|d d d D ]}|d }d\}}	|	|k r| j|	||t
|	d ||d	||	rd|	 ndd}
|	dkrt|
dd tp d}|
d }|D ]B}|d d }| j| j d| | j |dpF|dV  q|	d7 }	qqd S )Nr   )r   r   rL   ZAuthenticationzcms/routes/r=   z?include=default)r8   r1   rD   r   	componentZmandatoryParams=zkcontent/videos?sort=episodeNumber&filter[seasonNumber]={}&filter[show.id]={}&page[size]=100&page[number]={}filtersr   optionsr@   )r   r   r   z%Downloading season {} JSON metadata{}z page r<   )r1   Znotec                 S   s   | d d S )NmetaZ
totalPagesr   )xr   r   r    <lambda>|      z2DiscoveryPlusShowBaseIE._entries.<locals>.<lambda>r   pathzvideos/)Zier8   )	_X_CLIENT_REALM_DOMAINr!   	_BASE_APIr   	_SHOW_STR_INDEXsplitformatstrr   intZ
url_result	_VIDEO_IEZie_keyr   )r   	show_namer1   Z	show_jsonZshow_idZ
season_urlr   Z	season_idZtotal_pagesZpage_numZseason_jsonZepisodes_jsonrx   Z
video_pathr   r   r    _entriesh  sR    
 
  
 z DiscoveryPlusShowBaseIE._entriesc                 C   s$   |  |d}| j| ||dS )Nr   )Zplaylist_id)r~   r   Zplaylist_resultr   )r   r4   r   r   r   r    r     s    z%DiscoveryPlusShowBaseIE._real_extractN)rg   rh   ri   r   r   r   r   r   r    r   f  s   r   c                   @   sR   e Zd Zdej ZddddddddddddgZdZd	d
ddZdd Z	dS )DiscoveryPlusItalyIEzChttps?://(?:www\.)?discoveryplus\.com/it/video(?:/sport|/olympics)?z_https://www.discoveryplus.com/it/video/i-signori-della-neve/stagione-2-episodio-1-i-preparativiTr{   z:https://www.discoveryplus.com/it/video/super-benny/trailerzehttps://www.discoveryplus.com/it/video/olympics/dplus-sport-dplus-sport-sport/water-polo-greece-italyzmhttps://www.discoveryplus.com/it/video/sport/dplus-sport-dplus-sport-sport/lisa-vittozzi-allinferno-e-ritornoZdplus_itr   r}   itr   c              	   C   s6   | d| d| j d| j | |||d d S r   r   r0   r   r   r    r2     s
    
z.DiscoveryPlusItalyIE._update_disco_api_headersNr   r   r   r   r    r     s(   
r   c                   @   s>   e Zd ZdZddddidgZdZdZd	Zd
ZdZ	dZ
eZdS )DiscoveryPlusItalyShowIEzOhttps?://(?:www\.)?discoveryplus\.it/programmi/(?P<show_name>[^/]+)/?(?:[?#]|$)zAhttps://www.discoveryplus.it/programmi/deal-with-it-stai-al-gioco   r@   zdeal-with-it-stai-al-giocor4   Zplaylist_mincountrp   z#https://disco-api.discoveryplus.it/zhttps://www.discoveryplus.it/zWEB:UNKNOWN:dplay-client:2.6.0ZdplayitZ	programmir   N)rg   rh   ri   r   r   r   r   r   r   r   r   rk   r   r   r   r   r    r     s    r   c                   @   s>   e Zd ZdZddddidgZdZdZd	Zd
ZdZ	dZ
eZdS )DiscoveryPlusIndiaShowIEzJhttps?://(?:www\.)?discoveryplus\.in/show/(?P<show_name>[^/]+)/?(?:[?#]|$)z3https://www.discoveryplus.in/show/how-do-they-do-it   r@   zhow-do-they-do-itr   z)https://ap2-prod-direct.discoveryplus.in/r   zWEB:UNKNOWN:dplus-india:prodr   rI   r   N)rg   rh   ri   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r     s    r   )&r   r   commonr   Znetworking.exceptionsr   utilsr   r   r   r	   r
   r   r   r   r   rk   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    <module>   s:   ( ! '///+////////?+G$