a
    h[                     @   sx   d dl Z ddlm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G d
d deZG dd deZdS )    N   )InfoExtractor)	YoutubeIE   )int_or_noneparse_iso8601str_or_noneurl_or_none)traverse_objc                   @   s0   e Zd ZddddZdd Zdd Zd	d
 ZdS )
EggsBaseIEz*/*z8.2.00ZAndroid)AcceptZ	apVersionZ
deviceNamec                 C   s   t d| jd< d S )N   ZdeviceId)secretsZ	token_hex_API_HEADERS)self r   J/mnt/pikpak/tmp/myenv/lib/python3.9/site-packages/yt_dlp/extractor/eggs.py_real_initialize   s    zEggsBaseIE._real_initializec                 C   s   | j d| || jdS )Nz!https://app-front-api.eggs.mu/v1/)headers)Z_download_jsonr   )r   ZendpointZvideo_idr   r   r   	_call_api   s    
zEggsBaseIE._call_apic                 C   s   t |dthf }r"| j|tdS t |ddthf}t |dthf}d }|r`|r`d| d| }|d|t tjd	t |d
thfdthfddthfddthfdthfdt	hfdt	hfdt	hfdtht
fddthfdthfddthfdS )NZ
youtubeUrl)ZieartistZ
artistNameZmusicIdzhttps://eggs.mu/artist/z/song/none)idZvcodecwebpage_urlZextractor_keyZ	extractorZ
musicTitleZmusicDataPathdisplayNameZartistIdimageDataPathZnumberOfMusicPlaysZnumberOfLikesZnumberOfCommentsZcomposertags.ZreleaseDate)titleurluploaderuploader_id	thumbnail
view_count
like_countcomment_count	composersr   	timestampr   )r
   r	   Z
url_resultr   r   EggsIEZie_keyIE_NAMEstrr   allr   )r   dataZyt_urlZartist_nameZmusic_idr   r   r   r   _extract_music_info   s8    




zEggsBaseIE._extract_music_infoN)__name__
__module____qualname__r   r   r   r,   r   r   r   r   r      s   r   c                   @   s   e Zd ZdZdZddddddd	ed
dgeedgdddgdddddddddedddddedededddg d d!d"gd#d$gd%d$id&gZd'd( Zd)S )*r'   zeggs:singlez7https?://eggs\.mu/artist/[^/?#]+/song/(?P<id>[\da-f-]+)zNhttps://eggs.mu/artist/32_sunny_girl/song/0e95fd1d-4d61-4d5b-8b18-6092c551da90z$0e95fd1d-4d61-4d5b-8b18-6092c551da90Zm4au   シネマと信号
Sunny Girlzre:https?://.*\.jpg(?:\?.*)?$Z1607i_1gu   橘高連太郎Z20241111Z	SunnyGirl)r   extr   r   r!   r    r#   r&   r%   r"   r$   Zartistsupload_dater   )r   	info_dictzLhttps://eggs.mu/artist/KAMO_3pband/song/1d4bc45f-1af6-47a9-8b30-a70cae350b4fZ80cLKA2wnoAZmp4u!   KAMO「いい女だから」AudioKAMOZnot_liveZUCsHLBw2__5Q9y55skXPotOgz$md5:d260da711ecbec3e720293dc11401b87publicz
@KAMO_bandZ20240925z4https://i.ytimg.com/vi/80cLKA2wnoA/maxresdefault.jpgz8https://www.youtube.com/channel/UCsHLBw2__5Q9y55skXPotOg   Tz"https://www.youtube.com/@KAMO_bandifr   zPeople & Blogs)r   r1   r   r   Zlive_statusZ
channel_idZchannel_follower_countdescriptionZavailabilityr    r2   r!   r$   Zchannel_urlr"   durationr#   ZchannelZplayable_in_embedZuploader_urlr   r&   Z	age_limit
categoriesZYoutubeZskip_download)r   r3   Zadd_ieparamsc                 C   s&   |  |}| d| |}| |S )Nzmusics/)	_match_idr   r,   )r   r   Zsong_idZ	json_datar   r   r   _real_extracts   s    
zEggsIE._real_extractN)r-   r.   r/   r(   
_VALID_URLint_TESTSr<   r   r   r   r   r'   =   sd   2r'   c                   @   sH   e Zd ZdZdZddddddd	d
dddddddd
gZdd ZdS )EggsArtistIEzeggs:artistz1https?://eggs\.mu/artist/(?P<id>\w+)/?(?:[?#&]|$)z$https://eggs.mu/artist/32_sunny_girlZ32_sunny_girlzXhttps://image-pro.eggs.mu/profile/1607.jpeg?updated_at=2024-04-03T20%3A06%3A00%2B09%3A00ux   Muddy Mine / 東京高田馬場CLUB PHASE / Gt.Vo 橘高 連太郎 / Ba.Cho 小野 ゆうき / Dr 大森 りゅうひこr0   )r   r!   r7   r      )r   r3   Zplaylist_mincountz"https://eggs.mu/artist/KAMO_3pbandZKAMO_3pbandu   川崎発３ピースバンドzYhttps://image-pro.eggs.mu/profile/35217.jpeg?updated_at=2024-11-27T16%3A31%3A50%2B09%3A00r4   )r   r7   r!   r   r   c              	   C   sz   |  |}| d| |}| d| d|}| jt|ddth| jhffd|it|dthfdthfdthfd	S )
Nzartists/z/musicsr+   .Zplaylist_idr   Zprofiler   )r   r7   r!   )r;   r   Zplaylist_resultr
   dictr,   r)   r	   )r   r   Z	artist_idZartist_dataZ	song_datar   r   r   r<      s    
zEggsArtistIE._real_extractN)r-   r.   r/   r(   r=   r?   r<   r   r   r   r   r@   y   s(   
r@   )r   commonr   Zyoutuber   utilsr   r   r   r	   Zutils.traversalr
   r   r'   r@   r   r   r   r   <module>   s   /<