a
    h"                     @   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uuiduuid4hex_download_json)	self
disco_base
display_idr   Zneeds_device_idkeyr   r   r    r    K/mnt/pikpak/tmp/myenv/lib/python3.9/site-packages/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v 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/)r2   r   r   	streamingurl)typer5   )r   itemsappendr   )r   r   video_idr2   r4   Zstreaming_list	format_idformat_dictr    r    r!   _download_video_playback_info7   s"    

z)DPlayBaseIE._download_video_playback_info c           #      C   sn  |  dp|}| g}| d|i d| d}d|i}	| |	||| z,| j|d | ||	ddddd	d
dd}
W nJ ty } z2t|jtr|jj	dkr| 
||  W Y d }~n
d }~0 0 |
d d }|
d d }|d  }g }i }z| |||	}W nP tyP } z6t|jtr:|jj	dkr:| 
||  W Y d }~n
d }~0 0 |D ]}t|tsjqV|d}|s~qV|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 qVd  }}g }g }|
dpJg }t|tr|D ]}|d}|stq\|d} | dkr|d}n@| d kr|d!}!|!r||!t|d"t|d#d$ | d%kr|d}n$| d&kr\|d}"|"r\||" q\|||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)r2   r   i  r   idr   i  r5   r6   ZdashZmpdF)Zmpd_idfatalZhlsm3u8mp4Zm3u8_native)Zentry_protocolZm3u8_idrB   )r5   r:   includedZchannelimagesrcwidthheight)r5   rH   rI   showtagdescriptionZvideoDurationi  ZpublishStartZseasonNumberZepisodeNumberreferer)rA   r   titlerL   duration	timestampseriesseason_numberepisode_numbercreatortags
thumbnailsformats	subtitlesZhttp_headers)	get_paramupperZ_initialize_geo_bypassr3   r   r   
isinstancer'   r   statusr/   stripr<   dictr   r   Z"_extract_mpd_formats_and_subtitlesextendZ_merge_subtitlesZ#_extract_m3u8_formats_and_subtitlesr8   listr	   r   r   r   )#r   r5   r   
disco_hostr   countrydomainr,   r   r2   videor+   r9   r-   rN   rW   rX   r4   r;   Z
format_urlr:   extZ	dash_fmtsZ	dash_subsZ	m3u8_fmtsZ	m3u8_subsrT   rQ   rU   rV   rE   r   e_typerG   r?   r    r    r!   _get_disco_api_infoC   s    
















zDPlayBaseIE._get_disco_api_infoN)T)r=   )
__name__
__module____qualname___PATH_REGEXr   r"   r/   r3   r<   rg   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-101rD   u    Svensken lär sig njuta av livetz$md5:d3819c9bccffd0fe458ca42451dd50d8gʡE@i+cQZ20130408zKanal 5u,   Nugammalt - 77 händelser som format Sveriger   rA   r   re   rN   rL   rO   rP   upload_daterT   rQ   rR   rS   skip_downloadTr5   	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   )rA   r   re   rN   rL   rO   rP   rn   rQ   rR   rS   Available for Premium users)r5   rq   rr   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)rA   r   re   rN   rL   	thumbnailrn   rP   rQ   rR   episoderS   )r5   md5rq   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r5   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 )NrA   rc   zwww.rb   Zsubdomain_countryZplus_countryr   dz
disco-api.zeu2-prod.disco-api.comdplay)_match_valid_urlgroupr
   rg   )r   r5   Zmobjr   rc   rb   hostr    r    r!   _real_extract8  s    

zDPlayIE._real_extractN)rh   ri   rj   r   rk   
_VALID_URL_TESTSr   r    r    r    r!   rl      s   	zrl   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-clientr0   update_PRODUCT_DISCO_CLIENT_VERr"   r1   r    r    r!   r3   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)r2   r   r   r   r4   )r   jsondumpsencode)r   r   r9   r2   r    r    r!   r<   N  s     
			z1DiscoveryPlusBaseIE._download_video_playback_infoc                 C   s   | j || |fi | jS )N)rg   Z	_match_id_DISCO_API_PARAMS)r   r5   r    r    r!   r   Z  s    z!DiscoveryPlusBaseIE._real_extractN)rh   ri   rj   __doc__r   r3   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7332936rD   z0mein-kleinstadt-traumhaus/vom-landleben-ins-loftzVom Landleben ins Loftz$md5:e5f72c02c853970796dd3818f2e25745rs   rt   Season 7zMein Kleinstadt-Traumhausg     @ifZ20240910HGTVzZhttps://eu1-prod-images.disco-api.com/2024/08/09/82a386b9-c688-32c7-b9ff-0b13865f0bae.jpeg)rA   re   r   rN   rL   ry   rS   seasonrR   rQ   rO   rP   rn   creatorsrU   rx   r5   rq   hgtveu1-prod.disco-api.comdera   r   rb   c              	   C   s&   | d| d| |||d d S Nr   zAlps:HyogaPlayer:0.0.0r   r   r"   r1   r    r    r!   r3   }  s
    z"HGTVDeIE._update_disco_api_headersN
rh   ri   rj   r   rk   r   r   r   r   r3   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-twisterrD   zTrapped in a TwisterzJTwisters destroy Midwest towns, trapping spotters in the eye of the storm.r   rw   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)rA   r   re   rN   rL   rS   ry   rR   r   rQ   rO   rn   rP   rU   r   rx   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.	   rA   r   re   rN   rL   rR   rS   ru   r5   rq   rv   zMhttps://discovery.com/video/dirty-jobs-discovery-atve-us/rodbuster-galvanizerTr|   Zdscz us1-prod-direct.go.discovery.comgousr   N	rh   ri   rj   r   rk   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-childrenrD   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)rA   r   re   rN   rL   rR   r   rS   ry   rQ   rO   rP   rn   rU   r   rx   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   ru   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5350005rD   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   rw      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)rA   re   r   rN   rL   rS   ry   rR   r   rQ   rO   rn   rP   rU   r   rx   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   ru   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-fliprD   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)rA   r   re   rN   rL   rQ   rO   rn   rP   rU   r   rx   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   ru   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-aislesrD   zWild in the AisleszGThe chefs make spaghetti and meatballs with "Out of Stock" ingredients.r   r   rw   zGuy's Grocery Gamesr   gd;OM@20230623dzZhttps://us1-prod-images.disco-api.com/2022/06/15/37fb5333-cad2-3dbb-af7c-c20ec77c89c6.jpegrA   r   re   rN   rL   rR   r   rS   ry   rQ   rU   r   rO   rn   rP   rx   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   ru   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-waterrD   zSmoke on the WaterzGThe pitmasters head to Georgia for the Smoke on the Water BBQ Festival.r   zSeason 2r   rw   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   ru   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-biancarD   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)rA   r   re   rN   rL   rR   r   rS   ry   rQ   r   rU   rO   rn   rP   rx   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   ru   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-runrD   zBattle of Bull RunzDTwo untested armies clash in the first real battle of the Civil War.r   r   rw   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rA   r   re   rN   rL   rR   r   rS   ry   rQ   rO   rn   rP   r   rU   rx   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   ru   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-planetsrD   zMystery of the Dead Planetsz>Astronomers unmask the truly destructive nature of the cosmos.rt   r   r   rw   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   ru   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-charityrD   zSweet Charityz=The staff at Charity Hospital treat a serious foot infection.r   r   rw   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   ru   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-perurD   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   ru   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-chancerD   zThe Last ChancezJInfidelity shakes Kalani and Asuelu's world, and Angela threatens divorce.r   r   rw   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   ru   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-familyrD   zFood and FamilyzCThe brothers help a Richmond family expand their single-level home.g"9.@iP	_Z20201230r   zProperty Brothers: Forever Homer   rm   ru   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   r1   r    r    r!   r3     s
    
z)DiscoveryPlusIE._update_disco_api_headersc                 C   sf   |  |dd\}}|sd}d| | _|dv rBdd|d| _nd	d
|d| _| j||fi | jS )NrA   rb   r   Zdplus_)brcar   z!us1-prod-direct.discoveryplus.comr   r   !eu1-prod-direct.discoveryplus.comr~   )r   r   r   r   rg   )r   r5   r9   rb   r    r    r!   r     s    
zDiscoveryPlusIE._real_extract)rh   ri   rj   r   rk   r   r   r   r   r3   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27104rD   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?r{   r   zDiscovery Channelzre:https://.+\.jpegz	Episode 2zSeason 8)rA   re   r   rN   rL   rO   rP   rn   rQ   rR   rS   rT   rx   ry   r   rU   ro   Trp   zdplus-indiaz ap2-prod-direct.discoveryplus.in
dplusindiainhttps://www.discoveryplus.in/)ra   r   rb   rc   c              	   C   s0   | d| d| j d| |||d d S )Nr   r   z:17.0.0r   )r   r   r"   r1   r    r    r!   r3     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g ddddi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)gZd,d- Zd.d/ Zd0S )1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4756322rD   zGerman Goldz$md5:f3073306553a8d9b40e6ac4cdbf09fc6z$goldrausch-in-australien/german-goldrw   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.jpeg)ZschatzsucherZschatzZnuggetu   bodenschätzez
down underZ
australienZ
goldrausch)rA   re   rN   rL   r   ry   rS   r   rR   rQ   rO   rn   rP   r   rx   rU   ro   rC   rp   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 Amish)znew yorku
   großstadtZamischeZ	landlebenZmoderninfosZ	traditionZherausforderungz!breaking-amish/die-welt-da-draueng5^I@zre:https://.+\.jpg)rA   re   rN   rL   rP   rn   rT   r   rQ   rS   rU   r   ry   rO   rR   rx   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replacerg   )r   r5   rc   Z	programmeZalternate_idrb   r   r    r    r!   r   W  s    z#DiscoveryNetworksDeIE._real_extractc              	   C   s&   | d| d| |||d d S r   r   r1   r    r    r!   r3   ^  s
    z/DiscoveryNetworksDeIE._update_disco_api_headersN)rh   ri   rj   r   r   r   r3   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   rM   ZAuthenticationzcms/routes/r>   z?include=default)r9   r2   rE   r   	componentZmandatoryParams=zkcontent/videos?sort=episodeNumber&filter[seasonNumber]={}&filter[show.id]={}&page[size]=100&page[number]={}filtersr   optionsrA   )r   r   r   z%Downloading season {} JSON metadata{}z page r=   )r2   Znotec                 S   s   | d d S )NmetaZ
totalPagesr    )xr    r    r!   <lambda>|      z2DiscoveryPlusShowBaseIE._entries.<locals>.<lambda>r   pathzvideos/)Zier9   )	_X_CLIENT_REALM_DOMAINr"   	_BASE_APIr   	_SHOW_STR_INDEXsplitformatstrr   intZ
url_result	_VIDEO_IEZie_keyr   )r   	show_namer2   Z	show_jsonZshow_idZ
season_urlr   Z	season_idZtotal_pagesZpage_numZseason_jsonZepisodes_jsonry   Z
video_pathr    r    r!   _entriesh  sJ    


z DiscoveryPlusShowBaseIE._entriesc                 C   s$   |  |d}| j| ||dS )Nr   )Zplaylist_id)r   r   Zplaylist_resultr   )r   r5   r   r    r    r!   r     s    z%DiscoveryPlusShowBaseIE._real_extractN)rh   ri   rj   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   r1   r    r    r!   r3     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   rA   zdeal-with-it-stai-al-giocor5   Zplaylist_mincountrq   z#https://disco-api.discoveryplus.it/zhttps://www.discoveryplus.it/zWEB:UNKNOWN:dplay-client:2.6.0ZdplayitZ	programmir   N)rh   ri   rj   r   r   r   r   r   r   r   r   rl   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   rA   zhow-do-they-do-itr   z)https://ap2-prod-direct.discoveryplus.in/r   zWEB:UNKNOWN:dplus-india:prodr   rJ   r   N)rh   ri   rj   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   rl   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$