
    VGh                     N    d dl Zd dlZddlmZ ddlmZmZm	Z	m
Z
  G d de      Zy)    N   )InfoExtractor   )
clean_htmldatetime_from_strunified_timestampurljoinc                   l    e Zd ZdZg dZddedededddd	d
ddddddddddddgZd Zd Z	d Z
y)JoqrAgIEuM   超!A&G+ 文化放送 (f.k.a. AGQR) Nippon Cultural Broadcasting, Inc. (JOQR))zFhttps?://www\.uniqueradio\.jp/agplayer5/(?:player|inc-player-hls)\.phpz#https?://(?:www\.)?joqr\.co\.jp/ag/zIhttps?://(?:www\.)?joqr\.co\.jp/qr/ag(?:daily|regular)program/?(?:$|[#?])z/https://www.uniqueradio.jp/agplayer5/player.phplive   超!A&G+is_live)idtitlechanneldescriptionlive_statusrelease_timestampT)skip_downloadignore_no_formats_error)url	info_dictparams7https://www.uniqueradio.jp/agplayer5/inc-player-hls.php)r   only_matchingz)https://www.joqr.co.jp/ag/article/103760/z(http://www.joqr.co.jp/qr/agdailyprogram/z*http://www.joqr.co.jp/qr/agregularprogram/c                     t        t        j                  j                  | j	                  d| d|ddd                  xs d S )Nzvar\s+z'\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1metadatavalue )groupdefault)r   urllibparseunquote_plus_search_regex)selfvariablehtmls      `/var/www/it7/html/youtubeDownloader/venv/lib/python3.12/site-packages/yt_dlp/extractor/joqrag.py_extract_metadatazJoqrAgIE._extract_metadata.   sS    &,,33D4F4FhZFG*GR 5G 59 : ; C>B	C    c                 x      fd} |d      }|sy |r|t        d      j                         k  r|S  |d      S )Nc                    t        |       t        j                  d      z   }|j                  d      }j	                  dj                  d| d| dd| 	      xs d
dd       }|r t        |j                  d       d| d      S y )N	   )hoursz%Y%m%duR   <h3[^>]+\bclass="dailyProgram-itemHeaderTime"[^>]*>[\s\d:]+–\s*(\d{1,2}:\d{1,2})z/https://www.joqr.co.jp/qr/agdailyprogram/?date=zDownloading program list of Fz#Failed to download program list of )notefatalerrnoter   z
start time)r!   z%Y/%m/%d z +09:00)r   dt	timedeltastrftimer%   _download_webpager   )date_strdt_date
start_timer&   video_ids       r)   extract_start_time_fromzBJoqrAgIE._extract_start_timestamp.<locals>.extract_start_time_from4   s    #H-10EEC<<)D++e&&EdVLh7v>eA$H ' J P NPd , ,J (CLL,D+EQzlRY)Z[[r+   todaynow	yesterday)r   	timestamp)r&   r<   r   r=   start_timestamps   ``   r)   _extract_start_timestampz!JoqrAgIE._extract_start_timestamp3   sD    	 2':/,=e,D,N,N,PP""*;77r+   c           	         d}| j                  d|dd      }| j                  d|      }|r|dk(  rbg }d}| j                  |d	      }d
}|r4|dt        j                  j                  |      j                  d      z   z  }| j                  |d       nV| j                  d| j                  d|dd      d      }	| j                  t        d|	      |      }d}| j                  |d      }||d| j                  d|      |||dS )Nr   z https://www.uniqueradio.jp/aandgzDownloading metadatazFailed to download metadata)r0   r2   Program_nameu   放送休止is_upcomingFz!This stream is not currently livez and will start at z%Y-%m-%d %H:%M:%ST)expectedz<source\s[^>]*\bsrc="([^"]+)"r   zDownloading player datazFailed to download player datazm3u8 urlzhttps://www.uniqueradio.jp/r   r   Program_text)r   r   r   r   formatsr   r   )r7   r*   rC   r4   datetimefromtimestampr6   raise_no_formatsr%   _extract_m3u8_formatsr	   )
r&   r   r<   r   r   rI   r   r   msg	m3u8_paths
             r)   _real_extractzJoqrAgIE._real_extractK   sN   )).'1N * P &&~x@/G'K $ = =h N5C -++334EFOOPcde f!!#!5**0&&Mx2<\ ' ^ I 005yA8MG#K $ = =h M !11.(K&!2
 	
r+   N)__name__
__module____qualname__IE_DESC
_VALID_URLstrint_TESTSr*   rC   rP    r+   r)   r   r      s    ]G`J A!$!$
 "'+
 I ; : </F8C
80%
r+   r   )rJ   r4   urllib.parser"   commonr   utilsr   r   r   r	   r   rY   r+   r)   <module>r]      s&      ! c
} c
r+   