
    i                         S r SSKJrJr  SSKJrJr  Sr " S S\5      r " S S	\5      r	 " S
 S\5      r
 " S S\5      r " S S\5      r " S S\5      rg)z$Extractors for https://unsplash.com/   )	ExtractorMessage   )textutilz(?:https?://)?unsplash\.comc                   V    \ rS rSrSrS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)UnsplashExtractor   z"Base class for unsplash extractorsunsplash)z
{category}z{user[username]}z{id}.{extension}z{id}zhttps://unsplash.comr      c                 D    [         R                  " X5        US   U l        g )Nr   )r   __init__itemselfmatchs     J/app/mltbenv/lib/python3.13/site-packages/gallery_dl/extractor/unsplash.pyr   UnsplashExtractor.__init__   s    4'!H	    c              #     #    U R                  S5      =(       d    SnU R                  5       nU R                  5        H  n[        R                  " US5        US   U   n[
        R                  " XC5        U(       a  UR                  U5        SUS'   U R                  US   5      US'   S	U;   a  US	    Vs/ s H  oUS
   PM	     snUS	'   [        R                  SU4v   [        R                  XC4v   M     g s  snf 7f)Nformatraw)current_user_collectionsrelated_collectionsurlsjpg	extension
created_atdatetagstitle )configmetadataphotosr   delete_itemsr   nameext_from_urlupdateparse_datetime_isor   	DirectoryUrl)r   fmtr$   photourlts         r   itemsUnsplashExtractor.items   s     kk(#,u==?[[]EJL-$C!!#-X&!&E+ 33E,4GHE&M5:6] C]7] Cf##R..++s)) # !Ds   B4C=6C89C=c                     g N r   s    r   r$   UnsplashExtractor.metadata3   s    r   c                 d    XR                   -  nU =R                  U-  sl        X R                   -  $ r3   )per_page
page_start)r   numpagess      r   skipUnsplashExtractor.skip6   s)    }}$5 }}$$r   c              #      #    U R                   US'   U R                  US'    U R                  XS9nU(       a  US   nU S h  vN   [        U5      U R                   :  a  g US==   S-  ss'   MN   N-7f)Nr8   page)paramsresultsr   )r8   r9   request_jsonlen)r   r.   r@   rA   r%   s        r   _paginationUnsplashExtractor._pagination;   sw     !]]zv&&s&:F	*6{T]]*6NaN  s   A A2A0.A2)r   N)F)__name__
__module____qualname____firstlineno____doc__categorydirectory_fmtfilename_fmtarchive_fmtrootr9   r8   r   r0   r$   r<   rD   __static_attributes__r4   r   r   r	   r	      sA    ,H6M%LK!DJH*(%
 r   r	   c                   0    \ rS rSrSrSr\S-   rSrS r	Sr
g)	UnsplashImageExtractorJ   z%Extractor for a single unsplash photoimagez/photos/([^/?#]+)zhttps://unsplash.com/photos/IDc                 \    U R                    SU R                   3nU R                  U5      4$ )Nz/napi/photos/)rO   r   rB   )r   r.   s     r   r%   UnsplashImageExtractor.photosP   s.    =4!!#&((r   r4   NrF   rG   rH   rI   rJ   subcategoryBASE_PATTERNpatternexampler%   rP   r4   r   r   rR   rR   J   s    /K11G.G)r   rR   c                   0    \ rS rSrSrSr\S-   rSrS r	Sr
g)	UnsplashUserExtractorU   z,Extractor for all photos of an unsplash useruserz
/@(\w+)/?$zhttps://unsplash.com/@USERc                 d    U R                    SU R                   S3nSS0nU R                  X5      $ )N/napi/users//photosorder_bylatestrO   r   rD   r   r.   r@   s      r   r%   UnsplashUserExtractor.photos[   s7    <		{':h',,r   r4   NrW   r4   r   r   r]   r]   U   s    6K]*G*G-r   r]   c                   0    \ rS rSrSrSr\S-   rSrS r	Sr
g)	UnsplashFavoriteExtractora   z+Extractor for all likes of an unsplash userfavoritez/@(\w+)/likesz https://unsplash.com/@USER/likesc                 d    U R                    SU R                   S3nSS0nU R                  X5      $ )Nra   z/likesrc   rd   re   rf   s      r   r%    UnsplashFavoriteExtractor.photosg   s7    <		{&9h',,r   r4   NrW   r4   r   r   ri   ri   a   s    5K--G0G-r   ri   c                   <    \ rS rSrSrSr\S-   rSrS r	S r
S rS	rg
)UnsplashCollectionExtractorm   z$Extractor for an unsplash collection
collectionz%/collections/([^/?#]+)(?:/([^/?#]+))?z,https://unsplash.com/collections/12345/TITLEc                 T    [         R                  X5        US   =(       d    SU l        g )Nr   r"   )r	   r   r!   r   s     r   r   $UnsplashCollectionExtractor.__init__s   s    ""4/1X^
r   c                 4    U R                   U R                  S.$ )N)collection_idcollection_title)r   r!   r5   s    r   r$   $UnsplashCollectionExtractor.metadataw   s    !%

KKr   c                 d    U R                    SU R                   S3nSS0nU R                  X5      $ )Nz/napi/collections/rb   rc   rd   re   rf   s      r   r%   "UnsplashCollectionExtractor.photosz   s8    -dii[@h',,r   )r!   N)rF   rG   rH   rI   rJ   rX   rY   rZ   r[   r   r$   r%   rP   r4   r   r   ro   ro   m   s*    .KEEG<G$L-r   ro   c                   6    \ rS rSrSrSr\S-   rSrS r	S r
Srg	)
UnsplashSearchExtractor   z%Extractor for unsplash search resultssearchz!/s/photos/([^/?#]+)(?:\?([^#]+))?z#https://unsplash.com/s/photos/QUERYc                 B    [         R                  X5        US   U l        g )Nr   )r	   r   queryr   s     r   r    UnsplashSearchExtractor.__init__   s    ""4/1X
r   c                 (   U R                   S-   nS[        R                  " U R                  R	                  SS5      5      0nU R
                  (       a/  UR                  [        R                  " U R
                  5      5        U R                  XS5      $ )Nz/napi/search/photosr   - T)	rO   r   unquoter   replacer   r(   parse_queryrD   rf   s      r   r%   UnsplashSearchExtractor.photos   sj    ii//4<<		(9(9#s(CDE::MM$**4::67T22r   )r   N)rF   rG   rH   rI   rJ   rX   rY   rZ   r[   r   r%   rP   r4   r   r   r{   r{      s$    /KAAG3G3r   r{   N)rJ   commonr   r   r"   r   r   rY   r	   rR   r]   ri   ro   r{   r4   r   r   <module>r      sc    + & -6 	 6 r). )	-- 	-	- 1 	--"3 -&3/ 3r   