
    nh                     ~    d dl Z d dlZd dlmZ ej                            d           d dlmZ  G d de          ZdS )    N)PyQueryz..)Spiderc                   Z    e Zd Zd ZddZd Zd Zd Zd Zd Z	dd
Z
d Zd Zd Zd ZdS )r   c                     dS )NThePorn selfs    ,   /storage/emulated/0/纯福利/PY1/ThePorn.pygetNamezSpider.getName	   s    y     c                     d S Nr   )r
   extends     r   initzSpider.init       r   c                    i }	 |                      d          }t          |j                  }g }ddddddd}|                                D ]\  }}|                    ||d	            |d
                                          D ]}	|	                    d          }
|
rs|
                                                                }|
                    d          }|r6|r4|                    |d|                    d          d          d	           t                      fd|D             |d<   nA# t          $ r4}ddddddd}d |                                D             |d<   Y d }~nd }~ww xY w|S )Nzhttps://theporn.cc/categorieszcategories/alljaveuvrz
video/bestzjav/uncensored)u   影片u   日本AVu   欧美VRu   最佳影片u   日本无码	type_nametype_idz .categories_list .categorie_itemahrefzcategories//c                 f    g | ]-}|d          |d         fxv                               +|.S r   )add).0clskeyseens     r   
<listcomp>z&Spider.homeContent.<locals>.<listcomp>*   sl      H  H  Hsc+FVX[\eXfEg>gclp=p=py}  zB  zB  CF  zG  zG=ps=p=p=pr   classc                     g | ]
\  }}||d S )r   r   )r"   kvs      r   r&   z&Spider.homeContent.<locals>.<listcomp>1   s$    ]]]$!QQ1==]]]r   )fetchpqtextitemsappendfindstripattrsplitset	Exception)r
   filterresultrsprootclassesmain_categoriesnameciditema_tagr   e
cateManualr$   r%   s                 @@r   homeContentzSpider.homeContent   s     	^**<==Cch<<DG +UY ,>N O
 -2244 D D	cTcBBCCCC?@@FFHH 	 			#  ::<<--//D ::f--D  )-'JTZZ__R5H'J'J( (   
 55D H  H  H  H  Hg  H  H  HF7OO 	^ 	^ 	^*UY ,>N J ^]*JZJZJ\J\]]]F7OOOOOO	^ s   D0D7 7
E5*E00E5c                                            d          }d fd t          |j                  d                                          D             iS )Nhttps://theporn.cc/listc                 :    g | ]}                     |          S r   parseVideoItemr"   r>   r
   s     r   r&   z+Spider.homeVideoContent.<locals>.<listcomp>7   s'    qqqt,,T22qqqr   .video-list .avdata-outer)r+   r,   r-   r.   )r
   r8   s   ` r   homeVideoContentzSpider.homeVideoContent5   sT    jj.//qqqq|r#(||Lg?h?h?n?n?p?pqqqrrr   c                    	 |                     d          }|                    d          }|                     d          }|                    d          p|                    d          }|r|                    d          d         |                     d                                          |                    d	          r|nd
|z   |                     d                                          dnd S #  Y d S xY w)Nz	a.av-linkr   zimg.cover-imgzdata-srcsrcr   r   z.av_data_titlehttphttps://theporn.cc	.duration)vod_idvod_namevod_picvod_remarks)r0   r2   r3   r-   
startswith)r
   r>   r?   r   img_tagcovers         r   rH   zSpider.parseVideoItem9   s    	IIk**E::f%%Dii00GLL,,CU0C0CE  **S//"- II&677<<>>$)$4$4V$<$<^55BVY^B^#yy55::<<	  
   	44s   C0C3 3C8c                     t          |          dk    rd| }nd| d| }                     |          }t          |j                  }g }dD ]:}	 ||	          }
|
j        dk    r" fd|
                                D             } n;d}	  |d          }|j        dk    r|                    d	          }|j        dk    r{d}|                                D ]b}|                    d
          }|rIt          j	        d|          }|r2t          |
                    d                    }t          ||          }c|}n#  Y nxY w|t          |          |dddS )N   rD   r   )rJ   .avdata-outerz.video-list .cardr   c                 :    g | ]}                     |          S r   rG   rI   s     r   r&   z*Spider.categoryContent.<locals>.<listcomp>V   s'    SSS$--d33SSSr   i'  z.paginationr   r   z/(\d+)$Z   i?B )rE   page	pagecountlimittotal)intr+   r,   r-   lengthr.   r0   r2   researchgroupmax)r
   tidpgr6   r   urlr8   r9   videosselector
video_listr^   
pagination
page_links	last_pagelinkr   matchpage_nums   `                  r   categoryContentzSpider.categoryContentH   s   r77a<<---CC222b22Cjjoo#(||[ 	 	HhJ 1$$SSSS
@P@P@R@RSSS %
 		m,,J 1$$'__S11
$q(( !I * 0 0 2 2 E E#yy00 E$&Ij$$?$?E$ E+.u{{1~~+>+>,/	8,D,D	 )I	D GG"
 
 	
s   B1E   Ec                 @   |d         }|                      d|           }t          |j                  } |d                                                              dd          p |d                                          } |d                              d          }|sLt          j        d	 |d
                              d          pd          }|r|                    d          nd}d||||dddd |d                                          pddd| dgiS )Nr   https://theporn.cc/video/titlez
 - ThePornr   z.av-big-title .inner-titlez
.cover-imgrM   z$background-image:\s*url\("([^"]+)"\)z.vjs-posterstylerY   rE   u   未知演员u   未知导演u   未知地区2024rP   u   未知时长r   u   第1集$)rQ   rR   rS   vod_content	vod_actorvod_directorvod_areavod_yearrT   vod_play_fromvod_play_url)r+   r,   r-   replacer2   rc   rd   re   )r
   arrayrg   r8   r9   rv   rW   rq   s           r   detailContentzSpider.detailContentu   sE   Ahjj:S::;;#(||W""$$,,\2>>k$$GcBdBdBiBiBkBk\""''.. 	4IEttMGZGZG_G_`gGhGhGnlnooE&+3EKKNNNE '*&4,,1133E~&,s,,
 
   	r   1c                     t          |          dk    rd| }nd| d| }                     |          }t          |j                  }dD ]<} ||          }|j        dk    r$d fd|                                D             ic S =dg iS )NrY   zhttps://theporn.cc/search/r   )z.search-results .video-itemrJ   rZ   r   rE   c                 :    g | ]}                     |          S r   rG   rI   s     r   r&   z(Spider.searchContent.<locals>.<listcomp>   s'     Z Z Zt!4!4T!:!: Z Z Zr   )ra   r+   r,   r-   rb   r.   )	r
   r$   quickr]   ri   r8   r9   rk   rl   s	   `        r   searchContentzSpider.searchContent   s    t99>>4s44CC;s;;T;;Cjjoo#(||e 	\ 	\HhJ 1$$ Z Z Z ZzGWGWGYGY Z Z Z[[[[ % |r   c                    |                      d|           }t          |j                  }d} |d                                          D ]H}|                                }d|v r.t	          j        d|          }	|	r|	                    d          } nI|rd| d}
n$ |d	          }|r|                    d
          nd}
dd|
dddddS )Nru   r   scripthash_idz"hash_id":\s*"([a-f0-9]+)"rY   zhttps://b2.bttss.cc/videos/z/g.m3u8?h=3121efe8979c635zvideo#video-player_html5_apirM   r   z<Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36rD   rO   )z
User-AgentRefererOrigin)parseplayUrlri   header)r+   r,   r-   r.   rc   rd   re   r2   )r
   flagidvipFlagsr8   r9   r   r   script_textrq   rM   	video_tags               r   playerContentzSpider.playerContent   s
   jj9R99::#(||d8nn**,, 	 	F ++--KK''	"?MM #kk!nnGE 	=RRRRCC;<<I+4<)..'''"C \0. 		
 	
 		
r   c                 B    rt          fddD                       ndS )Nc              3   D   K   | ]}|                                 v V  d S r   )lower)r"   fmtri   s     r   	<genexpr>z'Spider.isVideoFormat.<locals>.<genexpr>   s0      dd#3#))++%ddddddr   )z.m3u8z.mp4z.aviz.mkvz.flvz.webmF)any)r
   ri   s    `r   isVideoFormatzSpider.isVideoFormat   s2    hkvsdddd1cddddddqvvr   c                     d S r   r   r	   s    r   manualVideoCheckzSpider.manualVideoCheck   r   r   c                     ddi dgS )N   z
video/MP2Tr   r   )r
   params     r   
localProxyzSpider.localProxy   s    \2r**r   N)r   )r   )__name__
__module____qualname__r   r   rB   rK   rH   rs   r   r   r   r   r   r   r   r   r   r   r      s             $ $ $Ls s s  +
 +
 +
Z  2   "
 
 
<w w w  + + + + +r   r   )	rc   syspyqueryr   r,   pathr/   base.spiderr   r   r   r   <module>r      s    				 



 ! ! ! ! ! !          |+ |+ |+ |+ |+V |+ |+ |+ |+ |+r   