
    i
                         d Z ddlZddlZddlmZ ddlmZmZ ddlmZ dddddd	d
Z	dZ
dZdgZdZddj                  d  ed      D              dz   ddddddZd Zd Zy)zUBilibili is a Chinese video sharing website.

.. _Bilibili: https://www.bilibili.com
    N)	urlencode)datetime	timedelta)utilshttps://www.bilibili.comQ3077586FJSON)websitewikidata_idofficial_api_documentationuse_official_apirequire_api_keyresultsT   videosz4https://api.bilibili.com/x/web-interface/search/type0 c              #   b   K   | ]'  }t        j                  t        j                         ) y w)N)randomchoicestring	hexdigits).0_s     '/root/searxng/searx/engines/bilibili.py	<genexpr>r   "   s     I!fmmF$4$45Is   -/   infocz-17V8	undefined4)	innersignbuvid3zi-wanna-go-backb_utFEED_LIVE_VERSIONheader_theme_versionhome_feed_columnc                 v    d|d   t         d| dd}t         dt        |       |d<   d|d	   d
<   t        |d<   |S )Ntruepagenor   video)__refresh__page	page_sizesingle_columnkeywordsearch_type?urlr   headersReferercookies)results_per_pagebase_urlr   cookie)queryparamsquery_paramss      r   requestr>   +   sZ    x %L  j)L"9!:;F5M#=F9i F9M    c                    | j                         }g }|j                  di       j                  dg       D ]  }t        j                  |d         }|d   }|d   }|d   }|d   }|d   }	|d	   }
t	        j
                  |
      }t        j                  |d
         }|r|t        d      kD  rd }d|	 d}|j                  ||||||||dd	        |S )Ndataresulttitlearcurlpicdescriptionauthoraidpubdateduration<   )minutesz,https://player.bilibili.com/player.html?aid=z(&high_quality=1&autoplay=false&danmaku=0zvideos.html)	rC   r4   contentrG   publishedDatelength	thumbnail
iframe_srctemplate)	jsongetr   html_to_textr   fromtimestampparse_duration_stringr   append)resp
search_resr   itemrC   r4   rP   rF   rG   video_id	unix_dateformatted_daterJ   
iframe_urls                 r   responser`   <   s   JGvr*..x< 
""4=18nK	=)h;O	!//	: ..tJ/?@9R#88HCH:Muv
& !/"&()
	
%
@ Nr?   )__doc__r   r   urllib.parser   r   r   searxr   aboutpagingr8   
categoriesr9   joinranger:   r>   r`    r?   r   <module>rj      s   
   " (  *"&	 
 Z
 B ggIuRyIIGS'
"%r?   