Giter Site home page Giter Site logo

gog-galaxy-export-script's Introduction

GOG Galaxy 2.0 Export Script

This script helps a user export their GOG Galaxy 2.0 Library.

TL;DR / brief how to use

  1. Install Python 3, through Windows Store or manually if you prefer
  2. Download the source files and unzip it in a directory of your choice
  3. Open the command prompt (Win+R, write cmd and press Enter) and enter the directory you chose with cd /d DIRECTORY, replacing DIRECTORY with the directory in which galaxy_library_export.py resides
  4. Install python's requirements:
    python -m pip install csv natsort
    
  5. Export the CSV with:
    python galaxy_library_export.py
    

By default this scripts export everything it can into the CSV. If you would like to customize the results, read below.

Usage

Through the use of command line parameters, you can decide what data you want exported to the CSV. Some of the options include the list of platforms (--platforms), playtime in minutes (--playtime), developers, publishers, genres and much more. You can read the help manual by invoking the script without parameters, to find an up to date list of all the possible export options.

If you want to use the CSV in a different tool, such as the HTML5 library exporter, you can default to the -a parameter to export everything.

When a different locale wants a different CSV delimiter (such as the Italian), you can manually specify the character to use (-d <character>).

Also, you can manually specify the database location (-i) and the CSV location (-o), instead of using the default ones.

If the CSV has to be read by a Python script, you can use the option --py-lists to export python compatible list strings that can be reconverted in python objects through ast's literal_eval, which avoids several (potentially incorrect) string split/joins.

If you also want to export all available dlcs use the --dlcs-details argument. With that all dlcs are handled as "games" and will be exported with all available infos.

settings.json

The settings.json allows to handle dlcs as game and export them accordingly or treat any release (game, dlc, soundtrack, goodies pack etc.) as dlc of another game, if they are not already linked in the database.

  • TreatDLCAsGame: Aarray of release-keys which should be treated as a game instead of a dlc
    • Used to mark games which are (mistakenly) treated as dlcs by the gog galaxy client as games.
    • All entries with a matching release-key will be exported with all available data.
    • This will not change the link between a dlc and his parent game if it really is a dlc.
  • TreatReleaseAsDLC: Dictionary which maps the releaseKey of a game to a list of dlcs.
    • Used to mark any release which is (mistakenly) treated as a game by the gog galaxy client as dlc.
    • The dlcs specified in the settings.json are joined with the list of dlcs found in the database.
    • TreatReleaseAsDLC is evaluated after TreatDLCAsGame. If a release-key is present in TreatDLCAsGame and also mapped to another release-key with TreatReleaseAsDLC than this release-key is handled as dlc.
    • This will not override the original link between a dlc and it's parent game. If a dlc is mapped to another game it will be present in the dlc list of this game and the original game.

Dependencies

  • Python 3
    • csv
    • natsort

Platform Support

All platforms from the official list are supported. Some are not listed at the moment but should still show up correctly in the output.

Wiki

Check the Wiki tab.

Roadmap

Check the Projects tab.

Contribution

Feel free to add issues and pull requests.

License

This repository is licensed under the MIT License.

gog-galaxy-export-script's People

Contributors

ab1908 avatar cojonuo-git avatar jahire2 avatar janpokorny avatar mabackma avatar retrobit avatar themelmacian avatar toastmonster avatar varstahl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gog-galaxy-export-script's Issues

DLC parser: 'NoneType' object is not iterable

DLC parser breaks by parsing the entry of Shadowrun Returns Deluxe Upgrade: '{"dlcs":null}'.

$ python galaxy_library_export.py -a
Parsing failed on: ('gog_1411891779,epic_d919e78b3fc049678e63df7ff49cf65d', '{"title":"Shadowrun Returns Deluxe Upgrade"}', '{"isModifiedByUser":false,"title":"Shadowrun Returns Deluxe Upgrade"}', '{"summary":"The year is 2054. Magic has returned to the world, awakening powerful creatures of myth and legend. Technology merges with flesh and consciousness. Elves, trolls, orks and dwarves walk among us, while ruthless corporations bleed the world dry. You are a shadowrunner – a mercenary living on the fringes of society, in the shadows of massive corporate arcologies, surviving day-by-day on skill and instinct alone. When the powerful or the desperate need a job done, you get it done… by any means necessary. \\r\\n \\r\\n \\r\\n \\r\\nThe unique cyberpunk-meets-fantasy world of Shadowrun has gained a huge cult following since its creation nearly 25 years ago. Now, creator Jordan Weisman returns to the world of Shadowrun, modernizing this classic game setting as a single player, turn-based tactical RPG. \\r\\n \\r\\n \\r\\n \\r\\nWith the Shadowrun Returns Editor, everyone is empowered to create and share their own stories and campaigns with the Steam Workshop community. You can even explore the entire Shadowrun Returns Seattle campaign in the Editor directly – see how it was built and borrow as much as you need to jump-start your own creations! No advanced coding or art skills are required to create content using the SRR Editor."}', '{"criticsScore":null,"developers":[],"genres":["Role-playing (RPG)","Adventure","Strategy"],"publishers":[],"releaseDate":1374710400,"themes":["Action","Fantasy","Historical","Science fiction"]}', 0, None, '{"dlcs":null}', '{"background":null,"squareIcon":null,"verticalCover":null}')
Traceback (most recent call last):
  File ".../galaxy_library_export.py", line 491, in <module>
    extractData(args)
  File ".../galaxy_library_export.py", line 411, in extractData
    raise e
  File ".../galaxy_library_export.py", line 385, in extractData
    for dlc in jld('dlcs', True):
TypeError: 'NoneType' object is not iterable
$ python --version
Python 3.9.6

Database is from Galaxy Client version 2.0.40.

platformList inaccurate

Products owned in the GOG store are shown as owned in "Placeholder". Products owned on Twitch are usually shown as being owned on additional platforms, example "Twitch,Itch.io" or "Twitch,Itch.io,BlackBerry Games??". Products owned in Humble Bundle are usually shown as being owned on additional platforms, example "Humble Bundle,Nintendo DS" or "Humble Bundle,Steam,Nintendo Entertainment System".

Ids have changed

Hi the org values for gamePieceTypeId are not working.

It worked when I updated them to
dataId1 = 21
dataId2 = 9
titleId1 = 10
titleId2 = 23

I am in NA. Might be a region thing.

Not clear which field is exported: title or originalTitle / meta or originalMeta

Currently it is not clear which title is exported. It can be either "title" or "originalTitle".
Which ever comes first in the sorted list will be exported.
Example:

  • title: "Game A", originalTitle: " Game with an A" => title is exported
  • title "Game Z", originalTitle: "Game with an Z" => originalTitle is exported

I think same can happen with the meta data.
It is already possible to change the release date of a game in the galaxy client. And for genres, developers and publisher there is a tooltip: "coming soon".

@AB1908 @Varstahl
I wanted to discuss the possible solutions before I implement a fix.

Title:
A simple solution would be to separate title and originalTitle. Use title as standard and originalTitle can be added if the user needs it in the export. Or if you prefer the other way around: originalTitle as standard and the (custom)title as optional export.
It's also possible to always export both.

Meta data:

  1. Only export one value
  2. Always export both values. For example releaseDate and originalReleaseDate if --release-date is selected.
  3. User can choose which he wants to export

criticsScore has up to 4 decimal places

Is that how it's stored in the DB? Seems a little excessive. The Galaxy2 GUI shows it as an integer. Perhaps it should be rounded the nearest whole number?

Missing dlcs in export

In the current script the dlcs are not concatenated. As a result it is possible that some dlcs are missing in he exported dlc list.

example:
same game on different platforms:
platform1_gameX: dlcs = []
platform2_gameX: dlcs = [p2_dlc1, p2_dlc2]
platform3_gameX: dlcs = [p3_dlc1, p3_dlc2]

  • The user owns the game on all platforms
  • There is no dlc support on platform1
  • The user owns all dlcs on platform2

If the SQL selects the dlc list from platform1 or platform3 no dlcs are exported.
In the first case the script thinks there is no dlc at all,
in the second case the script can't find the owned dlcs because the wrong list is selected.

Most fields have square brackets and apostrophes around the data

The csv file produced has ['characters'] surrounding most of the fields.

Here is an example that I have transposed for improved formatting.

Header Value
title Alice: Madness Returns
platformList ['Origin', 'Steam']
criticsScore 72
developers ['Spicy Horse Games']
genres ['Adventure', "Hack and slash/Beat 'em up", 'Platform']
publishers ['Electronic Arts']
releaseDate 14/06/2011
themes ['Action', 'Horror']
gameMins 82

Output missing default delimiter

After I managed to get the script working (it's been forever since I used Python so it was a struggle just getting the thing to run on WIndows) I thought I was going crazy when the CSV file wasn't correctly sorting into individual fields, until I realised that when looking at the raw text, the default comma delimiter was missing. If I added the -d to manually specify then it would print the results out correctly.

If it helps I was using Python 3.10 from the Windows store and natsort 8.1.0

Script does not support running on linux because platform detection doesn't even consider it

line 578, in <module>
    'default': defaultDBlocation,
NameError: name 'defaultDBlocation' is not defined

Even though I ran the script explicitly defining path to the database, I got the error because it didn't recognize the platform and couldn't set the default location. So I just hacked it by hardcoding the default location of the database, but I guess it would be nice if the script recognized the correct platform and react accordingly or, at least, don't even set the defaultDBlocation if the script is being run with -i parameter.

command I ran
python galaxy_library_export.py -i /home/user/Desktop/storage/galaxy-2.0.db -o /home/user/Desktop/gog.csv

dirty hack, line 555:

	if platform == "darwin":
		defaultDBlocation = "/Users/Shared/GOG.com/Galaxy/Storage/galaxy-2.0.db"
	# Windows
	elif platform == "win32":
		defaultDBlocation = "C:\\ProgramData\\GOG.com\\Galaxy\\storage\\galaxy-2.0.db"
	#added hack
	defaultDBlocation = "/home/user/Desktop/storage/galaxy-2.0.db

Request / Question: Import & Tags

2 Requests / Questions:

  • Export Tags?
  • Import?

1. Export Tags

Can the script export tags or will you include tags in the near future?
Also other details like images, alternative titles, set installed locations / exe paths etc.?

2. Import

Do you know if it's possible/"ok" to import the exported data back into the client?
Did you test it / do you have information about it?
Do you consider making an importer?

GOG Galaxy 2.0.44.218 broke exporting

GOG Galaxy updated itself to version 2.0.44.218 today and appears to have removed the GameLinks table from the database schema. I see the following error when running the export script now:

Traceback (most recent call last):
  File "galaxy_library_export.py", line 605, in <module>
    extractData(args)
  File "galaxy_library_export.py", line 359, in extractData
    cursor.execute(unique_game_data)
sqlite3.OperationalError: no such table: GameLinks

I last ran the export script against a database created by GOG Galaxy 2.0.43.71 near the end of October 2021 and it was working with no problems. Unfortunately, since GOG Galaxy uses a stub installer which always installs the latest version, I don't see any way to downgrade it as a workaround.

Double game listing bug

Some games are listed twice because of certain factors. For example, Alan Wake has separate release dates for Epic Games Launcher and Steam. I'm not sure if this is intentional to denote different release dates on different platforms but it causes the GROUP BY query to fail as the metadata column is not unique. Any suggestions for fixes are welcome.

How to...

It would be appreciated if you included a simple guide about how to actually use the script. For those who are clueless. You're just assuming everyone who reads the description will understand everything :X

Help Functionality Not Working

Whenever I try to get the help page from the script, I get the following error:

Traceback (most recent call last):
  File "galaxy_library_export.py", line 578, in <module>
    'default': defaultDBlocation,
NameError: name 'defaultDBlocation' is not defined

I've tried this by using python3 galaxy_library_export.py, python3 galaxy_library_export.py -h and python3 galaxy_library_export.py --help. It appears that the argument in galaxy_library_export.py for help isn't set properly. (line 573 for quick lookup)

Unecessary multiple database requests when determining the release type

To determine the release type the script first makes a database request to get the GamePieceTypes,id and than inserts it in the sql script. It would be much more efficient if we just join the GamePieceTypes table to the MasterList and use the type name directly.

I already prepared a fix but I wanted to ask if it is okay if I also change the whole SQL to ISO/ANSI compliant joins?

Export Tags/Scores

Would really appreciate if there was a way to export tags and or scores together with the list of games. I keep a backlog of games in GoG Galaxy and currently there's no way for me to separate the backlogged games from the actually owned/played games because the way I do it within Galaxy is by using tags. Huge thanks in advance!

At least 1 game missing from export

I noticed that my export using the latest release is missing at least one game.

You'll notice in the screenshot below that I have all 5 episodes of "3 out of 10" from Epic Games Store, yet the exported file is missing episode 2, "Foundation 101".

missing game

ModuleNotFoundError: No module named 'natsort'

The current release does not work.

python galaxy_library_export.py

Traceback (most recent call last):
File "galaxy_library_export.py", line 7, in
from natsort import natsorted
ModuleNotFoundError: No module named 'natsort'

How to link the platform to releaseKey from the DB file?

I have been taking a look at the code and want to write a simpler version for myself from scratch with the final objective of generating a random game picker.

After looking through the db file, I have a rough idea on how to get the Title of the game, the tags, release date etc. I do not know how to get the platform. Is there a field in any of the tables that links the platform to the releaseKey? Or are you figuring out the platform using the first few characters of the Release Key?

Game Path

Hi, first off thanks for your work on this script, I'm wondering if it's at all possible to include the launch path? e.g: executable path + launch arguments?

I am a developer but I'm not familure with python so if you can confirm if this is possible then I'm happy to do the leg work, I'd just rather know before I start learning to find out it's not.

Thanks.

Platform not being populated

I ran the script and ended up with a spreadsheet that appears to list all of the games, but the platform column is almost empty. It has a few entries, but the vast majority are blank.

I am on Windows 10, using Python 3.9.1. I did notice that my switches appear to not be honored (using -o c:\temp\gog.csv and it still comes out as gamesdb.csv for instance) so perhaps I am just doing something wrong?

I've attached part of my CSV file if that helps.
games - Copy.zip

Get the "gameId" of GOG games

Hi, I'm sorry if I'm doing this in the wrong place or if someone has already arrived with this same issue, I really didn't find it.

Would it be possible to get the "gameId" of GOG games?

sqlite3.OperationalError

Traceback (most recent call last):
File "galaxy_library_export.py", line 39, in
cursor.execute(owned_game_filtered_data)
sqlite3.OperationalError: near ")": syntax error

list index out of range

Traceback (most recent call last):
File "galaxy_library_export.py", line 52, in
row['title'] = result[1].split('"')[3]
IndexError: list index out of range

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.