U
    gb                     @   sT   d dl Z d dlZddlmZ ddlmZmZmZm	Z	 ddl
mZ G dd deZdS )	    N   )InfoExtractor   )ExtractorErrormake_archive_idunified_timestampurljoin)traverse_objc                   @   s   e Zd ZdZdddddddd	d
dgd	ddddddddddgddd	ddddeedddddd d!d"d#d$d%d&gd'd(d)d*d+ged,d-d.ed/d(d0d1dgZd2d3 Zd4d5 Zd6S )7
NintendoIEzdhttps?://(?:www\.)?nintendo\.com/(?:(?P<locale>\w{2}(?:-\w{2})?)/)?nintendo-direct/(?P<slug>[^/?#]+)z4https://www.nintendo.com/nintendo-direct/09-04-2019/Zmp4Z2oPmiviVePUA1IqAZzjuVhz
09-04-2019zNintendo Direct 9.4.2019i`o]z$md5:8aac2780361d8cb772b6d1de66d7d6f4Z20190904   z)nintendo J2bXdmaTE6fe3dWJTPcc7m23FNbc_A1V)	extid
display_idtitle	timestampdescriptionupload_date	age_limit_old_archive_ids)urlZ	info_dictz:https://www.nintendo.com/en-ca/nintendo-direct/08-31-2023/Z2TB2w2rJhNYF84qQ9E57hUz
08-31-2023z)Super Mario Bros. Wonder Direct 8.31.2023ip:dz$md5:3067c5b824bcfdae9090a7f38ab2d200zMild Fantasy ViolencezIn-Game PurchasesZ20230831   )	r   r   r   r   r   r   tagsr   r   zAhttps://www.nintendo.com/us/nintendo-direct/50-fact-extravaganza/Zj0BBGzfw0pQzSLearn new details about Super Smash Bros. for Wii U, which launches on November 21.iK  publicz:https://i.ytimg.com/vi_webp/j0BBGzfw0pQ/maxresdefault.webpipHTzUCGIY_O-8vW4rfX98KlMkvRgzcount:53z	count:100Z20141023z@NintendoAmericaTZGamingz50-fact-extravaganzazNintendo of AmericazComic MischiefzCartoon ViolencezMild Suggestive Themesz8https://www.youtube.com/channel/UCGIY_O-8vW4rfX98KlMkvRg
   z(https://www.youtube.com/@NintendoAmericaZnot_livez50-FACT Extravaganza)r   r   Zchannel_follower_countZ
view_countr   durationZavailability	thumbnailr   Z
channel_idZchaptersZheatmapr   Zuploader_idZplayable_in_embed
categoriesr   Zchannelr   Z
like_countZchannel_urlr   Zuploader_urlZcomment_countZlive_statusZuploaderr   c                 C   s   t dtj|S )Nzhttps://assets.nintendo.com/)r   urllibparsequote)selfpath r"   =/tmp/pip-unpacked-wheel-q5ljy6pj/yt_dlp/extractor/nintendo.py_create_asset_urlK   s    zNintendoIE._create_asset_urlc                 C   s  |  |dd\}}|pdd\}}}| p4d d|  }| jd| d| d	d
d | jd|dtj||dddtjddddidddd}t	|ddt
hf}	|	std| dd
ddt	|d}
|
rtd|
pd t	|	d thfd!thfd"thfd#d$thfd%d&thfd'd(d)thfd*| jhfd+}||d,< t	|	d-d.thf}|st	|	d/thf}|s~| jd0|d1 | j|f|d2d
iS |d3rt| |d4d  g|d5< | | d6| d7||d8< |S )9NlocaleslugZUS-en_zUsing locale z (from )T)Z	only_oncezhttps://graph.nintendo.com/ZNintendoDirect)r%   r&   ),:)
separatorsZpersistedQueryr   Z@969b16fe9f08b686fa37bc44d1fd913b6188e65794bb5e341c54fa683a8004cb)versionZ
sha256Hash)ZoperationName	variables
extensions)querydatadirectzNo Nintendo Direct with id z exists)expectedz, )errors.messagezGraphQL API error: zUnknown errorr   nameZ	startDater   textZcontentRatingorderZcontentDescriptors.labelr   )r   r   r   r   r   r   r   r   videopublicIdZ
liveStreamz Could not find any video formats)Zvideo_idZurl_transparentzLegacy Videos/   r   z/video/upload/sp_full_hd/v1/z.m3u8formats)Z_match_valid_urlgroup
rpartitionlowerupperZwrite_debugZ_download_jsonjsondumpsr	   dictr   joinstrr   intr$   Zraise_no_formatsZ
url_result
startswithr   Z_extract_m3u8_formats)r    r   r%   r&   languager)   ZcountryZparsed_localeresponseZdirect_infor5   resultZasset_idZ
youtube_idr"   r"   r#   _real_extractN   sd    



	 zNintendoIE._real_extractN)__name__
__module____qualname__Z
_VALID_URLrH   Z_TESTSr$   rM   r"   r"   r"   r#   r
      st   ;r
   )rC   urllib.parser   commonr   utilsr   r   r   r   Zutils.traversalr	   r
   r"   r"   r"   r#   <module>   s
   