forked from 07th-mod/python-patcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
steamGridExtractor.py
75 lines (61 loc) · 2.79 KB
/
steamGridExtractor.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
from __future__ import unicode_literals
import common
import glob
import shutil
import os
import commandLineParser
def getSteamPath():
try:
if common.Globals.IS_LINUX:
# Newer versions of Steam use this path
altSteamPath = os.path.expanduser("~/.steam/steam")
if os.path.exists(altSteamPath):
return altSteamPath
# Older versions of Steam and the Steam Deck use this path
return os.path.expanduser("~/.local/share/Steam/")
elif common.Globals.IS_WINDOWS:
try:
import winreg
except ImportError:
import _winreg as winreg
return winreg.QueryValueEx(
winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Valve\Steam"),
"SteamPath",
)[0]
elif common.Globals.IS_MAC:
return os.path.expanduser('~/Library/Application Support/Steam')
else:
return None
except:
return None
def getUserDataFolders():
steamPath = getSteamPath()
print("steamGridExtractor: Attempting to install steamgrid icons to [{}]".format(steamPath))
if steamPath:
if not os.path.exists(steamPath):
print("steamGridExtractor: WARNING: steamPath [{}] does not exist! steamGrid extraction will probably fail!".format(steamPath))
return glob.glob(
os.path.join(steamPath, "userdata", "**", "config"), recursive=True
)
else:
return None
def extractSteamGrid(downloadDir):
try:
userDataFolders = getUserDataFolders()
commandLineParser.printSeventhModStatusUpdate(98, "Downloading and Extracting Steam Grid")
print("Downloading and Extracting Steam Grid Icons to {}".format(userDataFolders))
downloaderAndExtractor = common.DownloaderAndExtractor(modFileList=[],
downloadTempDir=downloadDir,
extractionDir=downloadDir,
supressDownloadStatus=True)
downloaderAndExtractor.addItemManually(url="https://07th-mod.com/installer/steamgrid/higumi-steamgrid.zip",
extractionDir=downloadDir)
downloaderAndExtractor.download()
# Extract to each steam user's data folder (steam has one folder per user)
if userDataFolders:
for i in userDataFolders:
shutil.unpack_archive(os.path.join(downloadDir, "higumi-steamgrid.zip"), i)
else:
print("steamGridExtractor: WARNING: not extracting steamgrid icons as no steam user data folders found")
except Exception as e:
print("Steamgrid Installation Failed: {}".format(e))