Add medias for EGS and keep appName

This commit is contained in:
Mathieu Comandon 2021-04-30 16:44:15 -07:00
parent 5683898db0
commit 36d404d667
3 changed files with 27 additions and 15 deletions

View file

@ -2,8 +2,6 @@
import os
from lutris import settings
from lutris.util import system
from lutris.util.linux import LINUX_SYSTEM
from lutris.services.battlenet import BattleNetService
from lutris.services.bethesda import BethesdaService
from lutris.services.dolphin import DolphinService
@ -17,7 +15,9 @@ from lutris.services.origin import OriginService
from lutris.services.steam import SteamService
from lutris.services.ubisoft import UbisoftConnectService
from lutris.services.xdg import XDGService
from lutris.util import system
from lutris.util.dolphin.cache_reader import DOLPHIN_GAME_CACHE_FILE
from lutris.util.linux import LINUX_SYSTEM
DEFAULT_SERVICES = ["lutris", "gog", "humblebundle", "steam"]
@ -36,6 +36,7 @@ def get_services():
_services["dolphin"]: DolphinService
return _services
SERVICES = get_services()

View file

@ -18,7 +18,7 @@ from lutris.util.strings import slugify
class DieselGameMedia(ServiceMedia):
service = "egs"
file_pattern = "%s"
file_pattern = "%s.jpg"
def get_media_url(self, detail):
for image in detail["keyImages"]:
@ -48,7 +48,7 @@ class EGSGame(ServiceGame):
def new_from_api(cls, egs_game):
"""Convert an EGS game to a service game"""
service_game = cls()
service_game.appid = egs_game["id"]
service_game.appid = egs_game["appName"]
service_game.slug = slugify(egs_game["title"])
service_game.name = egs_game["title"]
service_game.details = json.dumps(egs_game)
@ -181,8 +181,9 @@ class EpicGamesStoreService(OnlineService):
auth_file.write(json.dumps(response_content, indent=2))
self.session_data = response_content
def get_game_details(self, namespace, catalog_item_id):
def get_game_details(self, asset):
namespace = asset["namespace"]
catalog_item_id = asset["catalogItemId"]
response = self.session.get(
'%s/catalog/api/shared/namespace/%s/bulk/items' % (self.catalog_url, namespace),
params={
@ -194,7 +195,9 @@ class EpicGamesStoreService(OnlineService):
}
)
response.raise_for_status()
return response.json()[catalog_item_id]
# Merge the details with the initial asset to keep 'appName'
asset.update(response.json()[catalog_item_id])
return asset
def get_library(self):
self.resume_session()
@ -208,7 +211,7 @@ class EpicGamesStoreService(OnlineService):
for asset in assets:
if asset["namespace"] == "ue":
continue
game_details = self.get_game_details(asset["namespace"], asset["catalogItemId"])
game_details = self.get_game_details(asset)
games.append(game_details)
return games
@ -233,3 +236,11 @@ class EpicGamesStoreService(OnlineService):
self.is_loading = False
self.emit("service-games-loaded")
return egs_games
def get_launch_arguments(app_name):
return (
"-opengl"
" -SkipBuildPatchPrereq"
" -com.epicgames.launcher://apps/%s?action=launch&silent=true"
) % app_name

View file

@ -3,9 +3,9 @@ import os
from lutris import settings
from lutris.database.services import ServiceGameCollection
from lutris.util.log import logger
from lutris.util import system
from lutris.util.http import HTTPError, download_file
from lutris.util.log import logger
PGA_DB = settings.PGA_DB
@ -41,12 +41,12 @@ class ServiceMedia:
return self.url_pattern % service_game[self.api_field]
def get_media_url(self, details):
if self.api_field not in details:
logger.warning("No field '%s' in API game %s", self.api_field, details)
return
if not details[self.api_field]:
return
return self.url_pattern % details[self.api_field]
if self.api_field not in details:
logger.warning("No field '%s' in API game %s", self.api_field, details)
return
if not details[self.api_field]:
return
return self.url_pattern % details[self.api_field]
def get_media_urls(self):
"""Return URLs for icons and logos from a service"""