This repository has been archived by the owner on May 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathlistinstalled.py
104 lines (74 loc) · 3.49 KB
/
listinstalled.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#List installed games
import os, json, logging
from func import configpath
from func.gameName import rspchar
from func.createlaunchfile import createlaunchfile
from func.steam import *
from func import settings
#If system is Steam Deck, add to Steam (if enabled) or add to Steam script
def AddToSteam(gamename):
if "deck" in os.path.expanduser("~") and settings.enable_autoaddtosteam:
addtosteam(gamename)
else:
addtoscript(gamename)
def listinstalled():
#EPIC GAMES LIBRARY
#------------------------------------------------------------------------------------
if os.path.exists(configpath.legendaryinstalledpath) and settings.enable_epic:
#Convert legendary json to dict
with open(configpath.legendaryinstalledpath, encoding='utf-8') as l:
installed = json.load(l)
#Games' AppNames stored in list
installedkeyarray = list(installed.keys())
#Proceed to making launch files
logging.info("Done! Now creating launch files for your Epic Games library ...")
for i in installedkeyarray:
#Make sure the entries are games, not DLC
if installed[i]["is_dlc"] == False:
#Removing special characters from the game name (Steam issue)
gamename = rspchar(installed[i]["title"])
#Print current action
logging.info(gamename + " [" + i + "]...") # installed[i] = game's name, i = game's appname
#Pointing to the game's json file
gamejson = configpath.gamesjsonpath + "/" + i + ".json"
#Preparing launch file
createlaunchfile(gamename, i, gamejson, "epic") # gamename, appname, game's json file path
#Prepare adding game to Steam or AddToSteam script
AddToSteam(gamename)
else:
logging.warning("Creating scripts for Epic games is disabled in settings.config")
#GOG LIBRARY
#------------------------------------------------------------------------------------
if os.path.exists(configpath.goginstalledpath) and settings.enable_gog:
#Convert both json to dict
with open(configpath.goginstalledpath, encoding='utf-8') as l:
goginstalled = json.load(l)
with open(configpath.goglibrarypath, encoding='utf-8') as p:
goglibrary = json.load(p)
#Stored as list
goginstalledkeyarray = list(goginstalled['installed'])
goglibrarykeyarray = list(goglibrary['games'])
#Proceed to making launch files
logging.info("Done! Now creating launch files for your GOG library ...")
for i in goginstalledkeyarray:
for j in goglibrarykeyarray:
if i['appName'] == j['app_name'] and i['is_dlc'] == False:
#Removing special characters from the game name (Steam issue)
gamename = rspchar(j['title'])
#Print current action
logging.info(gamename + " [" + i['appName'] + "]...")
#Pointing to the game's json file
gamejson = configpath.gamesjsonpath + "/" + j['app_name'] + ".json"
#Check if game is linux or windows
if i['platform'] == "linux":
gametype = "gog-linux"
else:
gametype = "gog-win"
#Preparing launch file
createlaunchfile(gamename, j['app_name'], gamejson, gametype) # gamename, appname, game's json file path
#Prepare adding game to Steam or AddToSteam script
AddToSteam(gamename)
else:
logging.warning("Creating scripts for GOG games is disabled in settings.config")
#END OF THE PROGRAM
logging.info("Process finished. Launch scripts stored in GameFiles folder.")