
    iC                         S r SSKJrJr  SSKJrJr   " S S\5      r " S S\5      r " S	 S
\5      r	 " S S\5      r
S rg)z Extractors for https://booth.pm/   )	ExtractorMessage   )textutilc                   @    \ rS rSrSrSrSrSrSrSr	Sr
S	 rSS
 jrSrg)BoothExtractor   zBase class for booth extractorsboothzhttps://booth.pm)z
{category}z{shop[name]}z{id} {name}z {num:>02} {filename}.{extension}z{id}_{filename})g      ?g      ?c                 :    U R                   R                  SSSS9  g )Nadulttz	.booth.pm)domain)cookiesset)selfs    G/app/mltbenv/lib/python3.13/site-packages/gallery_dl/extractor/booth.py_initBoothExtractor._init   s    #k:    c              #     #     U R                  U5      R                  nU(       aL  [        R                  " USS5       H/  n[        R                  " [        R
                  " U5      5      v   M1     OM[        R                  " USS5       H1  n[        R
                  " [        R                  " USS5      5      v   M3     [        R                  " USS5      nU(       d  g U R                  [        R
                  " U5      -   nGM  7f)Nz data-item=""zitem-card__titlez</div>zhref="z"rel="next" class="nav-item" href=")requestr   extract_iterr   
json_loadsunescapeextrroot)r   urljsonpageitemnexts         r   _paginationBoothExtractor._pagination   s     <<$))D --dNCHD//$--*=>> I !--0(<D--		$#(FGG< 99T#GMD))dmmD11C s   DD N)F)__name__
__module____qualname____firstlineno____doc__categoryr   directory_fmtfilename_fmtarchive_fmtrequest_intervalr   r$   __static_attributes__r&   r   r   r	   r	      s.    )HDAM5L#K!;2r   r	   c                   ,    \ rS rSrSrSrSrS rS rSr	g)	BoothItemExtractor-   r"   zK(?:https?://)?(?:[\w-]+\.)?booth\.pm/(?:[a-z]{2}(?:-[^/?#]+)?/)?items/(\d+)zhttps://booth.pm/ja/items/12345c              #     #    U R                    SU R                  S    3nSSS SSSSS.nU R                  S	5      S
:X  a  S nU R                  US-   US9nOJU R	                  U5      R
                  n[
        R                  " USS5      US'   U R                  US-   USS9nUR                  SS 5      US'   U R                  US   5      US'   US    Vs/ s H  oUS   PM	     snUS'   US   n[
        R                  " US   R                  SS5      S   5      US'   U R                  XC5      =n(       a-  [        U5      US'   US   S   R                  SS 5      S   US!'   OSUS'   [        R                  US!'   [         R"                  S"U4v   [%        US5       H=  u  pU	S   nXS#'   [
        R&                  " X5        [         R(                  U0 UEU	E4v   M?     g s  snf 7f)$Nz
/ja/items/    zapplication/jsonemptycorszsame-originzu=4)AcceptzContent-TypeX-CSRF-TokenzSec-Fetch-DestzSec-Fetch-ModezSec-Fetch-SitePrioritystrategyfallbackz.json)headerszname="csrf-token" content="r   r:   F)r>   intervalr,   booth_categorypublished_atdatetagsnameshopthumbnail_url/   r   idcountr      uuid num)r   groupsconfigrequest_jsonr   r   r   popparse_datetime_iso	parse_intrsplit_extract_fileslensplitr   NONEr   	Directory	enumeratenameext_from_urlUrl)
r   r   r>   r!   r"   r   rE   filesrN   files
             r   itemsBoothItemExtractor.items3   s    :dkk!n%56(. %$+
 ;;z"j0D$$S7]G$DD<<$))D&*ii3S':GN#$$gw % @D "&*d!;..tN/CDV+/<8<a&	<8VF|^^D$9$@$@a$H$KLT
''3353JDM 8E?00a8;DLDM99DLT))"5!,ICu+CK!!#,++s$4t$4t$444	 - 9s   CG G!C?G c                 
   UcN  / nUR                  S5       H5  nUS   R                  SS5      nUR                  U[        U5      S.5        M7     U$ US	 [        R
                  " USS5       Vs/ s H  nSU0PM	     sn$ s  snf )	Nimagesoriginal_base_resizedrM   )r   	_fallbackzdata-origin="r   r   )rR   replaceappendrf   r   r   )r   r"   r!   r^   imager   s         r   rV   !BoothItemExtractor._extract_files^   s    <E(+J'//D!$!*3  , LN,,T?CHJHC HJ 	J Js   /B r&   N)
r'   r(   r)   r*   subcategorypatternexampler`   rV   r1   r&   r   r   r3   r3   -   s    K9G/G)5VJr   r3   c                   ,    \ rS rSrSrSrSrS rS rSr	g)	BoothShopExtractorn   rE   z"(?:https?://)?([\w-]+\.)booth\.pm/zhttps://SHOP.booth.pm/c                 j    [         R                  " US   5      U l        [        R	                  X5        g )Nr6   )r   root_from_urlr   r	   __init__)r   matchs     r   rs   BoothShopExtractor.__init__s   s&    &&uQx0	,r   c              #      #    U R                  U R                  S-   SS9 H$  n[        US'   [        R                  US   U4v   M&     g 7f)Nz/itemsT)r    
_extractorshop_item_url)r$   r   r3   r   Queue)r   r"   s     r   r`   BoothShopExtractor.itemsw   sI     $$TYY%9$ED!3D--o!6<< Fs   AA	)r   N)
r'   r(   r)   r*   rk   rl   rm   rs   r`   r1   r&   r   r   ro   ro   n   s    K3G&G-=r   ro   c                   &    \ rS rSrSrSrSrS rSrg)BoothCategoryExtractor}   r,   z9(?:https?://)?booth\.pm(/[a-z]{2}(?:-[^/?#]+)?/browse/.+)z#https://booth.pm/ja/browse/CATEGORYc              #      #    S[         0nU R                  U R                  U R                  S   -   5       H  n[        R
                  X!4v   M     g 7f)Nrw   r6   )r3   r$   r   rO   r   ry   )r   datar   s      r   r`   BoothCategoryExtractor.items   sF     01##DIIA$>?C--** @s   AAr&   N)	r'   r(   r)   r*   rk   rl   rm   r`   r1   r&   r   r   r|   r|   }   s    KJG3G+r   r|   c              #   @   #    U S S nUS-   v   US-   v   US-   v   g 7f)Njpegpngwebpr&   )r   bases     r   rf   rf      s.     s8D
-
,
-s   N)r+   commonr   r   rM   r   r   r	   r3   ro   r|   rf   r&   r   r   <module>r      sH    ' & 2Y 2<>J >JB= =+^ +r   