o
    iz                     @   s|   d dl mZ ddlmZmZmZmZmZ G dd deZG dd deZ	G dd	 d	eZ
G d
d de
ZG dd de
ZdS )   )InfoExtractor   )
clean_htmlformat_fieldint_or_nonestr_or_nonestrip_or_nonec                   @   s   e Zd ZdZdddZdS )MindsBaseIEzhttps?://(?:www\.)?minds\.com/Nc                 C   sD   d| }|  |d}| j||d| dd|r|jndd|dS )	Nzhttps://www.minds.com/api/z
XSRF-TOKENzDownloading z JSON metadatazhttps://www.minds.com/ )RefererzX-XSRF-TOKEN)headersquery)_get_cookiesget_download_jsonvalue)selfpathvideo_idresourcer   api_urltoken r   J/home/ubuntu/.local/lib/python3.10/site-packages/yt_dlp/extractor/minds.py	_call_api   s   zMindsBaseIE._call_api)N)__name__
__module____qualname___VALID_URL_BASEr   r   r   r   r   r	      s    r	   c                   @   sz   e Zd ZdZejd Zddddddd	d
ddeeedgeddddddddddddddddddddgZdd Z	dS )MindsIEmindsz.(?:media|newsfeed|archive/view)/(?P<id>[0-9]+)z.https://www.minds.com/media/100000000000086822 215a658184a419764852239d4970b045100000000000086822mp4zMinds intro sequencezre:https?://.+\.pngottman20130524iuQBill Ottman	animationzattribution-cc)idexttitle	thumbnailuploader_idupload_date	timestampuploader
view_count
like_countdislike_counttagscomment_countlicense)urlmd5	info_dictz1https://www.minds.com/newsfeed/798025111988506624 b2733a74af78d7fd3f541c4cbbaa5950798022190320226304ColinFlaherty20180111iVZ)r(   r)   r*   r/   r-   r.   r,   z5https://www.minds.com/archive/view/715172106794442752T)r6   only_matchingz2https://www.minds.com/newsfeed/1197131838022602752c                 C   s  |  |}| d| |dd }|ddkr*|ddkr#|d }n| |d S |d	 dks2J |}| d
| |d}g }|dpEg D ]}|d}|sPqF||dt|d|d qF|dph|}|dpoi }	|	d}
|d}|rt|tr|g}d }|dp|d}|r| j||dd}|r|j	}||dp||t
|dpd t|dt|dt|	d|
t|
d dt|dt|dt|d|t|d |d!S )"Nzv1/entities/entity/entitytypeactivitycustom_typevideoentity_guid	perma_urlsubtypezv2/media/video/sourcessrclabelsize)	format_idheightr6   ownerObjusernamer3   posterthumbnail_srcF)fatalr*   descriptionr5   time_creatednamezhttps://www.minds.com/%sz
play:countzthumbs:up:countzthumbs:down:countzcomments:count)r(   r*   formatsrQ   r5   r.   r/   r,   uploader_urlr0   r1   r2   r3   r4   r+   )	_match_idr   r   
url_resultappendr   
isinstancestr_request_webpager6   r   r   r   r   )r   r6   	entity_idr>   r   rB   rT   sourcerG   ownerr,   r3   r+   rN   urlhr   r   r   _real_extractD   sj   








zMindsIE._real_extractN)
r   r   r   IE_NAMEr	   r   
_VALID_URLint_TESTSr`   r   r   r   r   r      sP    
)r   c                   @   s    e Zd ZdZdd Zdd ZdS )MindsFeedBaseIE   c                 c   s    | j dd}d}	 | d| d|d| |}|dpg }|D ]}|d}|s,q"| d	| t |V  q"|d
 |d< |d rJt|| j ksLd S |d7 }q
)Nr   )limitsyncTzv2/feeds/container/z/videoszpage entitiesguidzhttps://www.minds.com/newsfeed/z	load-nextfrom_timestamp)
_PAGE_SIZEr   r   rW   r   ie_keylen)r   feed_idr   idatari   r>   rj   r   r   r   _entries   s,   

zMindsFeedBaseIE._entriesc                 C   sX   |  |}| d| j d| || j| j }| | |d |t|d|dS )Nzv1//rj   rS   briefdescription)rV   r   
_FEED_PATH
_FEED_TYPEplaylist_resultrr   r   r   )r   r6   ro   feedr   r   r   r`      s   
zMindsFeedBaseIE._real_extractN)r   r   r   rl   rr   r`   r   r   r   r   re      s    re   c                   @   s:   e Zd ZdZde Zejd ZdZdddddd	d
Z	dS )MindsChannelIEchannelminds:z:(?!(?:newsfeed|media|api|archive|groups)/)(?P<id>[^/?&#]+)zhttps://www.minds.com/ottmanr$   r&   zCo-creator & CEO @minds)r(   r*   rQ   6   r6   r8   playlist_mincountN
r   r   r   rv   ra   r	   r   rb   ru   _TESTr   r   r   r   ry      s    

ry   c                   @   s8   e Zd ZdZde Zejd ZdZddddd	d
Z	dS )MindsGroupIEgroupr{   zgroups/profile/(?P<id>[0-9]+)zgroups/groupzChttps://www.minds.com/groups/profile/785582576369672204/feed/videos785582576369672204zCooking Videos)r(   r*   r   r}   Nr   r   r   r   r   r      s    

r   N)commonr   utilsr   r   r   r   r   r	   r   re   ry   r   r   r   r   r   <module>   s    	i#