+
    KiU?  c                   s   R t ^ RIt^ RIt^ RIHt ^ RIHtHtHt ^ RI	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 ^ R
IHtHt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- ]P\                  P_                  R4      t0]P\                  P_                  R4      t1]P\                  P_                  R4      t2]P\                  P_                  R4      t3]P\                  P_                  R4      t4R)t5R*t6 ! R R]%4      t7 ! R R]74      t8 ! R R]84      t9 ! R R]84      t: ! R  R!]:4      t; ! R" R#]74      t< ! R$ R%]#4      t= ! R& R']4      t>R+R( lt?R# ),zEpic Games Store serviceN)gettext)AnyDictOptional)Gio)settings)LutrisConfigwrite_game_config)add_gameget_game_by_field)ServiceGameCollection)Game)Imagepaste_overlaythumbnail_image)SERVICE_LOGINAuthTokenExpiredErrorOnlineService)
sync_media)ServiceGame)ServiceMedia)system)EGSLauncher)logger)slugifyz~/.cache/lutris/egs/game_boxz!~/.cache/lutris/egs/game_box_tallz~/.cache/lutris/egs/game_logoz~/.cache/lutris/egs/bannersz~/.cache/lutris/egs/boxartc                   sN   a  ] tR t^#t o RtR	tR.tRt^tR t	V 3R lR lt
RtV tR# )
DieselGameMediaegsz%s.jpg,  c                s@   \         P                  P                  V P                  V4      p\         P                  P                  \        VP                  R R4      4      p\         P                  P                  V4      p\        P                  ! V4      pVP                  R4      p\        WPP                  4      pV'       Ed   \        P                  ! V4      pVP                  R4      pVP                  w  rxWpP                  8  dY   VP                  V P                  \        WP                  V,          ,          4      3\        P                   P"                  R7      pMgWP$                  8  dX   VP                  \        WpP$                  V,          ,          4      V P$                  3\        P                   P"                  R7      p\'        WV4      p\         P                  P                  V P                  V4      p	VP                  R4      pVP)                  V	4       R# )z.jpgz.pngZRGBA)ZresampleZRGBN)ospathjoin	dest_pathEGS_LOGO_PATHZreplaceexistsr   openZconvertr   remote_sizesize
min_logo_xZresizeZintZ
ResamplingZBICUBIC
min_logo_yr   save)
selffilenameZgame_box_pathZ	logo_pathZhas_logoZthumb_imageZ
logo_imageZ
logo_widthZlogo_heightZ
thumb_paths
   &&        8/usr/lib/python3.14/site-packages/lutris/services/egs.py_render_filenameZ DieselGameMedia._render_filename*   s   T^^X>GGLL0@0@0PQ	77>>),jj/!))&1%k3C3CD8I.J#++F3J&0oo#JOO+'..__c+:9U*V&WX"--55 / 
 .'..'DEFX"--55 / 
 (@KWW\\$..(;
!))%0$    c                sL   < V ^8  d   QhRS[ S[S[3,          RS[S[,          /# )i   detailsZreturn)r   Zstrr   r   )Zformat__classdict__s   "r*   Z__annotate__ZDieselGameMedia.__annotate__D   s'      T#s(^  r,   c                s    VP                  R . 4       FW  pVR,          V P                  8X  g   K  VR,          RV P                  ^ ,          : RV P                  ^,          : 2,           u # 	  R# )Z	keyImagesZtypeZurlz?w=z&resize=1&h=N)get	api_fieldr#   )r(   r-   Zimage   && r*   get_media_urlZDieselGameMedia.get_media_urlD   s\    [[b1EV}.U|t?O?OPQ?R?RTXTdTdefTg&hhh 2 r,    N   i  )__name__
__module____qualname____firstlineno__servicer#   file_patternsr%   r&   r+   r2   __static_attributes____classdictcell__r.      @r*   r   r   #   s/     GKJMJJ%4 r,   r   c                   s   a  ] tR t^Kt o RtRt]t^dt^dt]	P                  P                  ]P                  R4      tR tR tRtV tR# )DieselGameBoxTallzEGS tall game boxzegs/game_box_tallc                sv    \         P                  ! V P                  4       F  pV P                  V4       K  	  R # N)r   Zlistdirr   r+   )r(   r)   s   & r*   renderZDieselGameBoxTall.renderU   s'    

4>>2H!!(+ 3r,   r3   Nr4   )r6   r7   r8   r9   __doc__r$   r#   r%   r&   r   r   r   r   	CACHE_DIRr   r0   rB   r<   r=   r>   r?   r*   r@   r@   K   sF     DKJJX//1DEI#I, ,r,   r@   c                   s    ] tR t^ZtRtRtRtR# )DieselGameBoxSmallr3   N)d   i   r4   r6   r7   r8   r9   r$   r#   r<   r3   r,   r*   rE   rE   Z   s    DKr,   rE   c                   sz    ] tR t^_tRtRt]tRt^t]	P                  P                  ]P                  R4      tR tRtR# )DieselGameBoxEGS game boxr   zegs/game_boxr3   Ni<  i   )r6   r7   r8   r9   rC   r$   r#   r%   r&   r   r   r   r   rD   r   r0   r<   r3   r,   r*   rH   rH   _   s8    DKJJX//@IIr,   rH   c                   s    ] tR t^jtRtRtRtR# )DieselGameBannerSmallr3   N)i   iY   rJ   rG   r3   r,   r*   rK   rK   j   s    DKr,   rK   c                   s|    ] tR t^otRtRt]tR.tRt]	P                  P                  ]P                  R4      tR tRtR# )DieselGameBoxLogorI   z%s.pngFzegs/game_logor3   N)r5   rF   )r6   r7   r8   r9   rC   r$   r#   r;   Zvisibler   r   r   r   rD   r   r0   r<   r3   r,   r*   rL   rL   o   s:    DKJMGX//AI#Ir,   rL   c                   s8   a  ] tR t^zt o RtRt]R 4       tRtV t	R# )EGSGamez!Service game for Epic Games Storer   c                s    V ! 4       pVR,          Vn         \        VR,          4      Vn        VR,          Vn        \        P
                  ! V4      Vn        V# )z%Convert an EGS game to a service gameappNameZtitle)appidr   slugnamejsondumpsr-   )Zclsegs_gameservice_gamer1   r*   new_from_apiZEGSGame.new_from_api   sN     u%i0#HW$56$W-#zz(3r,   r3   N)
r6   r7   r8   r9   rC   r:   ZclassmethodrV   r<   r=   r>   r?   r*   rM   rM   z   s     +G r,   rM   c                   s  a a ] tR t^t oRtRt]! R4      tRtRt	Rt
RtRtRtR	]R
]R]R]/tR]/tR
tRt]P0                  P3                  ]P6                  R4      t]P0                  P3                  ]P6                  R4      t]P0                  P3                  ]P6                  R4      tRtR.t Rt!Rt"Rt#Rt$V 3R lt%]&R 4       t'R t(R t)R t*R&R lt+R t,R t-R t.R  t/R! t0R" t1R# t2R$ t3R%t4Vt5V ;t6# )'EpicGamesStoreServicez"Service class for Epic Games Storer   zEpic Games Store  iR  TZwineepic-games-storeZgame_box_smallZgame_banner_smallZgame_boxZbox_tallZlogoz	.egs.authz
.egs.tokenzegs-library.jsonzhttps://www.epicgames.com/id/login?redirectUrl=https%3A//www.epicgames.com/id/api/redirect%3FclientId%3D34a02cf8f4414e29b15921876da36f9a%26responseType%3Dcodez)https://www.epicgames.com/id/api/redirectz6https://account-public-service-prod03.ol.epicgames.comz6https://catalog-public-service-prod06.ol.epicgames.comz3https://library-service.live.use1a.on.epicgames.comzMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) EpicGamesLauncher/11.0.1-14907503+++Portal+Release-Live UnrealEngine/4.23.0-14907503+++Portal+Release-Live Chrome/84.0.4147.38 Safari/537.36c                s<  < \         SV `  4        \        P                  ! 4       V n        V P                  V P                  P
                  R &   / V n        \        P                  P                  V P                  4      '       dU    \        V P                  RR7      ;_uu_ 4       p\        P                  ! VP                  4       4      V n        RRR4       R# R#   + '       g   i     R# ; i  \         d$   p\         P"                  ! RXT4        Rp?R# Rp?ii ; i)z
User-Agentutf-8ZencodingNz"Unable to load token file '%s': %s)Zsuper__init__requestssession
user_agentheaderssession_datar   r   r!   
token_pathr"   rR   loadsZread	Exceptionr   	exception)r(   Z
token_fileex	__class__s   &  r*   r\   ZEpicGamesStoreService.__init__   s    '')-1__\*77>>$//**W$//G<<
(,

:??3D(ED% =< +<<< W  !EzSUVVWs6   C- #*CC- C*	$C- *C- -D8DDc                sB    \         P                  P                  R R4      # )Z 34a02cf8f4414e29b15921876da36f9aZ daafbccc737745039dffe53d94fc76cf)r]   authZHTTPBasicAuthr(      &r*   http_basic_authZ%EpicGamesStoreService.http_basic_auth   s    }}**+MOqrrr,   c                s"    V P                  4       # rA   )Zis_authenticatedri   rj   r*   is_connectedZ"EpicGamesStoreService.is_connected   s    $$&&r,   c                s   \         P                  ! R4       \         P                  ! V4       \        P                  ! VP	                  4       4      pVR,          pV P                  VR7       \        P                  ! V 4       R# )zOnce the user logs in in a browser window, Epic redirects
to a page containing a Session ID which we can use to finish the authentication.
Store session ID and exchange token to auth filezLogin to EGS successfulZauthorizationCode)authorization_codeN)r   debugrR   rc   Zdecodestart_sessionr   Zfire)r(   ZcontentZcontent_jsonZ
session_id   &&  r*   login_callbackZ$EpicGamesStoreService.login_callback   s\     	./Wzz'.."23!"56
j94 r,   c                sF   R V P                   R,          ,          V P                  P                  R&   V P                  P                  RV P                  ,          4      pVP
                  R8  d   VP                  4        VP                  4       pRV9   d   \        V4      hV# )z	bearer %sZaccess_tokenZAuthorizationz%s/account/api/oauth/verifyrX   ZerrorMessage)	ra   r^   r`   r/   	oauth_urlstatus_coderaise_for_statusrR   RuntimeError)r(   responseresponse_contents   &  r*   resume_sessionZ$EpicGamesStoreService.resume_session   s    0;d>O>OP^>_0__-<<##$ADNN$RS3&%%'#==?--/00r,   c           	     s$   V'       d
   R RRVRR/pM*V'       d
   R RRVRR/pMR RRV P                   R,          RR/pV P                  P                  RVV P                  R7      pVP                  R	8  d   VP                  4        VP                  4       pR
V9   d   \        V4      h\        V P                  RRR7      ;_uu_ 4       pVP                  \        P                  ! V^R7      4       RRR4       WPn         R#   + '       g   i     L; i)Z
grant_typeexchange_codeZ
token_typeZeg1rm   ZcodeZrefresh_tokenzNhttps://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token)Zdatarh   rX   errorZwrZ   r[   )ZindentN)ra   r^   Zpostrk   rs   rt   rR   ru   r"   rb   ZwriterS   )r(   ry   rm   paramsrv   rw   Z	auth_files   &&&    r*   ro   Z#EpicGamesStoreService.start_session   s    "O_mUachiF"$8&BTVbdijF o!2!2?!CeF <<$$\%% % 

 3&%%'#==?&&/00$//399YOODJJ'7BC :, :9s   (C??D	c                s   VR ,          pVR,          pV P                   P                  V P                  : RV: R2RVRRRRRR	R
R/R7      pVP                  4        VP	                  VP                  4       V,          4       V# )	namespaceZcatalogItemIdz/catalog/api/shared/namespace/z/bulk/itemsidZincludeDLCDetailsTZincludeMainGameDetailsZcountryZUSZlocaleZenr{   )r^   r/   catalog_urlrt   ZupdaterR   )r(   Zassetr|   Zcatalog_item_idrv   s   &&   r*   get_game_detailsZ&EpicGamesStoreService.get_game_details   s    +&	0<<##?C?O?OQZ[o#T($4$ $ 	
 	!!#X]]__56r,   c                s   V P                  4        V P                  P                  R V P                  ,          RR/R7      pVP	                  4        VP                  4       pVR,          pVR,          P                  RR4      pV'       d   V P                  P                  R V P                  ,          RRRV/R7      pVP	                  4        VP                  4       pVP                  VR,          4       VR,          P                  RR4      pK  . pV F5  pVR	,          R
8X  d   K  V P                  V4      pVP                  V4       K7  	  V# )z%s/library/api/public/itemsZincludeMetadataZtruer~   recordsZresponseMetadataZ
nextCursorNcursorr|   Zue)	rx   r^   r/   library_urlrt   rR   Zextendr   append)r(   rv   ZresDatar   r   ZgamesZrecordZgame_detailss   &       r*   get_libraryZ!EpicGamesStoreService.get_library  s6   <<##)D,<,<<FWY_E` $ 
 	!!#--/)$+,00tD||''-0@0@@J[]cemouIv ( H %%'mmoGNN79-./044\4HFFk"d*008LLL&	 
 r,   c                s    V P                  4       p. pT FD  p RT9   d   \
        P                  T4      pMK#  TP                  4        TP                  T4       KF  	  T#   \         d(   p\        P                  ! R4       \	        R4      ThRp?ii ; i  \         d:   p\        P                  ! RT4       \        P                  ! RT4        Rp?K  Rp?ii ; i)zLoad the list of gameszEGS Token expiredNrN   z Unable to interpret EGS game: %szEGS game skipped: %s)r   rd   r   warningr   rM   rV   re   infor'   r   )r(   Zlibraryrf   Z	egs_gamesgamerT   s   &     r*   loadZEpicGamesStoreService.load&  s    	E&&(G 	D
 $&33D9H
 MMOX&  %  	ENN./'(;<"D	E    !CRH2D9s.   A  B B+"BBC .CCc                s8   VR,          p\         P                  ! RV4       \        P                  ! RV4      pV'       g   \         P                  ! RV4       R# \        VR,          4      R,           V P                  ,           p\        VR4      pV'       d   R# \        VR	,          R
7      P                  p\        V4      VR,          R&   \        WW4      pV P                  V4      p	\        VR,          VR,          V	VR,          ^VVV P                  VR7	       V	# )z9Create a new Lutris game based on an existing EGS installZAppNamezInstalling EGS game %sr   z8Aborting install, %s is not present in the game library.NrQ   -installer_slug
configpath)Zgame_config_idr   argsrunner	directory)	rQ   r   rP   r   	installedr   r   r:   Z
service_id)r   rn   r
   Zget_gamerz   r   r}   r	   r   Z
game_levelget_launch_argumentsr   get_installed_slugr   )
r(   rT   manifestapp_namerU   Zlutris_game_idZexisting_gamegame_configr   rP   s
   &&&       r*   install_from_egsZ&EpicGamesStoreService.install_from_egs>  s    I&-x8,55eXFLLSU]^ f!56<twwF).:JK"(<2HITT&:8&DFF#&~C
&&|4f%H%{+)!GG
	
 r,   c                sR   \        RR4      pV'       g   \        P                  ! R4       R# VR,          P                  R4      ^ ,          p\        P                  ! RV4       \
        P                  ! \        P                  P                  VR4      4      '       g   \        P                  ! RV4       R# \        V4      p. pVP                  4        F/  pV P                  W4      pV'       g   K  VP                  V4       K1  	  \        V4       \        P                  ! R	4       R# )
z&Scan an existing EGS install for gamesrY   rP   zEGS is not installed in LutrisNr   Zdrive_czEGS detected in %szInvalid install of EGS at %szAll EGS games imported)r	   r   rz   Zsplitr   r   Zpath_existsr   r   r   r   Ziter_manifestsr   r   r   rn   )r(   rT   Z
egs_prefixZegs_launcherZinstalled_slugsr   rP   s   &      r*   add_installed_gamesZ)EpicGamesStoreService.add_installed_games[  s    $%7@LL9:k*00;A>
(*5!!"'',,z9"EFFLL7D":.$335H((<Dt&&t, 6 	?#-.r,   c                s   \        VR ,          4      pVP                  P                  R,          p\        P                  P                  V4      '       g<   \        P                  P                  VP                  P                  R,          V4      p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V P                  RR\        VR	,          4      /RRRRRVR\        VR	,          R4      RVP                  P                  R,          RRVR,          ,          //.//# )r}   ZexeZprefixrQ   ZversionrP   r   	game_slugr   rO   ZscriptZrequiresr   r   Z	installerZtaskZwineexecZ
executableinstallZdescriptionzThe Epic Game Store will now open. Please launch the installation of %s then close the EGS client once the game has been downloaded.)r   Zconfigr   r   r   Zisabsr   rQ   r   r}   r   get_installed_runner_nameclient_installerr   )r(   db_gameZegs_db_gamerT   Zegs_exes   &&&  r*   generate_installerZ(EpicGamesStoreService.generate_installerp  sE   D)*//--e4ww}}W%%ggll8??#>#>x#H'RGGFOtyyGGFO,s2TWW<009d44W=WW%D1101AB "J('"$89I9$U$hoo&A&A(&K)!EGNv!W
!
 	
r,   c                s    V P                   # rA   )r   )r(   r      &&r*   r   Z/EpicGamesStoreService.get_installed_runner_name  s    {{r,   c                sn   \        V P                  R 4      p\        P                  P	                  4       pV'       d   VR,          '       g@   \
        P                  ! RV P                  4       VP                  V P                  R7       R# VP                  V P                  W4      .WR,          R7       R# )rP   r   zEGS (%s) not installed)r   rO   )r:   rO   N)
r	   r   r   ZApplicationZget_defaultr   r   Zshow_lutris_installer_windowZshow_installer_windowr   )r(   r   rT   Zapplicationrp   r*   r   ZEpicGamesStoreService.install  s    $T%:%:FCoo113x44NN3T5J5JK44t?T?T4U--((;<dZaRb . r,   )r^   ra   )NN)7r6   r7   r8   r9   rC   r}   _rQ   Zlogin_window_widthZlogin_window_heightZiconZonliner   r   rE   rK   rH   r@   ZmediasrL   Zextra_mediasZdefault_formatZrequires_login_pager   r   r   r   rD   Zcookies_pathrb   Z
cache_pathZ	login_urlZredirect_urisrr   r   r   r_   r\   Zpropertyrk   rl   rq   rx   ro   r   r   r   r   r   r   r   r   r<   r=   Z__classcell__)rg   r.   s   @@r*   rW   rW      sO    ,	B DDFF),2M%	F 	!L )N77<< 2 2K@Lh00,?Jh002DEJ	L 
 AAMHIJKGK	, 
W s s'
!	 -6$40:/*!
F	 	r,   rW   c                 s    R V : RV: 2# )z=-opengl -SkipBuildPatchPrereq -com.epicgames.launcher://apps/z?action=r3   )r   Zactionr   r*   r   r     s    \dflmmr,   rJ   r4   )Zlaunch)@rC   rR   r   r    r   Ztypingr   r   r   r]   Zgi.repositoryr   Zlutrisr   Zlutris.configr   r   Zlutris.database.gamesr   r	   Zlutris.database.servicesr
   Zlutris.gamer   Zlutris.gui.widgets.utilsr   r   r   Zlutris.services.baser   r   r   Zlutris.services.lutrisr   Zlutris.services.service_gamer   Zlutris.services.service_mediar   Zlutris.utilr   Zlutris.util.egs.egs_launcherr   Zlutris.util.logr   Zlutris.util.stringsr   r   Z
expanduserZEGS_GAME_ART_PATHZEGS_GAME_BOX_PATHr    ZEGS_BANNERS_PATHZEGS_BOX_ART_PATHZBANNER_SIZEZBOX_ART_SIZEr   r@   rE   rH   rK   rL   rM   rW   r   r3   r,   r*   <module>r      s0     	   & &    9 = :  J J T T - 4 6  4 " 'GG&&'EF GG&&'JK ""#BC77%%&CD 77%%&BC %l %P, ,* 
 %  M 
$ $k  UM Upnr,   