mirror of
https://github.com/derrod/legendary.git
synced 2025-08-04 15:01:02 +00:00
Directly handling Epic Games login without legendary-gl api for now.
This commit is contained in:
parent
3963382b3f
commit
f69d0e5142
|
@ -10,6 +10,8 @@ import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
import colorama
|
||||||
|
from colorama import Fore, Back, Style
|
||||||
|
|
||||||
from collections import defaultdict, namedtuple
|
from collections import defaultdict, namedtuple
|
||||||
from logging.handlers import QueueListener
|
from logging.handlers import QueueListener
|
||||||
|
@ -39,6 +41,7 @@ logger = logging.getLogger('cli')
|
||||||
|
|
||||||
|
|
||||||
class LegendaryCLI:
|
class LegendaryCLI:
|
||||||
|
_clientID = '34a02cf8f4414e29b15921876da36f9a'
|
||||||
def __init__(self, override_config=None, api_timeout=None):
|
def __init__(self, override_config=None, api_timeout=None):
|
||||||
self.core = LegendaryCore(override_config, timeout=api_timeout)
|
self.core = LegendaryCore(override_config, timeout=api_timeout)
|
||||||
self.logger = logging.getLogger('cli')
|
self.logger = logging.getLogger('cli')
|
||||||
|
@ -149,18 +152,23 @@ class LegendaryCLI:
|
||||||
from legendary.utils.webview_login import webview_available, do_webview_login
|
from legendary.utils.webview_login import webview_available, do_webview_login
|
||||||
|
|
||||||
if not webview_available or args.no_webview or self.core.webview_killswitch:
|
if not webview_available or args.no_webview or self.core.webview_killswitch:
|
||||||
# unfortunately the captcha stuff makes a complete CLI login flow kinda impossible right now...
|
# Captcha Prevents Automated Cli Login Sessions
|
||||||
print('Please login via the epic web login!')
|
print(Fore.MAGENTA+'Webview login is not available right now, we will need to complete things in your browser')
|
||||||
url = 'https://legendary.gl/epiclogin'
|
print(Fore.YELLOW + "Make sure you have logged in into your epic games account ")
|
||||||
|
input(Fore.CYAN + "Press any key to continue...")
|
||||||
|
url = f'https://www.epicgames.com/id/api/redirect?clientId={self._clientID}&responseType=code'
|
||||||
webbrowser.open(url)
|
webbrowser.open(url)
|
||||||
print(f'If the web page did not open automatically, please manually open the following URL: {url}')
|
print(f'If the web page did not open automatically, please manually open the following URL: {url}')
|
||||||
auth_code = input('Please enter the "authorizationCode" value from the JSON response: ')
|
input_code = ''
|
||||||
|
while input_code == '':
|
||||||
|
input_code = input(Fore.GREEN+'Please enter the authorization code from the JSON in your browser: ')
|
||||||
|
auth_code = input_code
|
||||||
auth_code = auth_code.strip()
|
auth_code = auth_code.strip()
|
||||||
if auth_code[0] == '{':
|
if auth_code[0] == '{':
|
||||||
tmp = json.loads(auth_code)
|
tmp = json.loads(auth_code)
|
||||||
auth_code = tmp['authorizationCode']
|
auth_code = tmp['authorizationCode']
|
||||||
else:
|
else:
|
||||||
auth_code = auth_code.strip('"')
|
auth_code = auth_code.strip('"')
|
||||||
else:
|
else:
|
||||||
if do_webview_login(callback_code=self.core.auth_ex_token,
|
if do_webview_login(callback_code=self.core.auth_ex_token,
|
||||||
user_agent=f'EpicGamesLauncher/{self.core.get_egl_version()}'):
|
user_agent=f'EpicGamesLauncher/{self.core.get_egl_version()}'):
|
||||||
|
|
|
@ -399,7 +399,7 @@ class LegendaryCore:
|
||||||
return self.get_game_and_dlc_list(update_assets=update_assets, platform=platform)[0]
|
return self.get_game_and_dlc_list(update_assets=update_assets, platform=platform)[0]
|
||||||
|
|
||||||
def get_game_and_dlc_list(self, update_assets=True, platform='Windows',
|
def get_game_and_dlc_list(self, update_assets=True, platform='Windows',
|
||||||
force_refresh=False, skip_ue=True) -> (List[Game], Dict[str, List[Game]]):
|
force_refresh=False, skip_ue=True) -> tuple[List[Game], Dict[str, List[Game]]]:
|
||||||
_ret = []
|
_ret = []
|
||||||
_dlc = defaultdict(list)
|
_dlc = defaultdict(list)
|
||||||
meta_updated = False
|
meta_updated = False
|
||||||
|
@ -524,8 +524,7 @@ class LegendaryCore:
|
||||||
self.log.debug(f'Removing old/unused metadata for "{app_name}"')
|
self.log.debug(f'Removing old/unused metadata for "{app_name}"')
|
||||||
self.lgd.delete_game_meta(app_name)
|
self.lgd.delete_game_meta(app_name)
|
||||||
|
|
||||||
def get_non_asset_library_items(self, force_refresh=False,
|
def get_non_asset_library_items(self, force_refresh=False, skip_ue=True) -> tuple[List[Game], Dict[str, List[Game]]]:
|
||||||
skip_ue=True) -> (List[Game], Dict[str, List[Game]]):
|
|
||||||
"""
|
"""
|
||||||
Gets a list of Games without assets for installation, for instance Games delivered via
|
Gets a list of Games without assets for installation, for instance Games delivered via
|
||||||
third-party stores that do not have assets for installation
|
third-party stores that do not have assets for installation
|
||||||
|
@ -961,7 +960,7 @@ class LegendaryCore:
|
||||||
|
|
||||||
return absolute_path
|
return absolute_path
|
||||||
|
|
||||||
def check_savegame_state(self, path: str, save: SaveGameFile) -> (SaveGameStatus, (datetime, datetime)):
|
def check_savegame_state(self, path: str, save: SaveGameFile) -> tuple[SaveGameStatus, (datetime, datetime)]:
|
||||||
latest = 0
|
latest = 0
|
||||||
for _dir, _, _files in os.walk(path):
|
for _dir, _, _files in os.walk(path):
|
||||||
for _file in _files:
|
for _file in _files:
|
||||||
|
@ -1331,7 +1330,7 @@ class LegendaryCore:
|
||||||
repair: bool = False, repair_use_latest: bool = False,
|
repair: bool = False, repair_use_latest: bool = False,
|
||||||
disable_delta: bool = False, override_delta_manifest: str = '',
|
disable_delta: bool = False, override_delta_manifest: str = '',
|
||||||
egl_guid: str = '', preferred_cdn: str = None,
|
egl_guid: str = '', preferred_cdn: str = None,
|
||||||
disable_https: bool = False, bind_ip: str = None) -> (DLManager, AnalysisResult, ManifestMeta):
|
disable_https: bool = False, bind_ip: str = None) -> tuple[DLManager, AnalysisResult, ManifestMeta]:
|
||||||
# load old manifest
|
# load old manifest
|
||||||
old_manifest = None
|
old_manifest = None
|
||||||
|
|
||||||
|
@ -1725,7 +1724,7 @@ class LegendaryCore:
|
||||||
igame.prereq_info['installed'] = True
|
igame.prereq_info['installed'] = True
|
||||||
self.lgd.set_installed_game(app_name, igame)
|
self.lgd.set_installed_game(app_name, igame)
|
||||||
|
|
||||||
def import_game(self, game: Game, app_path: str, egl_guid='', platform='Windows') -> (Manifest, InstalledGame):
|
def import_game(self, game: Game, app_path: str, egl_guid='', platform='Windows') -> tuple[Manifest, InstalledGame]:
|
||||||
needs_verify = True
|
needs_verify = True
|
||||||
manifest_data = None
|
manifest_data = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue