o
    i
                     @   s`   d dl Z d dlZddlmZ ddlmZmZmZmZm	Z	m
Z
 ddlmZmZ G dd deZdS )	    N   )InfoExtractor   )ExtractorError
clean_htmlextract_attributesjoin_nonemptyparse_durationunified_timestamp)find_elementtraverse_objc                	   @   s<   e Zd ZdZdddddddd	d
dgZdd Zdd ZdS )LearningOnScreenIEzFhttps?://learningonscreen\.ac\.uk/ondemand/index\.php/prog/(?P<id>\w+)zNhttps://learningonscreen.ac.uk/ondemand/index.php/prog/005D81B2?bcast=22757013005D81B2mp4zPlanet Earthg      @g   yZA20061126zjhttps://stream.learningonscreen.ac.uk/trilt-cover-images/005D81B2-Planet-Earth-2006-11-26T190000Z-BBC4.jpg)idexttitleduration	timestampupload_date	thumbnail)url	info_dictc                 C   s$   |  dds| jdd d S d S )Nhttps://learningonscreen.ac.uk/zPHPSESSID-LOS-LIVEsession_cookies)method)_get_cookiesgetraise_login_required)self r!   U/home/ubuntu/.local/lib/python3.10/site-packages/yt_dlp/extractor/learningonscreen.py_real_initialize   s   z#LearningOnScreenIE._real_initializec           
   	   C   sH  |  |}| ||}t|tdddhtddhthftddhttjdhd	t	hftd
dhtht
hfdf}|dd pOt|tdddhthdthf}| jd||dddddd}|sdtdt|d	kr|dd }t|d	dD ]\}}	|	| t|||	d< t|||	d< qv| j||||dS i |d |||dS )Nzprogramme-detailsT)r   htmlh2)tagzbroadcast-date)clsz([^<]+)r   zprog-running-time)r   r   r   r   zadd-to-existing-playlistzdata-record-titlez%https://stream.learningonscreen.ac.ukhlsdashzhttps://learningonscreen.ac.ukr   )OriginReferer)m3u8_idmpd_id_headerszNo video foundr   )startr   )r   r   )r   r   )	_match_id_download_webpager   r   r   	functoolspartialrematchr
   r	   popr   _parse_html5_media_entriesr   len	enumerateupdater   playlist_result)
r    r   video_idwebpagedetailsr   entriesr   idxentryr!   r!   r"   _real_extract#   sJ   





z LearningOnScreenIE._real_extractN)__name__
__module____qualname__
_VALID_URL_TESTSr#   rB   r!   r!   r!   r"   r      s    r   )r2   r4   commonr   utilsr   r   r   r   r	   r
   utils.traversalr   r   r   r!   r!   r!   r"   <module>   s     