o
    ic                     @   sp   d dl Z ddlmZ ddl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dS )    N   )InfoExtractor   )OnDemandPagedListformat_fieldint_or_nonesmuggle_urlc                   @   s"   e Zd ZdZdddZdd ZdS )StoryFireBaseIEz"https?://(?:www\.)?storyfire\.com/Nc                 C   s&   | j d| d| |d| d|dS )Nzhttps://storyfire.com/app//zDownloading z JSON metadata)query)_download_json)selfpathvideo_idresourcer    r   N/home/ubuntu/.local/lib/python3.10/site-packages/yt_dlp/extractor/storyfire.py	_call_api   s   zStoryFireBaseIE._call_apic                 C   s   |d }|  d|d d}|d}d|||dtd| d	d
i|dt|dt|dt|dt|dt|d|d|t|d dt|dpW|ddS )Ntitlez*https?://player\.vimeo\.com/external/(\d+)vimeoVideoURLzvimeo idhostIDurl_transparentdescriptionzhttps://player.vimeo.com/video/refererzhttps://storyfire.com/
storyImageviews
likesCountcommentsCountvideoDurationpublishDateusernamez#https://storyfire.com/user/%s/videoepisodeNumberepisode_number)_typeidr   r   url	thumbnail
view_count
like_countcomment_countduration	timestampuploaderuploader_iduploader_urlr"   )_search_regexgetr   r   r   )r   videor   vimeo_idr-   r   r   r   _parse_video   s4   

zStoryFireBaseIE._parse_videoN)__name__
__module____qualname___VALID_URL_BASEr   r3   r   r   r   r   r	      s    
r	   c                   @   sN   e Zd Zejd Zdddddddd	d
ddeeedddidgdZdd ZdS )StoryFireIEz"video-details/(?P<id>[0-9a-f]{24})z<https://storyfire.com/video-details/5df1d132b6378700117f9181 caec54b9e4621186d6079c7ec100c1eb	378954662mp4z Buzzfeed Teaches You About MemesntZAJFECERSgqHSxzonV5K2E89s1i]z$md5:0b4e28021548e144bed69bb7539e62eazwhang!20191212i  )r$   extr   r-   r+   r   r,   upload_dater*   r'   r(   r)   skip_downloadTz Unable to download JSON metadata)r%   md5	info_dictparamsexpected_warningsc                 C   s&   |  |}| d|dd }| |S )Nzgeneric/video-detailr1   )	_match_idr   r3   )r   r%   r   r1   r   r   r   _real_extractK   s   

zStoryFireIE._real_extractN)	r5   r6   r7   r	   r8   
_VALID_URLint_TESTrG   r   r   r   r   r9   2   s,    
r9   c                   @   s:   e Zd Zejd ZdddiddZdZdd	 Zd
d Z	dS )StoryFireUserIEzuser/(?P<id>[^/]+)/videoz=https://storyfire.com/user/UQ986nFxmAWIgnkZQ0ftVhq4nOk2/videor$   UQ986nFxmAWIgnkZQ0ftVhq4nOk2   r%   rC   playlist_mincount   c                 c   sD    |  d|d|d  d|| j id }|D ]}| |V  qd S )NpublicVideoszpage r   skipvideos)r   
_PAGE_SIZEr3   )r   user_idpagerS   r1   r   r   r   _fetch_page]   s   
zStoryFireUserIE._fetch_pagec                 C   s,   |  |}tt| j|| j}| ||S r4   )rF   r   	functoolspartialrW   rT   playlist_result)r   r%   rU   entriesr   r   r   rG   e   s   
zStoryFireUserIE._real_extractN)
r5   r6   r7   r	   r8   rH   rJ   rT   rW   rG   r   r   r   r   rK   R   s    
rK   c                   @   sF   e Zd Zejd Zdddidddddid	d
gZdd Zdd ZdS )StoryFireSeriesIEz%write/series/stories/(?P<id>[^/?&#]+)z@https://storyfire.com/write/series/stories/-Lq6MsuIHLODO6d2dDkr/r$   z-Lq6MsuIHLODO6d2dDkr   rN   z:https://storyfire.com/write/series/stories/the_mortal_one/the_mortal_oner   )r%   rC   playlist_countc                 c   s*    |  D ]}|dr| |V  qd S )NhasVideo)valuesr0   r3   )r   storiesstoryr   r   r   _extract_videos|   s   
z!StoryFireSeriesIE._extract_videosc                 C   s*   |  |}| d|d}| | ||S )NseriesStorieszseries stories)rF   r   rZ   rd   )r   r%   	series_idrb   r   r   r   rG      s
   
zStoryFireSeriesIE._real_extractN)	r5   r6   r7   r	   r8   rH   _TESTSrd   rG   r   r   r   r   r\   l   s    
r\   )rX   commonr   utilsr   r   r   r   r	   r9   rK   r\   r   r   r   r   <module>   s    & 