+
    Ki&  c                   sl   R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
Ht ^ RIHt ^ RIHtHtHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIH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'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# )zSteam serviceN)defaultdict)gettext)settings)LutrisConfigwrite_game_config)sql)add_gameget_game_by_field	get_games)ServiceGameCollection)Game)InstallerFile)BaseService)
sync_media)ServiceGame)ServiceMedia)logger)AppManifestget_appmanifests)get_active_steamid64get_steam_libraryget_steamapps_dirs)slugifyc                   sx    ] tR t^tRtRt]P                  P                  ]	P                  R4      tR.tRtRtRtR# )	SteamBannersteamzsteam/banners%s.jpgappidzBhttp://cdn.akamai.steamstatic.com/steam/apps/%s/capsule_184x69.jpg N)i   iE   __name__
__module____qualname____firstlineno__serviceZsizeospathjoinr   Z	CACHE_DIRZ	dest_pathZfile_patternsZ	api_fieldZurl_pattern__static_attributes__r       :/usr/lib/python3.14/site-packages/lutris/services/steam.pyr   r      s7    GDX//AIJMIVKr&   r   c                   sx    ] tR t^"tRtRt]P                  P                  ]	P                  R4      tR.tRtRtRtR# )	
SteamCoverr   zsteam/coversr   r   z<http://cdn.steamstatic.com/steam/apps/%s/library_600x900.jpgr   N)i   i,  r   r   r&   r'   r(   r(   "   s7    GDX//@IJMIPKr&   r(   c                   sx    ] tR t^+tRtRt]P                  P                  ]	P                  R4      tR.tRtRtRtR# )	SteamBannerLarger   zsteam/headerr   r   z?https://cdn.cloudflare.steamstatic.com/steam/apps/%s/header.jpgr   N)i  i   r   r   r&   r'   r)   r)   +   s7    GDX//@IJMISKr&   r)   c                   s@   a  ] tR t^4t o RtRtRtRt]R 4       t	Rt
V tR# )	SteamGamezServiceGame for Steam gamesr   c                s    V ! 4       pVR,          Vn         VR,          Vn        VR,          Vn        \        VR,          4      Vn        V P
                  Vn        \        P                  ! V4      Vn        V# )z0Return a Steam game instance from an AppManifestr   name)	r   game_idr+   r   slugrunnerjsonZdumpsdetails)Zcls
steam_gamegames   && r'   new_from_steam_gameZSteamGame.new_from_steam_game;   s`     u(
!'*v&	Jv./	jjzz*-r&   r   N)r   r   r   r    __doc__r!   installer_slugr.   Zclassmethodr3   r%   __classdictcell__)__classdict__s   @r'   r*   r*   4   s)     %GNF	 	r&   r*   c                   s   a a ] tR t^Ht oRt]! R4      tRtR]R]	R]
/tRtRt. ROt]tR tV 3R ltR	 tR
 t]R 4       tR tR tR tR tRtVtV ;t# )SteamServicer   ZSteamzsteam-clientZbannerZbanner_largeZcoverc                sd   \        4       pV'       g   \        P                  ! R4       R# \        V4      pV'       g   \	        \        R4      4      hV FH  pVR,          V P                  9   d   K  V P                  P                  V4      pVP                  4        KJ  	  V P                  4        V# )zReturn importable Steam gamesz(Unable to find SteamID from Steam configNzOFailed to load games. Check that your profile is set to public during the sync.r   )r   r   errorr   ZRuntimeError_excluded_appids
game_classr3   saveZmatch_games)selfsteamidZsteam_gamesr1   r2   s   &    r'   loadZSteamService.loadZ   s    &(LLCD'0q!rstt%J'"d&:&::??66zBDIIK	 &
 	r&   c           	     sZ  < \         SV `  W4       V'       d   \        R V P                  RVR,          /R7       Fk  p\        P
                  ! VR,          4      P                  R4      pV^<,          p\        P                  ! \        P                  RRV/RVR,          /R	7       Km  	  R
# R
# )r!   
service_idr   Zfiltersr0   Zplaytime_foreverZgamesplaytimeid)Z
conditionsN)Zsuper
match_gamer   rD   r/   ZloadsZgetr   Z	db_updater   ZDB_PATH)r>   service_gameZlutris_gamer2   Zsteam_game_playtimerC   	__class__s   &&&   r'   rE   ZSteamService.match_gamek   s    <5!9dgg|\ZaMb*cd&*jji1H&I&M&MN`&a#.3h..*h9O]acghlcm\no e r&   c                s    R p\        VP                  R,          R,          4      p\        VP                  RRWE,          RV/4      pV.. 3# )z$STEAM:%s:.r2   r   r1   ZurlZfilename)Zstrscriptr   	game_slug)r>   Z	installerZ_installer_file_idZ_selected_extrasZ	steam_urir   Zfiles   &&&&   r'   get_installer_filesZ SteamService.get_installer_filesu   sO    !	I$$V,W56Y00,	HY[egl@mnvrzr&   c                s<   VP                  4       '       g   R# VP                  pW P                  9   d   R#  \        P                  ! V P
                  V4      pV'       g   R# V P
                  : RV: 2p\        VR4      pV'       d   R# \        4       P                  pW&R,          R&   \        WF4      pV P                  V4      p\        VR,          RV^VVRV P
                  VR	7	       V#   \         d#   p	\        P                  ! R
T	4        Rp	?	R# Rp	?	ii ; i)z;Create a new Lutris game based on an existing Steam installN-r5   r2   r   r+   r   ZLinux)	r+   r.   r-   	installedr5   
configpathZplatformr!   rA   z Failed to install from Steam: %s)Zis_installedr?   r;   r	   Zget_gamerD   r   r   
game_levelr   get_installed_slugr   	Exceptionr   r9   )
r>   Zmanifestr   rF   Zlutris_game_idexisting_gameZgame_configrM   r-   exs
   &&        r'   install_from_steamZSteamService.install_from_steam{   s    $$&&  (((	099$''5IL(,7N-n>NOM&.33K+0(*>GJ**<8D!&)-%  
 K 	LL;R@	s$   (C. #'C. A!C. .D9DDc                s    \        4       # N)r   )r>   s   &r'   steamapps_pathsZSteamService.steamapps_paths   s    !##r&   c                s   R^ R^ R^ R. /p. p. pV P                    F  p\        V4       F  pWAR,          9  d   VR,          P                  V4       \        P                  P                  WE4      p \        V4      pVP                  VP                  4       V P                  V4      pV'       d   VP                  V4       VR;;,          ^,          uu&   K  	  K  	  VR,          '       dM   \        P                  ! RVR,          4       \        P                  ! RR	P                  VR,          4      4       M\        P                  ! R
4       \        RR/R7      p
V
 F  p\        VR,          4      pVP                  f!   \        P                   ! RVR,          4       KC   VP                  P"                  R,          R,          pY9  g   Kp   TP'                  4        TR;;,          ^,          uu&   K  	  \        P                  ! RVR,          4       \)        \*        4      p\        RR/R7      p
V
 F(  pWR,          ,          P                  VR,          4       K*  	  VP-                  4        F  w  pp\/        V4      ^8X  d   K  V F  p\        V4      pVP                  f   \        P                   ! RV4       K5  VP0                  '       d   KI   VP'                  4        VP3                  4        VR;;,          ^,          uu&   K  	  K  	  \5        V4       \        P                  ! RVR,          4       R#   \         d$   p	\        P                  ! RYi4        Rp	?	EK>  Rp	?	ii ; i  \$         d$    \        P                   ! RTR,          4        EK=  i ; i  \         d$   p	\        P                  ! RY4        Rp	?	EKj  Rp	?	ii ; i  \         d%   p	\        P                  ! RTT	4        Rp	?	EKo  Rp	?	ii ; i)z'Syncs installed Steam games with LutrisrL   ZremovedZdedupedZpathsz%Failed to process app manifest %s: %sNz%%s Steam games detected and installedzGames found in: %sz, z No Steam folder found with gamesr.   r   rB   rD   zSteam game %s has no configr2   r   zSteam game %s has no AppIDzFailed to uninstall game %s: %sz%s Steam games removedr!   rA   z-Steam game %s has no config for deduplicationz!Failed to deduplicate game %s: %sz%s Steam games deduplicated)rU   r   Zappendr"   r#   r$   r   r?   rS   rP   r   r9   debugr   r
   ZconfigZwarningrN   ZKeyErrorZ	uninstallr    ZlistZitemsZlenrC   Zdeleter   )r>   ZstatsZinstalled_slugsZinstalled_appidsZsteamapps_pathZappmanifest_fileZapp_manifest_pathZapp_manifestr-   rR   db_gamesdb_gamer1   r   Z	db_appidsZ_appidZgame_idsr,   s   &                 r'   add_installed_gamesZ SteamService.add_installed_games   sC   aAy!WbI"22N$4^$D !w7'N)).9$&GGLL$R!a#./@#AL$++L,@,@A22<@D'..t4+&!+& %E 3 >>LL@%BTULL-tyyw/HILL;<h%89Ggdm,J  (<gdmL"))44V<WE ,O((*)$)$  " 	-uY/?@%	i%9:Gl+,33GDMB   !* 1FH8}!#!']
$$,NN#RT[\!***W",,."))+i(A-( $ !2" 	?#2E)4DEi ! aLL!HJ[``a"  ;WT]K ! OLL!BENNO0 % W%H'SUVVWs[   1A%L>#$M/%N 5O>M,	M''M,/)NN O+O		OP O;;P c                s    RVR,          RV P                   R\        VR,          4      R,           V P                  ,           RV P                  V4      RV P	                  V4      RVR,          RR	RVR,          ///# )
z Generate a basic Steam installerr+   Zversionr-   rK   rI   r.   r   rH   r2   )r+   r   rD   rO   get_installed_runner_namer>   rX      &&r'   generate_installerZSteamService.generate_installer   sz     GFOtyyGGFO,s2TWW<009d44W=WW%v)9:;
 	
r&   c                s    V P                   # rT   )r.   r[   r\   r'   rZ   Z&SteamService.get_installed_runner_name   s    {{r&   c                s    VR ,          p\        RVRRRV P                  /R7      pV P                  W24      pV'       d?   \        P                  ! RV4       \        VP                  4      pVP                  4        R# V P                  W4       R# )r   rA   rL   Z1r!   rB   zFound steam game: %sN)r   rD   Zmatch_existing_gamer   rV   r
   r=   Zinstall_from_api)r>   rX   r   rW   rQ   r2   s   &&    r'   installZSteamService.install   sv     lE;YX\X_X_%`a00ALL/?(()DIIKg-r&   r   )Z221410Z228980Z1070560)r   r   r   r    rD   r:   r+   Ziconr   r)   r(   ZmediasZdefault_formatr.   r;   r*   r<   r@   rE   rJ   rS   ZpropertyrU   rY   r]   rZ   r^   r%   r6   Z__classcell__)rG   r7   s   @@r'   r8   r8   H   s     	BW:DD+(F
 NFO
 J"p!F $ $FFP

	. 	.r&   r8   )0r4   r/   r"   Zcollectionsr    r   r:   Zlutrisr   Zlutris.configr   r   Zlutris.databaser   Zlutris.database.gamesr   r   r   Zlutris.database.servicesr	   Zlutris.gamer
   Zlutris.installer.installer_filer   Zlutris.services.baser   Zlutris.services.lutrisr   Zlutris.services.service_gamer   Zlutris.services.service_mediar   Zlutris.util.logr   Zlutris.util.steam.appmanifestr   r   Zlutris.util.steam.configr   r   r   Zlutris.util.stringsr   r   r(   r)   r*   r8   r   r&   r'   <module>r_      s      	 #    9  H H :  9 , - 4 6 " G ` ` 'W, WQ QT| T (z.; z.r&   