U
    ¸žÖj~  ã                   @   s2   d dl mZmZmZ d dlZe d¡Zdd„ ZdS )é    )ÚurljoinÚurlsplitÚquoteNzURI="([^"]+)"c                    s|   g }|   ¡ D ]`}| ¡ }|s(| |¡ q| d¡rT‡ ‡fdd„}| t ||¡¡ qtˆ|ƒ}| ˆ |ƒ¡ qd |¡d S )ug   
    Transforma referencias HLS mediante una funciÃ³n
    que genera enlaces internos autorizados.
    ú#c                    s    t ˆ|  d¡ƒ}dˆ |ƒ d S )Né   zURI="ú")r   Úgroup)ÚmatchÚdestino©Úcrear_enlaceÚorigen© úhermes_hls_manifest.pyÚ
reemplazar   s    z(transformar_manifest.<locals>.reemplazarÚ
)Ú
splitlinesÚstripÚappendÚ
startswithÚURI_ATTRÚsubr   Újoin)Z	contenidor   r   Z	resultadoZlineaZtextor   r
   r   r   r   Útransformar_manifest   s    



ÿ
r   )Zurllib.parser   r   r   ÚreÚcompiler   r   r   r   r   r   Ú<module>   s   
