+
    KiO<  c                   sH   R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHtHt ^ RIHtHt ^ RIHt ^ R	IHtHt ^ R
IHt ^ RIHt ^ RIHt ^ RIHtH t  ^ RI!H"t"  ! R R]4      t# ! R R]#4      t$ ! R R]#4      t% ! R R]4      t& ! R R]4      t'R t(R t)R# )zManage Humble Bundle librariesN)gettext)Gtk)settings)UnavailableGameError)HumbleBundleCookiesDialogQuestionDialog)AUTO_ELF_EXEAUTO_WIN32_EXE)InstallerFile)SERVICE_LOGINOnlineService)ServiceGame)ServiceMedia)linux)	HTTPErrorRequest)loggerc                   sx    ] tR t^tRtRtRt]P                  P                  ]
P                  R4      tR.tRtRtR# )	HumbleBundleIconzHumbleBundle iconhumblebundlezhumblebundle/iconsz%s.pngicon N)F   r   )__name__
__module____qualname____firstlineno____doc__servicesizeospathjoinr   	CACHE_DIRZ	dest_pathZfile_patternsZ	api_field__static_attributes__r       A/usr/lib/python3.14/site-packages/lutris/services/humblebundle.pyr   r      s6    GDX//1EFIJMIr"   r   c                   s.   a  ] tR t^!t o RtRtR tRtV tR# )HumbleSmallIconFc                s    R # Nr   )selfZservices   &&r#   get_fallback_media_pathZ'HumbleSmallIcon.get_fallback_media_path%   s    r"   r   N)#   r)   )	r   r   r   r   r   Zcan_be_fallbackr(   r!   __classdictcell____classdict__   @r#   r$   r$   !   s     DO r"   r$   c                   s    ] tR t^)tRtRtR# )HumbleBigIconr   N)i   r/   )r   r   r   r   r   r!   r   r"   r#   r.   r.   )   s    Dr"   r.   c                   s8   a  ] tR t^-t o RtRt]R 4       tRtV t	R# )HumbleBundleGamez-Service game for DRM free Humble Bundle gamesr   c                s    \        4       pVR,          Vn        VR,          Vn        VR,          Vn        \        P
                  ! V4      Vn        V# )z?Converts a game from the API to a service game usable by Lutrismachine_name
human_name)r0   appidslugnamejsonZdumpsdetails)ZclsZhumble_gameZservice_game   && r#   new_from_humble_gameZ%HumbleBundleGame.new_from_humble_game2   sJ     ()(8'7'5#zz+6r"   r   N)
r   r   r   r   r   r   Zclassmethodr9   r!   r*   r+   r-   r#   r0   r0   -   s     7G r"   r0   c                   s  a a ] tR t^=t oRtRtRt]! R4      tRt	Rt
RtR]R]R]/tRtR	tR
tR.t]P*                  P-                  ]P0                  R4      t]P*                  P-                  ]P0                  R4      t]P*                  P-                  ]P0                  R4      tR!tR"V 3R lltR tR tR t R t!R t"R t#R t$R t%R t&]'R 4       t(R t)R t*]'R 4       t+]'R 4       t,R t-R t.R t/Vt0V ;t1# )#HumbleBundleServicezService for Humble Bundler   ZhumbleHumble BundleTZ
small_iconr   Zbig_iconzhttps://www.humblebundle.com/z5https://www.humblebundle.com/login?goto=/home/libraryz)https://www.humblebundle.com/home/libraryz.humblebundle.authz.humblebundle.tokenzhumblebundle/library/c                s  < \        R \        R4      R\        R4      RV/4      pVP                  \        P                  P
                  8X  d   \        4       pVP                  '       d]   \        V P                  RRR7      ;_uu_ 4       pVP                  VP                  4       RRR4       \        P                  ! V 4       R# V P                  4        R# \        SV `=  VR	7      #   + '       g   i     LJ; i)
Ztitlez+Workaround for Humble Bundle authenticationZquestionzHumble Bundle is restricting API calls from software like Lutris and GameHub.
Authentication to the service will likely fail.
There is a workaround involving copying cookies from Firefox, do you want to do this instead?parentwutf-8ZencodingN)r<   )r   _resultr   ZResponseTypeZYESr   Zcookies_contentopencookies_pathZwriter	   fireZlogoutZsuperlogin)r&   r<   ZdialogZcookies_file	__class__s   &&  r#   rE   ZHumbleBundleService.loginS   s    HIAD &	
 ==C,,000.0F%%%$++S7CC| &&v'='=> D""4(7==// DCs   
C((C8	c                s2    \         P                  ! V 4       R# )z0Called after the user has logged in successfullyN)r	   rD   )r&   urlr'   r#   login_callbackZ"HumbleBundleService.login_callbackk   s    4 r"   c                s"    V P                  4       # )zVThis doesn't actually check if the authentication
is valid like the GOG service does.
)Zis_authenticated)r&   s   &r#   is_connectedZ HumbleBundleService.is_connectedo   s     $$&&r"   c                sZ    V P                  4       p. p\        4       pT FO  pTR,          T9   d   K  TP	                  \
        P                  T4      4       TP                  TR,          4       KQ  	  T F  pTP                  4        K  	  T#   \         d   p\        R4      ThRp?ii ; i)z%Load the user's Humble Bundle libraryzAFailed to get Humble Bundle library. Try logging out and back-in.Nr2   )	get_libraryZ
ValueErrorZRuntimeErrorZsetappendr0   r9   ZaddZsave)r&   ZlibraryexZhumble_gamesZseengames   &     r#   loadZHumbleBundleService.loadu   s    	l&&(G uDL!T) 0 E Ed KLHHT,'(	 
 !DIIK !  	lbcikk	ls   B B*B%%B*c                s    \        WP                  4       R7      p VP                  4        VP                  #   \         d    \        P
                  ! RT4        R# i ; i)z/Make an authenticated request to the Humble API)ZcookieszFailed to request %sN)r   Zload_cookiesZgetr   r   errorr6   )r&   rG   Zrequestr8   r#   make_api_requestZ$HumbleBundleService.make_api_request   sR    #'8'8':;	KKM ||  	LL/5	s   8 "AAc                sd    \         P                  P                  V P                  RV,          4      # )z"Return the local path for an orderz%s.json)r   r   r   
cache_path)r&   gamekeyr'   r#   
order_pathZHumbleBundleService.order_path   s     ww||DOOY-@AAr"   c                s,   V P                  V4      p\        P                  P                  V4      '       d7   \	        VRR7      ;_uu_ 4       p\
        P                  ! V4      uuRRR4       # V P                  V P                  RV,          ,           4      p\        P                  ! V P                  RR7       \	        VRRR7      ;_uu_ 4       p\
        P                  ! WC4       RRR4       V#   + '       g   i     L; i  + '       g   i     T# ; i)z'Retrieve an order identitied by its keyr>   r?   Nzapi/v1/order/%s?all_tpkds=trueT)Zexist_okr=   )rS   r   r   existsrB   r6   rN   rP   api_urlZmakedirsrQ   Zdump)r&   rR   Zcache_filenameZ
cache_fileZresponse   &&   r#   	get_orderZHumbleBundleService.get_order   s     177>>.))nw77:yy, 87((8X[b8b)bc
DOOd3.#88JIIh+ 9 87 98s   C/D/C?	D	c                s    . pV P                  4        FX  pV'       g   K  VR,           F>  pVR,           F.  pVR,          V P                  9   g   K  VP                  V4       K0  	  K@  	  KZ  	  V# )z(Return the games from the user's librarysubproducts	downloadsplatform)
get_orderssupported_platformsrK   )r&   Zgamesorderproductdownloads   &    r#   rJ   ZHumbleBundleService.get_library   sh    __&E // ' 4 4H
+t/G/GGW- !5 0 ' r"   c                s   . p\         P                  P                  V P                  4      '       dW   \         P                  ! V P                  4       F2  pVP                  R4      '       g   K  VP                  RVRR /4       K4  	  V# )z)Retrieve a list of orders from the cache.z.jsonrR   Ni)r   r   rT   rQ   ZlistdirendswithrK   )r&   Z	game_keysZ
order_file   &  r#   get_gamekeys_from_local_ordersZ2HumbleBundleService.get_gamekeys_from_local_orders   sj    	77>>$//** jj9
!**733  )Z_!=> : r"   c           
     s   V P                  4       p. pV'       g#   V P                  V P                  R,           4      p\        P                  P                  ^R7      ;_uu_ 4       pV Uu. uF%  qCP                  V P                  VR,          4      NK'  	  ppV F"  pVP                  VP                  4       4       K$  	  RRR4       \        P                  ! R\        V4      4       V# u upi   + '       g   i     L7; i)zReturn all orderszapi/v1/user/order)Zmax_workersrR   NzLoaded %s Humble Bundle orders)rb   rP   rU   
concurrentZfuturesZThreadPoolExecutorZsubmitrW   rK   rA   r   infolen)r&   ZgamekeysZordersZexecutorrR   Zfuture_ordersr]   s   &      r#   r[   ZHumbleBundleService.get_orders   s    668,,T\\<O-OPH22q2AAX`hi`hU\__T^^WY=OP`hMi&elln- ' B 	4c&kB	 j BAs   %C.*+C)*C.)C..C>	c           
     s   V R,           F  pVR,          V8w  d   K  VR,           Uu. uF  qDR,          NK  	  ppW%9  d5   \         P                  ! RW%4       RV9   d   RpMRV9   d   RpM	V^ ,          pVR,           F4  pVR,          V8w  d   K  RV R,          R	V R	,          R
V R
,          RV/u u # 	  K  	  R# u upi )z;Return the download information in an order for a give gamerX   r1   rY   rZ   z>Requested platform %s not available in available platforms: %sr   windowsr^   rR   Zcreatedr_   N)r   warning)r]   humbleidrZ   r^   dZavailable_platformsr_   s   &&&    r#   find_download_in_orderZ*HumbleBundleService.find_download_in_order   s     ]++G~&(2:A+:N"O:NQZ==:N"O2TV^ 11&H"55(H215H#K00J'83uY/uY/uY/	  1 , #Ps   B<c                s    . pV P                  4        F0  pV P                  WAV4      pV'       g   K  VP                  V4       K2  	  V# )z0Return the download information for a given game)r[   rj   rK   )r&   rh   rZ   Zdownload_linksr]   r_   s   &&&   r#   get_downloadsZ!HumbleBundleService.get_downloads   sE    __&E225HMHx%%h/ ' r"   c                s    \        VP                  VP                  4      pT'       g   \        \        R4      4      hTP                  R4      ^ ,          P                  R4      R	,          p\        TP                  TRTRT/4      pT.. 3#   \         d2   p\        P
                  ! RT4       \        \        R4      4      ThRp?ii ; i)
zEReplace the user provided file with download links from Humble Bundlez$Failed to get Humble Bundle game: %sz6The download URL for the game could not be determined.NzNo game found on Humble Bundle?/rG   filename)get_humble_download_linkZservice_appidrunnerZ	Exceptionr   Z	exceptionr   r@   splitr   	game_slug)r&   	installerZinstaller_file_idZ_selected_extrasZlinkrL   rn   files   &&&&    r#   get_installer_filesZ'HumbleBundleService.get_installer_files   s    	l+I,C,CYEUEUVD &q)I'JKK::c?1%++C04Y002CeTS]_gEhivrz  	lCRH&q)a'bcikk	ls    B C,CCc                s    V  Uu. uF  q"R ,          V8X  g   K  VNK  	  up^ ,          p\        V4      pV'       g   R# VP                  R4      ^ ,          P                  R4      R,          # u upi )rZ   Nrl   rm   ro   )$pick_download_url_from_download_inforr   )rY   rZ   ri   r_   rG   rV   r#   get_filename_for_platformZ-HumbleBundleService.get_filename_for_platform   s_    (Fy!jMX,EAAyFqI28<yy~a &&s+B//	 Gs
   A,A,c                sl    V  F-  pVR ,          V8w  d   K  \        VR,          4      ^ 8  g   K,   R# 	  R# )rZ   download_structTN)re   )rY   rZ   r_   r8   r#   platform_has_downloadsZ*HumbleBundleService.platform_has_downloads   s2    !H
#x/8-./!3	 "r"   c                s~   \         P                  ! VR ,          4      pVR,           Uu. uF  q3R,          NK  	  pp/ pRV9   Ed#   V P                  VR,          R4      '       Ed   RpR\        /pV P	                  VR,          R4      pVP                  4       P                  R4      '       dM   RRRR	R
RR//RRRRRRR//RRRRRRR//RRRRRRR//RRRRRRR//RRRRRRR//RRRRRRR//RRRRRRR//.p	EMVP                  R4      '       g   VP                  R4      '       d   RRRR	R
RR//RRRRR//.p	MVP                  R4      '       d   RRRRR//.p	MRRR//.p	RR/pMRV9   dt   R pR\        R!R/pV P	                  VR,          R4      pVP                  4       P                  R"4      '       d    R#R$R%R!R//RRRRR&VR',          ,          //.p	M#R#R$R(R)R//.p	M\        P                  ! R*V4       / # R$VR$,          R+R,R'VR-,          R.V P                  V4      R/VR0VR1,          R2R3VR4VR5RR6/.R7V	//# u upi )8r7   rY   rZ   r   Zexez.shZextractru   Z
humblegameZformatZzipZdstz$CACHEZmergeZsrcz$CACHE/data/noarchz$GAMEDIRZoptionalTZmovez$CACHE/noarchz$CACHE/data/x86_64z$CACHE/x86_64z$CACHE/data/x86z
$CACHE/x86z$CACHE/data/z-binzmojo.runz.airZgamemodeZfalserf   wineZprefixz.zipZtaskr5   Zcreate_prefixz$GAMEDIR/drive_c/%sr4   ZwineexecZ
executablezUnsupported platforms: %sZversionr;   r1   rs   rq   rh   r3   scriptrM   ZsystemZfilesz+N/A:Select the installer from Humble Bundlert   )r6   loadsrz   r   rx   Zlowerr`   r   r   rg   Zget_installed_slug)
r&   db_gamer7   r_   	platformsZsystem_configrq   Zgame_configrn   r|   s
   &&        r#   generate_installerZ&HumbleBundleService.generate_installer  s	   **WY/0:A+:NO:Nhj)):N	OiD$?$?@TV]$^$^F ,/K55gk6JGTH~~((//xx XYu&:E:z[_`ae%95/S]_cdeu&:E:z[_`ae%95/S]_cdeu&7
JX\]^e%6|ZY]^_uneZUYZ[	 ""6**h.?.?
.K.Kxx XYuneZHI ""6**e\5*EF %v|&<=>!+W 5)#F .(JGK55gk6JIVH~~((00foxLMu>SV]^dVe>e fg
 "FJl#STUNN6	BIGFOGN+009f(-<)VWXV	
 	
W Ps   H:c                s    \         P                  ! VR ,          4      pVR,           Uu. uF  q3R,          NK  	  ppRV9   d"   V P                  VR,          R4      '       d   R# RV9   d   R# R# u upi )r7   rY   rZ   r   rf   r{   Z )r6   r}   rz   )r&   r~   r7   r_   r   rV   r#   get_installed_runner_nameZ-HumbleBundleService.get_installed_runner_nameB  sm    **WY/0:A+:NO:Nhj)):N	OiD$?$?@TV]$^$^	! Ps   A/r   )r   rf   r%   )2r   r   r   r   r   ZidZ_matcherr@   r5   r   ZonlineZdrm_freer$   r   r.   ZmediasZdefault_formatrU   Z	login_urlZredirect_urisr   r   r   r   r    rC   Z
token_pathrQ   r\   rE   rH   rI   rN   rP   rS   rW   rJ   rb   r[   Zstaticmethodrj   rk   rv   rx   rz   r   r   r!   r*   Z__classcell__)rF   r,   s   @@r#   r:   r:   =   s6    #	BH_DDFHOV5EzS`aFN-GGI@AM77<< 2 24HILh002GHJh002IJJ.00!'"B
  6 0 0  :
x
 
r"   r:   c                s   V R,          '       g   \         P                  ! R4       R# R p\        V R,          VRR7      p\         P                  ! R4       V F  p\         P                  ! V4       K  	  V^ ,          R,          R	,          # )
zFrom a list of downloads in Humble Bundle, pick the most appropriate one
for the installer.
This needs a way to be explicitely filtered.
ry   zNo downloads foundNc                 s    V R ,          pRV9   d   R# ^pRV9  d   ^p\         P                  P                  '       d   RV9   g   RV9   d   R#  ^V,          # RV9   d   R# ^V,          # )	r5   ZrpmZdebZ386Z32Z64iro   i)r   ZLINUX_SYSTEMZ	is_64_bit)r_   r5   Zbonusra   r#   humble_sortZ9pick_download_url_from_download_info.<locals>.humble_sortX  sw    D=JE'''}	 !-
 5y t|
5yr"   T)ZkeyZreversezHumble bundle installers:rG   Zweb)r   rg   ZsortedZdebug)download_infor   Zsorted_downloadsr_   s   &   r#   rw   rw   O  su    
 *+++, m,=>KY]^
LL,-$X %Au%e,,r"   c                s@   \        4       pVR8w  d   TMRpVP                  W4      pV'       g   \        P                  ! RW4       R# \        P                  ! R\        V4      V 4       V^ ,          p\        P                  ! RVR,          R,          4       \        P                  ! VP                  VR	,          4      4       VP                  VR	,          4      pVP                  W`V4      pV'       d   \        VR
,          4      # \        P                  ! RV 4       R# )z6Return a download link for a given humbleid and runnerr{   rf   z5Game %s for %s not found in the Humble Bundle libraryNzFound %s download for %szReloading order %sr^   r2   rR   r_   z&Couldn't retrieve any downloads for %s)r:   rk   r   rO   rd   re   r   ZremoverS   rW   rj   rw   rg   )rh   rq   r   rZ   rY   r_   r]   r   s   &&      r#   rp   rp   n  s    !#G6)vyH%%h9ILha
KK*C	NHE|H
KK$hy&9,&GHIIg  )!456hy12E225HMM3M*4MNN
NN;XFr"   )*r   Zconcurrent.futuresrc   r6   r   r    r@   Zgi.repositoryr   Zlutrisr   Zlutris.exceptionsr   Zlutris.gui.dialogsr   r   Zlutris.installerr   r   Zlutris.installer.installer_filer   Zlutris.services.baser	   r
   Zlutris.services.service_gamer   Zlutris.services.service_mediar   Zlutris.utilr   Zlutris.util.httpr   r   Zlutris.util.logr   r   r$   r.   r0   r:   rw   rp   r   r"   r#   <module>r      s    $   	     2 H 9 9 = 4 6  / "| & $ {  O- Od->Gr"   