+
     h\  c            	       s    ^ RI t ^ RIt^ RIHt ^ RIHt ^RIHtHtH	t	H
t
HtHtHtHtHtHt ^RIHtHt ^RIHtHtHtHt ^RIHtHtHtHt  ! R R	4      t ! R
 R]]]]]4      t ! R R]]]]]4      t R# )i    N)ListBeautifulSoup)
CommentListPartialArticle
PartialTagProfile
ResultList
StatisticsStyle	Thumbnail_parse_comments_parse_results)SearchCategoryThumbnailType)LOGGERget_pageget_page_typejoin)GetTagsMixinGetWatchersMixinRSSFeedMixinSharedMethodsMixinc                   s   a  ] tR t^t o RtV 3R lR ltR tV 3R lR ltR/ /V 3R lR	 lltV 3R
 lR lt	RRR/V 3R lR lllt
RtV tR# )BaseMetaClassag  An abstract class that implements the attributes present on nearly every page. In addition, it implements
some shared hidden methods and the top level get_comments method.

Parameters
-----------
html : BeautifulSoup
    The html containing the comments

Attributes
-----------
id : int
    The id of the page
name_id : str
    The name_id of the entity, cannot be changed, it's a mix of the original username lowercased with
    spaces removed and shortened.
url : str
    The url of the page
comments : CommentList[Comment]
    The comments scrapped on this list in order.
report : str
    URL to report the page
c                    < V ^8  d   QhRS[ /#    htmlr   Zformat__classdict__   "5/usr/lib/python3.14/site-packages/moddb/pages/base.py__annotate__BaseMetaClass.__annotate__0   s     & &] &    c           
     s   \        V R R4      '       g$    VP                  RRR7      P                  V n         \        \        P                  ! R	VP                  RR
.R7      R,          4      ^,          4      V n         TP                  RRR7      R,          T n        T P                  P                  R4      R,          T n         \        TP                  RRR7      R,          4      T n        T P-                  T4      T n        Yn        R#   \         d$    TP                  RRR7      R,          T n         ELi ; i  \         d     \        TP                  RR R/R7      R,          4      T n         L  \        \        3 dD    \        TP                  RRR7      R,          P                  R4      R,          4      T n          ELJi ; ii ; i  \         d7    \        TP                  RT P                  R7      R,          4      T n         ELri ; i  \         dc    RT n        \        P                   ! RT P"                  P$                  T P                  \        P&                  \(        P*                  8  R7        ELi ; i)nameNaZmainEntityOfPageZitempropmetazog:title)Zpropertycontentzsiteareaid=(\d*)Z
reporticonclass_hrefinputZ
siteareaidZattrsvaluezog:image/zog:urlstringZReportz'%s' '%s' cannot be reportedZexc_info)Zgetattrfindr0   r#   AttributeErrorintresearchid	TypeErrorspliturlr   name_idreportr   info	__class____name__levelloggingDEBUG_get_commentscomments_html)selfr   s   &&r   __init__ZBaseMetaClass.__init__0   s   tVT**N IIc4FIGNN			`		-tyyl^y/TU[/\]^_`DG	Fyy(y;IFDH xx~~c*2.		tyyXy>vFGDK **40
E " N IIfzIB9M	N  	``dii7MiNwWX"I. `diiiDYOUUVYZ[]^_`	`  	FDIIc$))I<VDEDH	F  	DKKK.''		6	 	sa   "D AD< >G (H *D98D9<G*E44AGGGG=HHA)J ?J c                P    R V P                   P                   RV P                   R2# Z<z name=Z>r@   rA   r#   rH      &r   __repr__ZBaseMetaClass.__repr__X   &    4>>**+6$))A>>r"   c                &   < V ^8  d   QhRS[ RS[/# r   r   return)r   r   r   r   r   r    r!   [   s     
 
- 
K 
r"   c                sR    \        V4      w  r#rE\        VVVV P                  VR7      # )zExtracts the comments from an html page and adds them to a CommentList.

Parameters
-----------
html : BeautifulSoup
    The html containing the comments

Returns
--------
CommentList
    The list of parsed comments
)resultscurrent_pagetotal_pagesr<   total_results)r   r   r<   )rH   r   rT   rU   rV   rW   s   &&    r   rE   ZBaseMetaClass._get_comments[   s4     =LD<Q9{%#'
 	
r"   paramsc                s,   < V ^8  d   QhRS[ RS[RS[/# )r   r<   rX   rS   )strZdictr   r   r   r   r    r!   r   s"     
 
 
 
j 
r"   c          	     sX    \        WR7      p\        V4      w  rErg\        VVVVVVR7      # )a  This function takes a list of thumbnails of `object_type` in html and returns
a list of Thumbnail of that object type.

Parameters
-----------
url : str
    The url with the list
object_type : ThumbnailType
    The type of objects to be expected. Easier to pass and hardcode then to guess
params : dict
    A dictionnary of filters to pass on to the soup function used to filter the results.

Returns
-------
ResultList[Thumbnail]
    The list of objects present on the page as a list of thumbnails.
rX   )rT   rX   r<   rU   rV   rW   )r   r   r   )rH   r<   rX   r   rT   rU   rV   rW      &&$     r   _getZBaseMetaClass._getr   s<    $ +<J4<P9{%#'
 	
r"   c                6   < V ^8  d   QhRS[ RS[S[,          /# r   indexrS   )r6   r    r
   r   r   r   r    r!      s     
 
 
i 
r"   c          
     sB   VP                  RRR7      V,          pRp\        P                  ! WCP                  4      pRpV Uu. uFP  p\	        \        P
                  ! Wg^ ,          4      ^,          V^ ,          \        P                  V^,          R7      NKR  	  up# u upi )a  Hidden method used to parse media content from the page. Since the only difference is that pages
with videos have one extra script that tells the window not do any sort of video playing assistance.
Also used to cached all media on a page.

Parameters
----------
index : int
    The index of the script containing the cached objects. 1 if it's only images, 2 if videos are
    also included

Returns
--------
List[Thumbnail]
    List of media like thumbnails that can be parsed individually. Can be a very long list.
scriptTr/   znew Array\(0, "(\S*)", "(\S*)"z\/([a-z0-9-]*)#imagebox)r#   r<   typeimage)find_allr7   Zfindalltextr
   r8   r   media)rH   r_   r   r`   ZregexZmatchesZname_finderZmatchr[   r   
_get_mediaZBaseMetaClass._get_media   s      x5e<1**UKK00 !
 ! YY{!H5a8!H"((Ah	 !
 	
 
s   ABshow_deletedFc                rQ   r^   )r6   r   r   r   r   r    r!      s     W W# W[ Wr"   c               st    RV'       d   RMR/pV P                  \        V P                   RV 2VR7      4      # )a  Used to get comments on the model regardless of what page they may be present in. The function
itself simply relies on two other to make the request and parse the table.

Parameters
----------
index : int
    The page of the model to get the comments for.
show_deleted : Optional[bool]
    Pass true to show deleted user comments. Only works if it is a page
    you have permissions on.

Returns
--------
CommentList[Comment]
    A list-like object containing the comments and additional methods
ZdeletedtNz/page/rZ   )rE   r   r<   )rH   r_   rg   rX   s   &&$ r   get_commentsZBaseMetaClass.get_comments   s9    " LSd;!!(dhhZveW+Ef"UVVr"   )rG   rF   r9   r#   r=   r>   r<   N)i   )rA   
__module____qualname____firstlineno____doc__rI   rO   rE   r\   rf   ri   __static_attributes____classdictcell__)r   s   @r   r   r      sY     .& &P?
 
.
r 
 
<
 
>W5 W W Wr"   r   c                   s   a a ] tR t^t oRtV3R lV 3R lltV3R lR ltV3R lR ltV3R lR	 ltV3R
 lR lt	R t
RtVtV ;t# )PageMetaClassa	  The common class representing the page for either a Mod, Game, Engine or a Member. Mostly used to be inherited by
those classes.

Parameters
-----------
html : BeautifulSoup
    The page to be parsed.

page_type : ThumbnailType
    The type of pages, this is passed down be the base class to help with the parsing of

Attributes
-----------
name : str
    The name of the page
profile : Profile
    The object with the content of the page's profile box.
stats : Statistics
    The object containg stat data on the page such as views, followers, ect...
style : Style
    The object containing data relevant to the type of the page, not valid for Engines. Multiplayer, singleplayer,
    ect...
suggestions : List[Thumbnail]
    A list of thumbnail object representing moddb's suggestion of similar pages for the visiting member.
files : List[Thumbnail]
    A list of thumbnails representing a possible partial list of all the files. To get a guaranteed full
    list either compare with statistics.files to see if the length of the list matches the number of files in the
    stats or use get_files, although that will still not return the whole list if there are multiple pages of
    files.
articles : List[Thumbnail]
    A list of thumbnail objects representing articles present on the page. Usually 3 or 4 articles long.
article :  PartialArticle
    A partial representation of the frong page article. This does not include things like comments or any
    of the sideba elements found in a full article. Can be parsed to return the complete Article object.
tags : List[PartialTag]
    A list of partial tags. You can use `get_tags` and then use the name id to get the right one.
imagebox : List[Thumbnail]
    A list of Thumbnail objects representing the image, videos and audio clips that are presented in the
    image box on the front page.
embed : str
    The html necessary to embed the a widget of the page.
rating : float
    A float out of ten representing the average rating for the page
medias : List[Thumbnail]
    list of thumbnails representing all the combined media objects of a page (videos and images)
summary : str
    Short description of the page, in plaintext.
description : str
    The full description of the page, contains html
plaintext : str
    Plaintext version of the full description
c                rQ   )r   r   	page_type)r   r   r   r   r   r    PageMetaClass.__annotate__   s     d" d"] d"~ d"r"   c                s  < \         S	V `  V4       W n        V\        P                  8w  d~   \        V4      V n         \        V4      V n        V\        P                   8w  d   \#        V4      V n        V P'                  V4      V n         VP+                  RRRR7      R,          V n         V P7                  V4      V n        Rp VP+                  R
RR7      ;'       g    VP+                  R
RR7      pVP>                  P>                  P>                  P+                  RRR7      pVP3                  RRR7      pV Uu. uF  p\A        VP4                  R,          VP4                  R,          VP4                  PB                  '       d   VP4                  PB                  R,          MRVP+                  R4      PD                  VP+                  R4      R,          \F        PH                  R7      NK  	  upV n%        V'       d   \M        V4      V n$        M^RV n$        \        P                  ! RV P:                  P<                  V P                  \        P                  \        P                  8  R7        VP+                  RRR/R7      P3                  R4      pV Uu. uFW  pVPD                  f   K  \O        VPD                  \Q        VR,          4      VR,          PS                  R 4      R6,          4      NKY  	  upV n*         VP+                  R"R#R$7      P3                  R%4      ^R7 pV Uu. uFq  pVP4                  '       g   K  \A        VP4                  R,          VP4                  R,          VP4                  PB                  R,          \F        PV                  R&7      NKs  	  upV n,         \[        VP+                  RR(R7      P+                  R)R*R+7      R,,          4      V n.         VP+                  RR/R7      P+                  RRR0/4      R,          V n/        V Pa                  ^VR17      V n1         VP+                  R)R2R+7      R,,          V n2        \1        VP+                  RR4R$7      4      V n3         \1        VP+                  RR4R$7      4      V n3        VP+                  RR4R$7      Ph                  V n5        R#   \         dN    \        P                  ! R T P                  \        P                  \        P                  8  R7       RT n         ELi ; i  \.         d5    \1        TP3                  R4      ^,          P4                  4      T n         ELi ; i  \         dc    \        P                  ! R	T P:                  P<                  T P                  \        P                  \        P                  8  R7       . T n         ELi ; iu upi   \         dc    \        P                  ! RT P:                  P<                  T P                  \        P                  \        P                  8  R7       . T n%         EL7i ; iu upi   \         dc    . T n*        \        P                  ! R!T P:                  P<                  T P                  \        P                  \        P                  8  R7        ELi ; iu upi   \        \.        3 dc    \        P                  ! R'T P:                  P<                  T P                  \        P                  \        P                  8  R7       . T n,         ELyi ; i  \         dc    R-T n.        \        P                  ! R.T P:                  P<                  T P                  \        P                  \        P                  8  R7        ELi ; i  \         d    RT n/         ELi ; i  \.         dc    RT n2        \        P                  ! R3T P:                  P<                  T P                  \        P                  \        P                  8  R7        ELi ; i  \         dj    \        P                  ! R5T P:                  P<                  T P                  \        P                  \        P                  8  R7       RT n3        RT n5         R# i ; i)8-Entity '%s' has no stats (idk why, ask moddb)r1   Nr+   rd   ztext textembed)ra   r)   r-   Ztextareaz'%s' '%s' has no filesspanZArticlesr/   Related Articlesdivtabler(   row rowcontent cleartitler*   srcptimedatetimer#   r<   rb   summaryZdatera   $'%s' '%s' has no article suggestions#'%s' '%s' has no front page articleformr#   tagsformr,   r$   r.   z'%s' '%s' has no tagsZulimageboxr9   Zlir#   r<   rb   ra   z'%s' '%s' has no imagesscorer&   ratingValuer%   r'           '%s' '%s' is not rated
ratingformhashr   descriptionz'%s' '%s' has no summaryprofiledescriptionz%'%s' '%s' has no extended descriptionr3   r2   )6superrI   _typer   Zmembersr   profiler   statsr5   r   r?   r#   rB   rC   rD   enginesr	   style_get_suggestionssuggestionsr4   embedr:   rY   rc   r$   
_get_filesfilesr@   rA   parentr
   imgr0   r   articlearticlesr   r   r   r;   tagsre   r   floatrating_review_hashrf   mediasr   r   rd   	plaintext)
rH   r   rq   articles_rawZraw
thumbnailsxraw_tagsr   r@   s
   &&&      r   rI   ZPageMetaClass.__init__   s   
 ..."4=DL"'-
 N222"4[
  $44T:DA!YYwVDTYUV]^
		.DJ 	))F:)6  $))1 ;D ;C ::,,3388w8OL%..u=S.TJ $
 $A WF,-CCGGG!##''%.FF3K..
3&.. $
DM* ),7DLDLKK5''		6		yy
/CyDMMcRH "!A88 P
188T!F)_aiooc6J26NO!DI	yy*y5>>tDQrJH "	 "A33	WF##''%.&,,	 "	DM&			%	055f}5UV_`DK	% $		&	 F K K&&)!!D ooado3		99Vm9DYODL tyy3GyHI	""499U7K9#LMD!YYu1EYFKKDNc " "CII#\\W]]:
 "
""  A z!:1!=!?!?@
A
  	KK(''		6	 DJ	 
  	KK6''		6	 DM	.
  	DIKK'''		6	 		 	* 	KK)''		6	 DM	  	DKKK(''		6	 	  	% $D	%  	DLKK*''		6	 	  	"KK7''		6	  $D!DN	"s  R, 	 T *U	 V> AV> 9B2V9+V> +(X3 X.(AX.0X3 9)Z( "Z#;AZ#Z( "9\ 1^ &^' 'A` ,ATT;UU	A)V65V69V> >A)X+*X+.X3 3A)Z Z #Z( (A/\\A)^
^^$#^$'A)``A0b
bc                r]   rR   r   r    r
   r   r   r   r    rr     s     " "] "tI "r"   c                s   VP                  RRR7      P                  P                  P                  P                  RRR7      P                  RRR7      p. pV Fh  p VP                  R	R
R7      p\        VR,          4      p\	        VR,          VR,          VP
                  R,          VR7      pVP                  V4       Kj  	  V#   \        \        3 d     K  i ; i)ai  Hidden method used to get the list of suggestions on the page. As with most things, this list of suggestions
will be a list of Thumbnail objects that can be parsed individually.

Parameters
-----------
html : BeautifulSoup
    The html page we are trying to parse the suggestions for

Returns
--------
List[Thumbnail]
    The list of suggestions as thumbnails.
rt   You may also liker/   rv   rw   r(   F)Z	recursiver$   rb   r*   ry   rz   r   )	r4   r   rc   r   r
   r   appendr5   r:   )rH   r   Zsuggestions_rawr   r   linkZsuggestion_typeZ
suggestion   &&      r   r   ZPageMetaClass._get_suggestions  s     IIf%8I9VFF66$$uW$"=XeuX- 	
  Avvc'v2"/V"=&gV((5/(	
 "":. !  #I. s   A$CCCc                r]   rR   r   r   r   r   r    rr     s      } i r"   c                   VP                  RR7      P                  P                  P                  P                  P                  RR7      p. pV F  pVP                  RRR7      P                  P                  pVP                  P                  P                  P                  R4      R,          p\        VP                  VR	,          V\        P                  R
7      pVP                  V4       K  	  V# )a  Used both for Teams and Engines, returns a list of games  present on the page
as Thumbnail objects.

Parameters
----------
html : BeautifulSoup
    The html to extract the list of games from

Returns
-------
List[Thumbnail]
    The list of games on the page as Thumbnail objects.
ZGamesr/   rx   r(   rv   r'   r   rz   r*   r   )
r4   r   rc   h4r$   r
   r0   r   gamer   )rH   r   Z	games_rawZgamesr   r   	image_urlr   r   r   
_get_gamesZPageMetaClass._get_games  s     IIWI-44;;BBIIRR) S 
	 A66%	625577D**1166u=eDI[[L"''	D LL  r"   c                r]   rR   r   r   r   r   r    rr     s     ! !} !i !r"   c                s   VP                  RR7      P                  P                  P                  P                  P                  RR7      p. pV F  pVP                  RRR7      P                  P                  p VP                  P                  P                  P                  R4      R,          p\        VP                  VR
,          V\        P                  R7      pVP                  V4       K  	  V#   \
         d    R	p LTi ; i)zCache the files present on the page. Up to 5 files might be present

Parameters
-----------
html : BeautifulSoup
    The page to cache the files from

Returns
-------
List[Thumbnail]
    The list of file like thumbnails
ZFilesr/   rx   r(   rv   r'   r   rz   Nr*   r   )r4   r   rc   r   r$   r:   r
   r0   r   filer   )rH   r   Z	files_rawr   r   r   r   r   r   r   r   ZPageMetaClass._get_files  s     IIWI-44;;BBIIRR) S 
	 A66%	625577D! KK..55::5A%H	 [[L"''	D LL    ! 	!s   :6C55DDc                r   r   r   r   r   r   r    rr     s       r"   c                r   )a4  Hidden method to get the engines showed currently on the page as a list of engine like thumbnails. Takes
an entire page of html and sorts it out

Parameters
-----------
html : BeautifulSoup
    The page to cache the engines from

Returns
-------
List[Thumbnail]
    The list of engine like thumbnail objects
ZEnginesr/   rx   r(   rv   r'   r   rz   r*   r   )
r4   r   rc   r   r$   r
   r0   r   enginer   )rH   r   Zengines_rawr   r   r   r   r   r   r   _get_enginesZPageMetaClass._get_engines  s     iiyi188??FFMMVV) W 
 A66%	625577D**1166u=eDI[[L"))	F NN6"  r"   c                rJ   rK   rL   rM   rN   r   rO   ZPageMetaClass.__repr__'  rP   r"   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )rA   rj   rk   rl   rm   rI   r   r   r   r   rO   rn   ro   __classcell__r@   r      @@r   rp   rp      sL     3jd" d"L" "H >! !F >? ?r"   rp   c                   sB   a a ] tR tRt oRtV3R lV 3R lltRtVtV ;t# )HardwareSoftwareMetaClassi+  a  Shared class for Hardware and Software

Attributes
-----------
description : str
    Description of the page
profile : Profile
    The page's profile
stats : Statistics
    The page's stats
rating : float
    The rating of the item
articles : List[Thumbnail]
    List of article type thumbnails from the recommended articles
article : PartialArticle
    The partial article presented on the front page
tags : List[PartialTag]
     A list of partial tags. You can use `get_tags` and then use the name id to get the right one.
medias : List[Thumbnail]
    list of thumbnails representing all the combined media objects of a page (videos and images)
suggestions : List[Thumbnail]
    list of suggested software/hardware type thumbnails
c                r   r   r   r   r   r   r    Z&HardwareSoftwareMetaClass.__annotate__F  s     i i] ir"   c                s  < \         SV `  V4        VP                  R RR7      P                  P                  V n        \        V4      V n         \        V4      V n
         \#        VP                  R R	R
7      P                  RRR7      R,          4      V n         VP                  RRR
7      P                  RRR/4      R,          V n        Rp VP                  RRR7      P*                  P*                  P*                  P                  R RR
7      pVP-                  R RR
7      pV Uu. uF  p\/        VP0                  R,          VP0                  R,          VP0                  P2                  '       d   VP0                  P2                  R,          MRVP                  R4      P                  VP                  R4      R,          \4        P6                  R 7      NK  	  upV n        V'       d   \;        V4      V n        MGRV n        \        P                  ! R"V P                  P&                  P                  V P                  4        VP                  RRR#/R$7      P-                  R%4      pV Uu. uFW  pVP                  f   K  \=        VP                  \?        VR,          4      VR,          PA                  R&4      R-,          4      NKY  	  upV n!        V PE                  ^VR(7      V n#         \4        V PH                  PJ                  PM                  4       ,          pVP                  RR)R7      P*                  P*                  P*                  P-                  R%R*R
7      pV Uu. uF0  p\/        VR,          VR,          WdP2                  R,          R+7      NK2  	  upV n'        R#   \         d'    TP                  RRR7      P                  T n         ELi ; i  \         dN    \        P                  ! RT P                  \        P                  \        P                   8  R7       RT n
         ELi ; i  \         dm    RT n        \        P                  ! RT P                  P&                  P                  T P                  \        P                  \        P                   8  R7        EL	i ; i  \         d    RT n         ELi ; iu upi   \         dm    \        P                  ! R!T P                  P&                  P                  T P                  \        P                  \        P                   8  R7       . T n         ELYi ; iu upi   \         dN    . T n!        \        P                  ! R'T P                  \        P                  \        P                   8  R7        ELi ; iu upi   \         d\    \        P                  ! R,T PH                  PJ                  T P                  \        P                  \        P                   8  R7        R# i ; i).rv   r   r   r{   r   r%   rs   r1   Nr   r(   r&   r   r'   r   r   r   r   r+   r#   r   r-   rt   ru   r/   rw   rx   ry   r*   rz   r|   r}   r~   r   r   r   r,   r$   r.   zHardware '%s' has no tagsr   r   rb   )r<   r#   ra   rb   z'%s' '%s' has no suggestionsr3   )(r   rI   r4   r{   r0   r   r5   r   r   r   r   r   r?   r#   rB   rC   rD   r   r   Zcategoryr   r   rc   r
   r$   r   r   r   r   r   r   r   r;   r   rf   r   r@   rA   Zlowerr   )	rH   r   r   r   r   r   rh   r   r@   s	   &&      r   rI   Z"HardwareSoftwareMetaClass.__init__F  s   	M#yy3GyHJJQQD t}	#D)DJ			%	055f}5UV_`DK	% $		&	 F K K&&)!!D 	99V4F9GNNUU\\aag b L &..u=S.TJ $
 $A WF,-CCGGG!##''%.FF3K..
3&.. $
DM( ),7DLDLKK5%%**			yy
/CyDMMcRH "!A88 P
188T!F)_aiooc6J26NO!DI ooado3	dnn55;;=>A))2 $ fVVFF88C8#@ 
 % $A aiajqeU$ Dw  	M#yy}yELLD	M  	KK?		6
 DJ	  	DKKK(%%**		6	 	  	% $D	%
  	KK6%%**		6	 DM	*
  	DIKK+TYYQXQ^Q^A^ 	   	KK.''		6	 	s   ,N O  9P, 1R& AS 'B2R?S (U *T>?AT>U (A5V# 6VV# -OOAP)(P),A3R#"R#&R<;R<?S A3T;:T;>U AVVV# #A"X	X	)
r   r   r   r   r   r   r   r   r   r   )	rA   rj   rk   rl   rm   rI   rn   ro   r   r   r   r   r   r   +  s     0i i ir"   r   )!rC   r7   Ztypingr    Zbs4r   Zboxesr   r   r   r   r   r   r	   r
   r   r   Zenumsr   r   Zutilsr   r   r   r   Zmixinsr   r   r   r   r   rp   r   ) r"   r   <module>r      ss     	     2 9 9 T TiW iWXd?%|5E|d?ND%|5E|Dr"   