Implement a GOG GALAXY 2.1 integration plugin
masterTo create an integration, inherit from the galaxy.api.plugin.Plugin class. The GOG GALAXY client calls specific methods on your plugin at appropriate times.
Minimum Requirements: You must override the following two asynchronous methods:
authenticate(self, stored_credentials=None): Returns anAuthenticationobject.get_owned_games(self): Returns a list ofGameobjects.
Error Handling:
Methods can raise exceptions that inherit from galaxy.api.jsonrpc.ApplicationError.
Communication:
You can send notifications back to the client, for example using galaxy.api.plugin.Plugin.update_local_game_status.
import sys
from galaxy.api.plugin import Plugin, create_and_run_plugin
from galaxy.api.consts import Platform
from galaxy.api.types import Authentication, Game, LicenseInfo, LicenseType
class PluginExample(Plugin):
def __init__(self, reader, writer, token):
super().__init__(
Platform.Test, # choose platform from available list
"0.1", # version
reader,
writer,
token
)
# required
async def authenticate(self, stored_credentials=None):
return Authentication('test_user_id', 'Test User Name')
# required
async def get_owned_games(self):
return [
Game('test', 'The Test', None, LicenseInfo(LicenseType.SinglePurchase))
]
def main():
create_and_run_plugin(PluginExample, sys.argv)
# run plugin event loop
if __name__ == "__main__":
main()