U
    g                     @   s@   d dl mZ ddlmZmZmZmZmZmZ G dd deZ	dS )   )InfoExtractor   )int_or_noneparse_iso8601str_or_nonestrip_or_nonetry_geturljoinc                   @   sT   e Zd ZdZdddddddd	d
ddddeeeeddddddddgZdd ZdS )StreetVoiceIEz>https?://(?:.+?\.)?streetvoice\.com/[^/]+/songs/(?P<id>[0-9]+)z.https://streetvoice.com/skippylu/songs/123688/Z 0eb535970629a5195685355f3ed60bfdZ123688mp3u   流浪z$md5:8eb0bfcc9dcd8aa82bd6efca66e3fea6zre:^https?://.*\.jpgi  Z20100923u   Crispy脆樂團Z627810z&re:^https?://streetvoice.com/skippylu/i]LZ2010)idexttitledescription	thumbnaildurationZupload_dateuploaderuploader_iduploader_url	timestamp
view_count
like_countcomment_countrepost_counttracktrack_idalbum)urlmd5Z	info_dictz/http://tw.streetvoice.com/skippylu/songs/94440/T)r   Zonly_matchingc                    s  |  |}d| d}| j||ddid  d }g }dD ]\}}| j|| d |d| d	d
ddphi d}|svq:d||dd}	|dkrd|	d< | jd|dd d}
|
rt|
}
|	|
|
d ||	 q: dpi }|d} fdd}|||t d dt dt	 dt
|d d t|d!|rTt|d| dnd |d"|d#|d$|d%||t
 d&d d'S )(Nz$https://streetvoice.com/api/v4/song//fieldszalbum,comments_count,created_at,id,image,length,likes_count,name,nickname,plays_count,profile,share_count,synopsis,user,username)queryname))zhls/filehls)filehttp)zfile/originaloriginalzDownloading z format URL    F)datafatalr$   r   none)r   	format_idr   Zvcodecr#   Zm3u8_nativeprotocolz\.mp3\.(\d+)kZbitrate)default)abrZtbruserusernamec                    s   t  | d S )N_count)r   getxZsong @/tmp/pip-unpacked-wheel-q5ljy6pj/yt_dlp/extractor/streetvoice.py<lambda>M   r'   z-StreetVoiceIE._real_extract.<locals>.<lambda>ZsynopsisimagelengthZ
created_atc                 S   s   | d d S )NZprofileZnicknamer6   r3   r6   r6   r7   r8   W   r'   r   ZplaysZlikescommentsZsharec                 S   s   | d d S )Nr   r"   r6   r3   r6   r6   r7   r8   `   r'   )r   formatsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )Z	_match_idZ_download_jsonr2   Z_search_regexintupdateappendr   r   r   r   r   r	   )selfr   Zsong_idbase_urlr   r<   suffixr+   Zf_urlfr.   r/   r0   Z	get_countr6   r5   r7   _real_extract*   st    
 
 
 
zStreetVoiceIE._real_extractN)__name__
__module____qualname__Z
_VALID_URLr=   Z_TESTSrD   r6   r6   r6   r7   r
      s8   r
   N)
commonr   utilsr   r   r   r   r   r	   r
   r6   r6   r6   r7   <module>   s    
