[game-data-packager] 01/01: make-template: read GOG downloader id from lgogdownloader cache

Alexandre Detiste detiste-guest at moszumanska.debian.org
Thu Sep 17 08:44:17 UTC 2015


This is an automated email from the git hooks/post-receive script.

detiste-guest pushed a commit to branch master
in repository game-data-packager.

commit 2baddd9a4507cb6503882fef71ab84628ffb07e8
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Thu Sep 17 10:43:36 2015 +0200

    make-template: read GOG downloader id from lgogdownloader cache
---
 game_data_packager/gog.py           | 13 +++++++++++++
 game_data_packager/make_template.py |  6 ++++++
 2 files changed, 19 insertions(+)

diff --git a/game_data_packager/gog.py b/game_data_packager/gog.py
index c2e0b11..6f04597 100644
--- a/game_data_packager/gog.py
+++ b/game_data_packager/gog.py
@@ -62,4 +62,17 @@ class Gog:
                     return True
             return False
 
+    def get_id_from_archive(self, archive):
+        cache = os.path.expanduser('~/.cache/lgogdownloader/gamedetails.json')
+        if not os.path.isfile(cache):
+            return None
+
+        archive = os.path.basename(archive)
+
+        data = json.load(open(cache, encoding='utf-8'))
+        for game in data['games']:
+            for installer in game['installers']:
+                if installer['path'].endswith(archive):
+                    return game['gamename']
+
 GOG = Gog()
diff --git a/game_data_packager/make_template.py b/game_data_packager/make_template.py
index bcb5662..17d4f3f 100644
--- a/game_data_packager/make_template.py
+++ b/game_data_packager/make_template.py
@@ -29,6 +29,7 @@ from debian.deb822 import Deb822
 import yaml
 
 from . import HashedFile
+from .gog import GOG
 from .steam import parse_acf
 from .util import which
 
@@ -88,6 +89,7 @@ class GameData(object):
         self.try_repack_from = None
         self.plugin = None
         self.gog_url = None
+        self.gog_game = None
 
         self.data = dict()
         self.install = set()
@@ -205,6 +207,8 @@ class GameData(object):
             self.package['install_to'] = 'usr/share/games/' + game
 
     def add_one_innoextract(self,exe):
+        self.gog_game = GOG.get_id_from_archive(exe)
+
         tmp = tempfile.mkdtemp(prefix='gdptmp.')
 
         command = ['innoextract', os.path.realpath(exe)]
@@ -359,6 +363,8 @@ class GameData(object):
             print('plugin: %s' % self.plugin)
         if self.gog_url:
             print('gog:\n  url: %s' % self.gog_url)
+        if self.gog_game:
+            print('gog:\n  url: FIXME\n  game: %s' % self.gog_game)
 
         print('')
         yaml.safe_dump(self.data, stream=sys.stdout, default_flow_style=False)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git



More information about the Pkg-games-commits mailing list