U
    gc                     @   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)Z_download_json)selfpathvideo_idresourcer    r   >/tmp/pip-unpacked-wheel-q5ljy6pj/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p|ddS )Ntitlez*https?://player\.vimeo\.com/external/(\d+)ZvimeoVideoURLzvimeo idZhostIDZurl_transparentdescriptionzhttps://player.vimeo.com/video/Zrefererzhttps://storyfire.com/Z
storyImageZviewsZ
likesCountZcommentsCountZvideoDurationZpublishDateusernamez#https://storyfire.com/user/%s/videoZepisodeNumberepisode_number)_typeidr   r   urlZ	thumbnail
view_count
like_countcomment_countduration	timestampuploaderuploader_idZuploader_urlr   )Z_search_regexgetr   r   r   )r   videor   Zvimeo_idr    r   r   r   _parse_video   s8     
 
zStoryFireBaseIE._parse_video)N)__name__
__module____qualname___VALID_URL_BASEr   r#   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/5df1d132b6378700117f9181Z caec54b9e4621186d6079c7ec100c1ebZ	378954662Zmp4z Buzzfeed Teaches You About MemesZntZAJFECERSgqHSxzonV5K2E89s1i]z$md5:0b4e28021548e144bed69bb7539e62eazwhang!Z20191212i  )r   extr   r    r   r   r   Zupload_dater   r   r   r   Zskip_downloadTz Unable to download JSON metadata)r   md5	info_dictparamsZexpected_warningsc                 C   s&   |  |}| d|dd }| |S )Nzgeneric/video-detailr"   )	_match_idr   r#   )r   r   r   r"   r   r   r   _real_extractK   s    
  zStoryFireIE._real_extractN)	r$   r%   r&   r	   r'   
_VALID_URLint_TESTr.   r   r   r   r   r(   2   s,   
 r(   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   ZUQ986nFxmAWIgnkZQ0ftVhq4nOk2   r   r+   Zplaylist_mincount   c                 c   sB   |  d|d|d  d|| j id }|D ]}| |V  q,d S )NZpublicVideoszpage r   skipvideos)r   
_PAGE_SIZEr#   )r   user_idpager7   r"   r   r   r   _fetch_page]   s       zStoryFireUserIE._fetch_pagec                 C   s,   |  |}tt| j|| j}| ||S )N)r-   r   	functoolspartialr;   r8   playlist_result)r   r   r9   entriesr   r   r   r.   e   s    
 zStoryFireUserIE._real_extractN)
r$   r%   r&   r	   r'   r/   r1   r8   r;   r.   r   r   r   r   r2   R   s   
 r2   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   r4   z:https://storyfire.com/write/series/stories/the_mortal_one/Zthe_mortal_oner   )r   r+   Zplaylist_countc                 c   s(   |  D ]}|dr| |V  qd S )NZhasVideo)valuesr!   r#   )r   storiesZstoryr   r   r   _extract_videos|   s    
z!StoryFireSeriesIE._extract_videosc                 C   s*   |  |}| d|d}| | ||S )NZseriesStorieszseries stories)r-   r   r>   rD   )r   r   Z	series_idrC   r   r   r   r.      s    
  zStoryFireSeriesIE._real_extractN)	r$   r%   r&   r	   r'   r/   Z_TESTSrD   r.   r   r   r   r   r@   l   s    
  r@   )r<   commonr   utilsr   r   r   r   r	   r(   r2   r@   r   r   r   r   <module>   s   & 