
    yf*                     F    d dl mZ ddlmZmZmZmZmZmZ  G d de      Z	y)   )InfoExtractor   )ExtractorErrorjoin_nonemptysmuggle_urlstr_or_nonestrip_or_nonetraverse_objc            	       X    e Zd ZdZddddddddd	d
gdddddddgZdZdZdZd Zd Z	y)TVerIEzrhttps?://(?:www\.)?tver\.jp/(?:(?P<type>lp|corner|series|episodes?|feature|tokyo2020/video)/)+(?P<id>[a-zA-Z0-9]+)z$videos are only available for 7 daysz#https://tver.jp/episodes/ep83nf3w4puk   家事ヤロウ!!! 売り場席巻のチーズSP＆財前直見×森泉親子の脱東京暮らし密着！z$md5:dc2c06b6acc23f1e7c730c513737719bu   家事ヤロウ!!!uX   売り場席巻のチーズSP＆財前直見×森泉親子の脱東京暮らし密着！u   テレビ朝日)titledescriptionseriesepisode	alt_titlechannelBrightcoveNew)skipurl	info_dictadd_iezhttps://tver.jp/corner/f0103888T)r   only_matchingzhttps://tver.jp/lp/f0033031zFhttp://players.brightcove.net/%s/default_default/index.html?videoId=%sNc           
      |    | j                  dd dddddd      }t        |d	      | _        t        |d
      | _        y )NzAhttps://platform-api.tver.jp/v2/api/platform_users/browser/createzCreating sessions   device_type=pczhttps://s.tver.jpzhttps://s.tver.jp/z!application/x-www-form-urlencoded)OriginRefererzContent-Type)notedataheaders)resultplatform_uid)r   platform_token)_download_jsonr
   _PLATFORM_UID_PLATFORM_TOKEN)selfcreate_responses     7/usr/lib/python3/dist-packages/yt_dlp/extractor/tver.py_real_initializezTVerIE._real_initialize%   sT    --OQU#*;-/ CF .  */;UV+O=YZ    c                    | j                  |      j                  dd      \  }}|dvr6| j                  ||d      }| j                  | j	                  d|d            }| j                  d| d	|d
| j                  | j                  dddi      }t        |d      xs i }| j                  d| d|dt        |j                  d            xs diddd      }|d   d   }t        |dd
      }	|	st        d      |	j                         sd|	 }	t        |j                  d            }
t        |j                  d             }t        ||
d!"      xs t        |j                  d            }t        |j                  d#            }t        |j                  d$            }d%|||
t        |||d!"      |t        |j                  d&            t        | j                   ||	fz  d'd(gi      d)d*	S )+Nidtype>   r   episodeszResolving to new URL)r   )z-canonical"\s*href="(https?://tver\.jp/[^"]+)"z$&link=(https?://tver\.jp/[^?&]+)[?&]z	url regexz8https://platform-api.tver.jp/service/api/v1/callEpisode/zJ?require_data=mylist,later[epefy106ur],good[epefy106ur],resume[epefy106ur]F)r    r!   zx-tver-platform-typeweb)fatalqueryr   )r   r   contentz(https://statics.tver.jp/content/episode/z.jsonvversion5zhttps://tver.jpzhttps://tver.jp/)r   r   )r0   r   video	accountID)r5   )
videoRefIDvideoID)get_allz-Failed to extract reference ID for Brightcovezref:r   seriesTitle )delimproductionProviderNamebroadcastDateLabelurl_transparentr   geo_countriesJPr   )	_typer   r   r   r   r   r   r   ie_key)_match_valid_urlgroup_download_webpage	_match_id_search_regexr"   r#   r$   r
   r   getr   isdigitr	   r   r   BRIGHTCOVE_URL_TEMPLATE)r%   r   video_id
video_typewebpageepisode_infoepisode_content
video_infop_idr_idr   r   r   provideronair_labels                  r'   _real_extractzTVerIE._real_extract0   sO   #44S9??fM*33,,S(AW,XG~~d&8&8k'& 'H **Fxj  Q[  \E $ 2 2"&"6"6 ' +  ':< B?A 	 ((6xjF[!4!4Y!?@GC ,-	 ) 
 '";/J(LV[\ !PQQ||~$=D 3 3G <=_00?@&'5 4:>>'23 	 223KLM!/"5"56J"KL '&uh3O&z~~m'DE,,d|;oPTv=VX%
 	
r)   )
__name__
__module____qualname__
_VALID_URL_TESTSrK   r#   r$   r(   rV    r)   r'   r   r      sv     GJ64 CA*qs(
 ## 1 -F& gMO	[7
r)   r   N)
commonr   utilsr   r   r   r   r	   r
   r   r\   r)   r'   <module>r_      s     ! [
] [
r)   