o
    iM                     @   sb   d dl Z d dlZd dlZd dlZd dlZejd d dlmZ G dd deZe	dkr/	 dS dS )    Nz..)Spiderc                   @   s   e Zd Zdd Zd&ddZdd Zdd	 Zd
d Zdd Zdd Z	dd Z
dd Zd'ddZdd Zdd Zdd Zdd Zdd  Zd!d" Zed#d$ Zd%S )(r   c                 C      dS )NZ
JieYingShi selfr   r   )   /storage/emulated/0/lz/py/sy/界影视.pygetName      zSpider.getName c                 C   s   d| _ d| _ddi| _d S )Nzhttps://www.hkybqufgh.comz/https://json.doube.eu.org/error/4gtv/index.m3u8
User-AgentoMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36)home_url	error_urlheaders)r   extendr   r   r   init   s   
zSpider.initc                 C   s   g S Nr   r   r   r   r   getDependence   r	   zSpider.getDependencec                 C      d S r   r   )r   urlr   r   r   isVideoFormat   r	   zSpider.isVideoFormatc                 C   r   r   r   r   r   r   r   manualVideoCheck    r	   zSpider.manualVideoCheckc                 C   s(   ddddddddddd	d
dgiS )Nclass1u   电影)type_id	type_name2u	   电视剧4u   动漫3u   综艺r   )r   filterr   r   r   homeContent#   s   zSpider.homeContentc                 C   s   |  | j}|dddS Nr   listparsejx)get_datar   )r   ar   r   r   homeVideoContent+   s   zSpider.homeVideoContentc                 C   s,   | j d| d|  }| |}|dddS )Nz/vod/show/id/z/page/r   r"   )r   r&   )r   tidpgr   r   r   datar   r   r   categoryContent0   s   
zSpider.categoryContentc                 C   s   |d }|  |}|dddS r!   )get_detail_data)r   idsvidr+   r   r   r   detailContent5   s   
zSpider.detailContentr   c                 C   s>   t |dkrg dddS | jd|  }| |}|dddS )N   r   r"   z/vod/search/)intr   r&   )r   keyquickr*   r   r+   r   r   r   searchContent:   s
   
zSpider.searchContentc                 C   s   |  |}|| jdddS )Nr1   r   )r   headerr$   r%   )get_play_datar   )r   flagidvipFlagsr   r   r   r   playerContentB   s   
zSpider.playerContentc                 C   r   r   r   )r   paramsr   r   r   
localProxyF   r	   zSpider.localProxyc                 C   r   )Nu   正在Destroyr   r   r   r   r   destroyI   r	   zSpider.destroyc           
   
   C   s   g }zJt j|| jd}|jdkr|W S td|j}td|j}td|j}td|j}tt|D ]}|	|| || || || d q5W |S  t j
yd }	 zt|	 W Y d }	~	|S d }	~	ww )Nr      z\\"vodId\\":(.*?),z\\"vodName\\":\\"(.*?)\\"z\\"vodPic\\":\\"(.*?)\\"z\\"vodRemarks\\":\\"(.*?)\\")vod_idvod_namevod_picvod_remarks)requestsgetr   status_coderefindalltextrangelenappendRequestExceptionprint)
r   r   r+   resZvod_id_sZ
vod_name_sZ	vod_pic_sZvod_remarks_sier   r   r   r&   P   s.   

	zSpider.get_datac                 C   s"  | j d|  }ttt d }| |d| d| }zZtj||d}|jdkr.g W S | d }g }|d D ]}|d	 }	|d
 }
|	|	 d| d|
  q:|d |d |d |d |d |d |d |d |d dd
|d}|gW S  tjy } zt| W Y d }~g S d }~ww )Nz(/api/mw-movie/anonymous/video/detail?id=  id=(&key=cb808529bae6b6be45ecfab29a4889bc&t=r?   r@   r+   ZepisodeListnamenid$-ZvodClassZvodIdZvodNameZ
vodRemarksZvodYearZvodAreaZvodActorZvodDirectorZ
vodContentu   默认#)r   rA   rB   rD   vod_yearvod_area	vod_actorvod_directorvod_contentvod_play_fromvod_play_url)r   strr2   timeget_headersrE   rF   rG   jsonrM   joinrN   rO   )r   r/   r   tr   rP   rQ   ZurlsiirV   rW   r+   rR   r   r   r   r-   f   s>   
zSpider.get_detail_datac           
   
   C   s   | d}|d }|d }| jd| d|  }ttt d }| |d| d| d| }ztj||d	}|jd
krB| j	W S |
 d d d d W S  tjyg }	 zt|	 W Y d }	~	| j	S d }	~	ww )NrY   r   r1   z0/api/mw-movie/anonymous/v2/video/episode/url?id=z&nid=rS   rT   rU   r?   r@   r+   r#   r   )splitr   rb   r2   rc   rd   rE   rF   rG   r   re   rN   rO   )
r   ZplayinfoZ_idZ_pidr   rg   r   rP   rR   r   r   r   r7      s    

zSpider.get_play_datac                 C   s6   t t |    }dd|d| dd}|S )Nr   z!application/json, text/plain, */*zA"Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"zhttps://www.hkybqufgh.com/)r   Acceptsignz	sec-ch-uarg   referer)hashlibsha1md5encode	hexdigest)rg   rR   rl   r   r   r   r   rd      s    	zSpider.get_headersN)r
   )r   )__name__
__module____qualname__r   r   r   r   r   r    r(   r,   r0   r5   r;   r=   r>   r&   r-   r7   staticmethodrd   r   r   r   r   r      s&    

 r   __main__)
rn   rH   sysrc   rE   pathrM   base.spiderr   rs   r   r   r   r   <module>   s    