o
    i                     @   s\   d dl Z ddlmZ ddl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dS )
    N   )InfoExtractor   )
clean_htmlget_element_by_classget_elements_by_classjoin_nonemptytraverse_objunified_timestampurljoinc                   @   s0   e Zd ZdZdddddddd	gZd
d ZdS )CamFMShowIEz4https?://(?:www\.)?camfm\.co\.uk/shows/(?P<id>[^/]+)   z&https://camfm.co.uk/shows/soul-mining/zsoul-miningz$md5:6a873091f92c936f23bdcce80f75e66azSoul MiningzITelling the stories of jazz, funk and soul from all corners of the world.)id	thumbnailtitledescription)playlist_mincounturl	info_dictc                    sj     |} ||}d| fddtd|D td jd|ddd	 jd
|ddd	ttd|dS )Nplaylistc                    s   g | ]}  td |tqS )https://camfm.co.uk)
url_resultr   CamFMEpisodeIE).0iself J/home/ubuntu/.local/lib/python3.10/site-packages/yt_dlp/extractor/camfm.py
<listcomp>#   s    z-CamFMShowIE._real_extract.<locals>.<listcomp>z-javascript:popup\('(/player/[^']+)', 'listen'r   z/<img[^>]+class="thumb-expand"[^>]+src="([^"]+)"r   Ffatalz<h1>([^<]+)</h1>r   zsmall-12 medium-8 cell)_typer   entriesr   r   r   )		_match_id_download_webpagerefindallr   _search_regex_html_search_regexr   r   )r   r   show_idpager   r   r   _real_extract   s   


zCamFMShowIE._real_extractN__name__
__module____qualname__
_VALID_URL_TESTSr,   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gd	dgZdd ZdS )r   z5https?://(?:www\.)?camfm\.co\.uk/player/(?P<id>[^/]+)z https://camfm.co.uk/player/43336zIEpisode will expire - don't actually know when, but it will go eventually43336z2AITAA: Am I the Agony Aunt? - 19:00 Tue 16/05/2023mp320230516z$md5:f165144f94927c0f1bfa2ee6e6ab7bbficdzAITAA: Am I the Agony Aunt?z$md5:5980a831360d0744c3764551be3d09c1Entertainment)	r   r   extupload_dater   	timestampseriesr   
categories)r   skipr   c           	      C   s   |  |}| ||}| d||}td|}ttdd|}td|}| jd|ddd	}|t||d
dt	|dt
||ttdd|td| jd|ddd	td|dd	S )Nzhttps://audio.camfm.co.ukcaptionz<span[^<]+<[^<]+> zcard-sectionz>Aired at ([^<]+)<zair dateFr    z - )delim).formats.z<b>[^<]+</b><br[^>]+/>r   z:<div[^>]+class="cover-art"[^>]+style="[^"]+url\(\'([^\']+)r   labelT)	r   r   r@   r9   r:   r   r   r;   was_live)r$   r%   _parse_html5_media_entriesr   r   r&   subr)   r   r	   r
   r   r(   r   )	r   r   
episode_idr+   audiosr=   r:   card_sectiondater   r   r   r,   >   s(   


zCamFMEpisodeIE._real_extractNr-   r   r   r   r   r   ,   s     r   )r&   commonr   utilsr   r   r   r   r	   r
   r   r   r   r   r   r   r   <module>   s
    $