Skip to content

Commit

Permalink
fuelpump: potentially resolve issues with DRM
Browse files Browse the repository at this point in the history
  • Loading branch information
imLinguin committed May 25, 2024
1 parent 74e3ca9 commit 888df22
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 3 deletions.
45 changes: 45 additions & 0 deletions nile/api/self_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import urllib.parse
import os
from nile.models import manifest
from nile.constants import CONFIG_PATH
from nile.models.hash_pairs import PatchBuilder

class SelfUpdateHandler:
def __init__(self, session, library):
self.session_manager = session
self.library_manager = library

def get_manifest(self):
response = self.session_manager.session.get("https://gaming.amazon.com/api/distribution/v2/public/download/channel/87d38116-4cbf-4af0-a371-a5b498975346")
data = response.json()
return data

def get_sdk(self):
if os.path.exists(os.path.join(CONFIG_PATH, 'SDK')):
return
ag_manifest = self.get_manifest()
url = urllib.parse.urlparse(ag_manifest['downloadUrl'])
url = url._replace(path=url.path + '/manifest.proto')

url = urllib.parse.urlunparse(url)

response = self.session_manager.session.get(url)
raw_manifest = response.content

launcher_manifest = manifest.Manifest()
launcher_manifest.parse(raw_manifest)

for file in launcher_manifest.packages[0].files:
if 'FuelSDK_x64.dll' in file.path or 'AmazonGamesSDK_' in file.path:
url = urllib.parse.urlparse(ag_manifest['downloadUrl'])
url = url._replace(path=url.path + '/files/' + file.hash.value)
url = urllib.parse.urlunparse(url)

response = self.session_manager.session.get(url, stream=True)

filepath = os.path.join(CONFIG_PATH, 'SDK', file.path.replace('\\', os.sep).replace('/', os.sep))
os.makedirs(os.path.dirname(filepath), exist_ok=True)
with open(filepath, 'wb') as filehandle:
for chunk in response.iter_content(1024 * 1024):
filehandle.write(chunk)

6 changes: 4 additions & 2 deletions nile/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from nile.utils.launch import Launcher
from nile.utils.uninstall import Uninstaller
from nile.utils.importer import Importer
from nile.api import authorization, session, library
from nile.api import authorization, session, library, self_update
from nile import constants, version, codename


Expand All @@ -28,6 +28,8 @@ def __init__(
self.logger = logger
self.unknown_arguments = unknown_arguments

self.self_update = self_update.SelfUpdateHandler(self.session, self.library_manager)
self.self_update.get_sdk()
self.__migrate_old_ids()

# Function that migrates installed and manifests from old id to product.id
Expand Down Expand Up @@ -240,7 +242,7 @@ def handle_launch(self):
self.logger.error("Game is not installed")
return

launcher = Launcher(self.config, self.arguments, self.unknown_arguments)
launcher = Launcher(self.config, self.arguments, self.unknown_arguments, matching_game)

launcher.start(found["path"])

Expand Down
24 changes: 23 additions & 1 deletion nile/utils/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import time
import signal
import ctypes
from nile.constants import CONFIG_PATH
from nile.utils.process import Process

class NoMoreChildren(Exception):
Expand Down Expand Up @@ -35,8 +36,9 @@ def parse(cls, game_path, path, unknown_arguments):


class Launcher:
def __init__(self, config_manager, arguments, unknown_arguments):
def __init__(self, config_manager, arguments, unknown_arguments, game):
self.config = config_manager
self.game = game
self.bottle = arguments.bottle
self.wrapper = arguments.wrapper
self.wine_prefix = arguments.wine_prefix
Expand Down Expand Up @@ -132,6 +134,26 @@ def start(self, game_path):
game_path, fuel_path, self.unknown_arguments
)

display_name = self.config.get('user', 'extensions//customer_info//given_name') or ''

sdk_path = os.path.join(CONFIG_PATH, 'SDK', 'Amazon Games Services')
fuel_dir = os.path.join(sdk_path, 'Legacy')
amazon_sdk = os.path.join(sdk_path, 'AmazonGamesSDK')

if sys.platform != 'win32':
fuel_dir = 'Z:' + fuel_dir
amazon_sdk = 'Z:' + amazon_sdk

self.env.update({
'FUEL_DIR': fuel_dir,
'AMAZON_GAMES_SDK_PATH': amazon_sdk,
'AMAZON_GAMES_FUEL_ENTITLEMENT_ID': self.game['id'],
'AMAZON_GAMES_FUEL_PRODUCT_SKU': self.game['product']['sku'],
'AMAZON_GAMES_FUEL_DISPLAY_NAME': display_name
})

print(self.env)

command = list()
if self.wrapper:
splited_wrapper = shlex.split(self.wrapper)
Expand Down

0 comments on commit 888df22

Please sign in to comment.