+
    Ki!7  c                   s   R t ^ RIt^ RIt^ RIt^ RI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Ht ^ RIHtHtHt ^ R	I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I0H1t1 ^ RI2H3t3 ^ RI4H5t5  ! R R]%4      t6 ! R R]#4      t7 ! R R]4      t8R# )zUbisoft Connect serviceN)gettext)AnyDictOptional)unquote)Gio)settings)LutrisConfigwrite_game_config)add_gameget_game_by_fieldupdate_existing)ServiceGameCollection)Game)SERVICE_LOGINSERVICE_LOGOUTOnlineService)
sync_media)ServiceGame)ServiceMedia)	AsyncCall)logger)slugify)consts)UbisoftConnectClient)get_ubisoft_registry)UbisoftParser)WinePrefixManagerc                   s   a a ] tR t^ t oRtRtRt]P                  P                  ]
P                  R4      tR.tRtRtV3R lR ltV 3R	 ltR
tVtV ;t# )UbisoftCoverzUbisoft connect cover artubisoftzubisoft/coversz%s.jpgZ
thumbImagez>https://static3.cdn.ubi.com/orbit/uplay_launcher_3_0/assets/%sc                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   "</usr/lib/python3.14/site-packages/lutris/services/ubisoft.pyZ__annotate__ZUbisoftCover.__annotate__*   s'      T#s(^      c                s    VP                  R 4      '       d
   VR ,          # VP                  V P                  4      '       d$   V P                  WP                  ,          ,          # R# )ZcoverUrlN)get	api_fieldurl_pattern)selfr      &&r    get_media_urlZUbisoftCover.get_media_url*   sJ    ;;z"":&&;;t~~&&##gnn&===r!   c                s   < VP                  R 4      '       d   \        SV `	  W4      # VP                  R4      '       g   R# \	        RR4      pV'       g   R# VR,          p\
        P                  P                  VRV4      p\
        P                  P                  V P                  V P                  V4      4      p\
        P                  P                  V4      '       d   \        P                  ! WV4       R# \        P                  ! RV4       R# )Zhttpz.jpgNubisoft-connectslug	directoryzFdrive_c/Program Files (x86)/Ubisoft/Ubisoft Game Launcher/cache/assetszNo thumbnail in %s)Z
startswithsuperdownloadZendswithr
   ospathjoin	dest_pathZget_filenameexistsshutilZcopyr   warning)r%   r)   urlubi_gamebase_dirZ
asset_file
cache_path	__class__s   &&&    r    r,   ZUbisoftCover.download4   s    >>&!!7#D..||F##$%6?K(WW\\^`c

 WW\\$..$2C2CD2IJ
77>>*%%KK
/NN/<r!    )i   i   )__name__
__module____qualname____firstlineno____doc__serviceZsizer-   r.   r/   r   	CACHE_DIRr0   Zfile_patternsr#   r$   r'   r,   __static_attributes____classdictcell____classcell__r8   r      @@r    r   r       sR     #GDX//1ABIJMIRK = =r!   r   c                   s8   a  ] tR t^Gt o RtRt]R 4       tRtV t	R# )UbisoftGamez+Service game for games from Ubisoft connectr   c                s    V ! 4       pVR,          ;'       g
    VR,          Vn         \        VR,          4      Vn        VR,          Vn        \        P
                  ! V4      Vn        V# )z)Convert an Ubisoft game to a service gamespaceId	installIdname)appidr   r)   rI   jsondumpsr   )ZclsZpayloadZservice_game   && r    new_from_apiZUbisoftGame.new_from_apiL   sY     u$Y/GG7;3G#GFO4#FO#zz'2r!   r9   N)
r:   r;   r<   r=   r>   r?   ZclassmethodrN   rA   rB   )r   s   @r    rF   rF   G   s     5G r!   rF   c                   s  a a ] tR t^Wt oRtRt]! R4      tRtRt	Rt
RtRtRt]P                  P!                  ]P$                  R4      t]P                  P!                  ]P$                  R	4      t]P                  P!                  ]P$                  R
4      t]P.                  tR.tRRRR/tR]/tRtV 3R ltR tR t R t!R t"R t#]$R 4       t%R t&R t'R t(R t)R t*R t+R t,Rt-Vt.V ;t/# ) UbisoftConnectServicez!Service class for Ubisoft Connectr   zUbisoft ConnectZwiner(       zubisoft/.authzubisoft/.tokenzubisoft/library/*https://connect.ubisoft.com/change_domain/z!https://connect.ubisoft.com/readyzFwindow.location.replace("https://connect.ubisoft.com/change_domain/");zwindow.location.replace(localStorage.getItem("PRODloginData") +","+ localStorage.getItem("PRODrememberMe") +"," + localStorage.getItem("PRODlastProfile"));Zcoverc                sD   < \         SV `  4        \        V 4      V n        R # N)r+   __init__r   client)r%   r8   s   &r    rT   ZUbisoftConnectService.__init__s   s    *40r!   c                s2    \         P                  ! V 4       R # rS   )r   firer%      &r    	auth_lostZUbisoftConnectService.auth_lostw   s    D!r!   c                s   \         P                  ! R4       V\        R4      R p\        V4      p\        P
                  ! RV,           R,           4      pV P                  P                  V4      p\         P                  ! RV4       V P                  P                  V P                  4       \        P                  ! V 4       VR,          VR,          3# )	z0Called after the user has logged in successfullyz"Login to Ubisoft Connect sucessfulrR   NZ[Z]zUbisoft user data: %sZuserIdZusername)r   infolenr   rK   loadsrU   Zauthorise_with_local_storagedebugZset_auth_lost_callbackrY   r   rV   )r%   credentialsr4   Zunquoted_urlZstorage_jsonsZ	user_datas   &&    r    login_callbackZ$UbisoftConnectService.login_callbackz   s    89#JKMNs|

3#5#;<KK<<]K	,i8**4>>:4 (#Yz%:;;r!   c                sT    V P                  4       p\        P                  ! R V4       V# )z Ubisoft Connect is connected: %s)Zis_authenticatedr   r]   )r%   Zress   & r    is_connectedZ"UbisoftConnectService.is_connected   s$    ##%7=
r!   c                s   \        R R4      pV'       g   R# VR,          p RR.p. p V Fz  p\        P                  P                  W%4      p\        P                  ! V4      p V F;  p\        P                  P                  V4      '       g   K*  VP                  V4       K=  	  K|  	   V F  p	\        P                  ! RV	4       K  	   V'       dl   \        V\        P                  P                  R7      p
\        P                  ! RV
4       \        V
R	4      ;_uu_ 4       p	V	P                  4       uuRRR4       #  \        P                  ! R
V4       R#   + '       g   i     L*; i)r(   r)   Nr*   z\drive_c/Program Files (x86)/Ubisoft/Ubisoft Game Launcher/cache/configuration/configurationszVdrive_c/users/*/AppData/Local/Ubisoft Game Launcher/cache/configuration/configurationszFound config file candidate: %s)ZkeyzLoading configuration from: %sZrbz*Ubisoft configuration file not found in %s)r
   r-   r.   r/   globZisfileappendr   r]   ZmaxZgetmtimeopenZreadrZ   )r%   r5   r6   Zpossible_pathsZall_valid_filesZpath_patternZfull_patternZmatching_pathsZpZfZlatest_files   &          r    get_configurationsZ(UbisoftConnectService.get_configurations   s   $%6?K(hjd

 O*L77<<?L!YY|4N^#77>>!$$#**1- $ + 	C ALL:A> ! 	\o2773C3CDKLL9;Gk4((Avvx )( 	?@(K )(s   "EE'	c                sL  a   S P                   P                  S P                  4       4       S P                   P                  4       pTR,          R,          R,          P                  R. 4      p. pT Fw  pRT9   d8   RpTR,           F  pT F  pTR	,          R
8X  g   K  RpK  	  K   	  T'       g   KA  \        P                  T4      p	T	P                  4        TP                  T	4       Ky  	  S P                  4       p
\        4       pTP!                  T
4       F9  p\        P                  T4      p	T	P                  4        TP                  T	4       K;  	  T#   \         dC   p\        P
                  ! R T,          4       \        S P                  T 3R l4        Rp?R# Rp?ii ; i)z4Failed to authorize with API: %s. Re-login required.c                 s$   < SP                  4       # rS   )Zlogin)Z_resultZ_errorr%   s   &&r    Z<lambda>Z,UbisoftConnectService.load.<locals>.<lambda>   s    4::<r!   NZdataZviewerZ
ownedGamesZnodesZownedPlatformGroupsFZtypeZPCT)rU   Z!authorise_with_stored_credentialsload_credentialsZRuntimeErrorr   Zerrorr   ZlogoutZget_club_titlesr"   rF   rN   Zsaverb   rd   r   Zparse_games)r%   ZexZresponseZgamesZ	ubi_gamesgameZis_pcZplatform_groupZplatformr5   Zconfiguration_dataZconfig_parsers   f           r    loadZUbisoftConnectService.load   sh   	KK99$:O:O:QR
 ;;..0 *<8<<WbI	D$,&*+@&A&AN$2#F+t3$(E %3 'B "//5HMMOX&  "446%!--.@AD"//5HMMOX& B 3  	LLORTTUdkk#GH	s   )E F#!7FF#c                s    V P                   .# )z2Return a list of all files used for authentication)
token_pathrW   rX   r    credential_filesZ&UbisoftConnectService.credential_files   s       r!   c           	     sd   \         P                  P                  \         P                  P                  V P                  4      4      '       g_   \
        P                  ! R V P                  4       \         P                  ! \         P                  P                  V P                  4      4       \
        P                  ! RV P                  4       \        V P                  RRR7      ;_uu_ 4       pVP                  \        P                  ! V^R7      4       RRR4       R#   + '       g   i     R# ; i)z%Creating Ubisoft credentials path: %sz!Writing Ubisoft credentials to %sZwutf-8Zencoding)ZindentN)r-   r.   r1   Zdirnamerh   r   r]   Zmkdirrc   ZwriterK   rL   )r%   r^   	auth_filerM   r    store_credentialsZ'UbisoftConnectService.store_credentials   s    ww~~bggoodoo>??LL@$//RHHRWW__T__568$//J$//399YOODJJ{1=> :999s   ,(DD/	c                s    \         P                  ! R V P                  4       \        V P                  RR7      ;_uu_ 4       p\        P
                  ! V4      pRRR4       V#   + '       g   i     X# ; i)zLoading credentials from %srj   rk   N)r   r]   rh   rc   rK   rg   )r%   rl   r^   s   &  r    re   Z&UbisoftConnectService.load_credentials   sP    2DOOD$//G44	))I.K 5 54s   A""A3	c                s   VR ,          p\        VR ,          4      R,           V P                  ,           p\        VR4      pV'       d(   VR,          ^8X  d   \        P                  ! RV4       R# \        P                  ! RV4       \        VR,          R7      P                  p\        P                  ! VR	,          4      pVP                  R
4      ;'       g+    VP                  R4      ;'       g    VP                  R4      pRV 2VR,          R&   \        WF4      p	V P                  V4      p
V'       dO   \        VR,          VR ,          V P                  V
VR,          ^VV	V P                  VR,          R7
       VR,          # \        VR ,          V P                  V
VR,          ^VV	V P                  VR,          R7	       V
# )rI   -installer_slug	installedz+Ubisoft Connect game %s installed in LutrisNz"Installing Ubisoft Connect game %s
configpath)Zgame_config_idr   launchIdrH   rG   uplay://launch/rf   argsidr*   rJ   )
ru   rI   runnerr)   r*   rp   ro   rq   r?   
service_id)	rI   rv   r)   r*   rp   ro   rq   r?   rw   )r   ru   r
   r   r]   r   Z
game_levelrK   r\   r"   r   get_installed_slugr   rv   r	   )r%   ubisoft_connectrf   Zapp_nameZlutris_game_idZexisting_gamegame_configr   	launch_idrq   r)   s   &&&        r    install_from_ubisoftZ*UbisoftConnectService.install_from_ubisoft   s{   < f.4tww>).:JK];71<LLFQ98D"/,2OP[[**T)_-KK
+aaw{{;/Gaa7;;W`Ka	(7	{&CFF#&~C
&&t, &&\{{)+6-%= !&&f;;%k2)!GGG}
	
 r!   c                s   \        V P                  R 4      pV'       g   \        P                  ! R4       R# VR,          P	                  R4      ^ ,          p\        V4      p. p\        P                  ! V P                  4       F  p\        P                  ! VR,          4      p\        W6P                  R4      4      p\        W6P                  R4      4      pV'       g   K^  V'       g   Kh  V P                  W4      p	V	'       g   K  VP                  V	4       K  	  \        P                  ! R\!        V4      4       \#        V4       R# )	r)   zUbisoft Connect not installedNr*   Zdrive_cr   ZregistryPathexezSyncing media for %s games)r
   client_installerr   r3   Zsplitr   r   Zget_for_serviceru   rK   r\   r   r"   r|   rb   r]   r[   r   )
r%   ry   Zprefix_pathprefixZinstalled_slugsrf   r   Zinstall_pathr}   r)   s
   &         r    add_installed_gamesZ)UbisoftConnectService.add_installed_games  s    +D,A,A6JNN:;%k288CAF";/)99$''BDjji1G/N8STL&v{{5/ABC|00G4#**40 C 	133GH?#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\        P                  ! VR,          4      pVP                  R4      ;'       g+    VP                  R4      ;'       g    VP                  R4      pVP                  R4      ;'       g+    VP                  R4      ;'       g    VP                  R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RV 2/RRRRRVRRV 2RVP                  P                  R,          RRVR,          ,          //.//# )ru   r}   r   r   rr   rH   rG   rI   Zversionr)   rn   	game_slugrv   rJ   ZscriptZrequiresrf   rt   rs   Z	installerZtaskZwineexecZ
executablezuplay://install/Zdescriptionz\Ubisoft will now open and install %s. Close Ubisoft Connect to complete the install process.)r   Zconfigrz   r-   r.   Zisabsr/   rK   r\   r"   rI   r   ru   rx   get_installed_runner_namer~   )r%   db_gameZubi_db_gamery   Zuc_exer   r{   Z
install_ids   &&&     r    generate_installerZ(UbisoftConnectService.generate_installer#  s   {401 ''33E:ww}}V$$WW\\/"8"8"D"DX"NPVWF**WY/0KK
+aaw{{;/Gaa7;;W`Ka	[[-bbZ1HbbGKKXaLb
GFOtyyGGFO,s2TWW<009d44W=WW%D11oi[9 "J(&"&6zl$C$o&<&<&H&H&R)!Y &fo	,.
!
 	
r!   c                s    V P                   # rS   )rv   )r%   r   r&   r    r   Z/UbisoftConnectService.get_installed_runner_nameI  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# )z:Install a game or Ubisoft Connect if not already installedr)   rp   z"Ubisoft Connect (%s) not installed)r   rJ   )r?   rJ   N)
r
   r~   r   ZApplicationZget_defaultr   r3   Zshow_lutris_installer_windowZshow_installer_windowr   )r%   r   ry   Zapplications   &&  r    installZUbisoftConnectService.installL  s    +D,A,A6Joo113ok&B&BNN?AVAVW44t?T?T4U--((BCTahYi . r!   )rU   )rP   rQ   )0r:   r;   r<   r=   r>   ru   _rI   Ziconrv   r~   Zbrowser_sizeZlogin_window_widthZlogin_window_heightr-   r.   r/   r   r@   Zcookies_pathrh   r7   r   Z	LOGIN_URLZ	login_urlZredirect_urisZscriptsr   ZmediasZdefault_formatrT   rY   r_   r`   rd   rg   Zpropertyri   rm   re   r|   r   r   r   r   rA   rB   rC   rD   rE   r    rO   rO   W   s$    +	BDDF(L77<< 2 2ODLh002BCJh002DEJ  IABM+.v4fG 	F N1"
<
'R< ! !?(T$&$
L
 
r!   rO   )9r>   ra   rK   r-   r2   r    r   Ztypingr   r   r   Zurllib.parser   Zgi.repositoryr   Zlutrisr   Zlutris.configr   r   Zlutris.database.gamesr	   r
   r   Zlutris.database.servicesr   Zlutris.gamer   Zlutris.services.baser   r   r   Zlutris.services.lutrisr   Zlutris.services.service_gamer   Zlutris.services.service_mediar   Zlutris.util.jobsr   Zlutris.util.logr   Zlutris.util.stringsr   Zlutris.util.ubisoftr   Zlutris.util.ubisoft.clientr   Zlutris.util.ubisoft.helpersr   Zlutris.util.ubisoft.parserr   Zlutris.util.wine.prefixr   r   rF   rO   r9   r!   r    <module>r      s       	    & &     9 N N :  M M - 4 6 & " ' & ; < 4 5$=< $=N+  M r!   