mirror of
https://github.com/Novattz/creamlinux-installer.git
synced 2026-01-24 20:32:51 -05:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc4466048e | ||
|
|
917b787a72 | ||
|
|
9645249b05 | ||
|
|
979be97e3e | ||
|
|
01b1404b07 | ||
|
|
3892c58c5d | ||
|
|
8190b656f6 | ||
|
|
f2c3c326c2 | ||
|
|
4d7b888bd5 | ||
|
|
db3ed0e138 | ||
|
|
d91cd08164 |
15
README.md
15
README.md
@@ -6,6 +6,16 @@
|
|||||||
- Automatically installs creamlinux and its components into selected steam games, excluding and handling specific config files.
|
- Automatically installs creamlinux and its components into selected steam games, excluding and handling specific config files.
|
||||||
- Provides a simple cli to navigate and operate the entire process.
|
- Provides a simple cli to navigate and operate the entire process.
|
||||||
|
|
||||||
|
# Demo
|
||||||
|
https://www.youtube.com/watch?v=22LDDUoBvus&ab_channel=Nova
|
||||||
|
|
||||||
|
# To do
|
||||||
|
- Cross reference dlc files and dlc id's. Incase dlc id's and dlc files differ in terms of quantity it will notify the user.
|
||||||
|
- Possibly add functionality to search for dlc files/automatically installing them.
|
||||||
|
- Add the possibility to install cream/smokeapi for games running proton.
|
||||||
|
- Check if the game already has dlc files installed
|
||||||
|
- Gui?
|
||||||
|
|
||||||
# Prerequisites
|
# Prerequisites
|
||||||
- `python 3.x`
|
- `python 3.x`
|
||||||
- `requests` library
|
- `requests` library
|
||||||
@@ -16,8 +26,11 @@
|
|||||||
- Navigate to the directory containing the script.
|
- Navigate to the directory containing the script.
|
||||||
- Run the script using python.
|
- Run the script using python.
|
||||||
```bash
|
```bash
|
||||||
python steam_dlc_fetcher.py
|
python dlc_fetcher.py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Issues?
|
||||||
|
- Open a issue and attach all relevant errors/logs.
|
||||||
|
|
||||||
# Credits
|
# Credits
|
||||||
- [All credits for creamlinux go to its original author and contributors.](https://github.com/anticitizn/creamlinux)
|
- [All credits for creamlinux go to its original author and contributors.](https://github.com/anticitizn/creamlinux)
|
||||||
|
|||||||
276
dlc_fetcher.py
276
dlc_fetcher.py
@@ -5,6 +5,48 @@ import zipfile
|
|||||||
import time
|
import time
|
||||||
import stat
|
import stat
|
||||||
|
|
||||||
|
LOG_FILE = 'script.log'
|
||||||
|
|
||||||
|
def clear_screen():
|
||||||
|
os.system('cls' if os.name == 'nt' else 'clear')
|
||||||
|
|
||||||
|
def fetch_latest_version():
|
||||||
|
try:
|
||||||
|
response = requests.get("https://api.github.com/repos/Novattz/creamlinux-installer/releases/latest")
|
||||||
|
data = response.json()
|
||||||
|
return data['tag_name']
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
log_message(f"Failed to fetch latest version: {str(e)}")
|
||||||
|
return "Unknown"
|
||||||
|
|
||||||
|
def show_header(app_version):
|
||||||
|
clear_screen()
|
||||||
|
cyan = '\033[96m'
|
||||||
|
reset = '\033[0m'
|
||||||
|
print(f"{cyan}")
|
||||||
|
print(r"""
|
||||||
|
_ _ _ _ _ ____ _____ _ ________ _____
|
||||||
|
| | | | \ | | | / __ \ / ____| |/ / ____| __ \
|
||||||
|
| | | | \| | | | | | | | | ' /| |__ | |__) |
|
||||||
|
| | | | . ` | | | | | | | | < | __| | _ /
|
||||||
|
| |__| | |\ | |___| |__| | |____| . \| |____| | \ \
|
||||||
|
\____/|_| \_|______\____/ \_____|_|\_\______|_| \_\
|
||||||
|
|
||||||
|
""")
|
||||||
|
print(f"""
|
||||||
|
> Made by Tickbase
|
||||||
|
> GitHub: https://github.com/Novattz/creamlinux-installer
|
||||||
|
> Version: {app_version}
|
||||||
|
{reset}
|
||||||
|
""")
|
||||||
|
|
||||||
|
app_version = fetch_latest_version()
|
||||||
|
|
||||||
|
def log_message(message):
|
||||||
|
with open(LOG_FILE, 'a') as log_file:
|
||||||
|
log_file.write(f"{message}\n")
|
||||||
|
print(message)
|
||||||
|
|
||||||
def parse_vdf(file_path):
|
def parse_vdf(file_path):
|
||||||
library_paths = []
|
library_paths = []
|
||||||
try:
|
try:
|
||||||
@@ -13,128 +55,168 @@ def parse_vdf(file_path):
|
|||||||
paths = re.findall(r'"path"\s*"(.*?)"', content, re.IGNORECASE)
|
paths = re.findall(r'"path"\s*"(.*?)"', content, re.IGNORECASE)
|
||||||
library_paths.extend([os.path.normpath(path) for path in paths])
|
library_paths.extend([os.path.normpath(path) for path in paths])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to read {file_path}: {str(e)}")
|
log_message(f"Failed to read {file_path}: {str(e)}")
|
||||||
return library_paths
|
return library_paths
|
||||||
|
|
||||||
def find_steam_library_folders():
|
def find_steam_library_folders():
|
||||||
base_paths = [os.path.expanduser('~/.steam/steam'), os.path.expanduser('~/.local/share/Steam'), '/mnt', '/media']
|
base_paths = [
|
||||||
|
os.path.expanduser('~/.steam/steam'),
|
||||||
|
os.path.expanduser('~/.local/share/Steam'),
|
||||||
|
os.path.expanduser('~/home/deck/.steam/steam'),
|
||||||
|
os.path.expanduser('~/home/deck/.local/share/Steam'),
|
||||||
|
'/mnt', '/media',
|
||||||
|
'/run/media/mmcblk0p1/steamapps'
|
||||||
|
]
|
||||||
library_folders = []
|
library_folders = []
|
||||||
for base_path in base_paths:
|
try:
|
||||||
if os.path.exists(base_path):
|
for base_path in base_paths:
|
||||||
for root, dirs, files in os.walk(base_path, topdown=True):
|
if os.path.exists(base_path):
|
||||||
if 'steamapps' in dirs:
|
for root, dirs, files in os.walk(base_path, topdown=True):
|
||||||
steamapps_path = os.path.join(root, 'steamapps')
|
if 'steamapps' in dirs:
|
||||||
library_folders.append(steamapps_path)
|
steamapps_path = os.path.join(root, 'steamapps')
|
||||||
vdf_path = os.path.join(steamapps_path, 'libraryfolders.vdf')
|
library_folders.append(steamapps_path)
|
||||||
if os.path.exists(vdf_path):
|
vdf_path = os.path.join(steamapps_path, 'libraryfolders.vdf')
|
||||||
additional_paths = parse_vdf(vdf_path)
|
if os.path.exists(vdf_path):
|
||||||
for path in additional_paths:
|
additional_paths = parse_vdf(vdf_path)
|
||||||
new_steamapps_path = os.path.join(path, 'steamapps')
|
for path in additional_paths:
|
||||||
if os.path.exists(new_steamapps_path):
|
new_steamapps_path = os.path.join(path, 'steamapps')
|
||||||
library_folders.append(new_steamapps_path)
|
if os.path.exists(new_steamapps_path):
|
||||||
dirs[:] = [] # Prevent further scanning into subdirectories
|
library_folders.append(new_steamapps_path)
|
||||||
|
dirs[:] = [] # Prevent further scanning into subdirectories
|
||||||
|
if not library_folders:
|
||||||
|
raise FileNotFoundError("No Steam library folders found.")
|
||||||
|
except Exception as e:
|
||||||
|
log_message(f"Error finding Steam library folders: {e}")
|
||||||
return library_folders
|
return library_folders
|
||||||
|
|
||||||
def find_steam_apps(library_folders):
|
def find_steam_apps(library_folders):
|
||||||
acf_pattern = re.compile(r'^appmanifest_(\d+)\.acf$')
|
acf_pattern = re.compile(r'^appmanifest_(\d+)\.acf$')
|
||||||
games = {}
|
games = {}
|
||||||
for folder in library_folders:
|
try:
|
||||||
if os.path.exists(folder):
|
for folder in library_folders:
|
||||||
for item in os.listdir(folder):
|
if os.path.exists(folder):
|
||||||
if acf_pattern.match(item):
|
for item in os.listdir(folder):
|
||||||
app_id, game_name, install_dir = parse_acf(os.path.join(folder, item))
|
if acf_pattern.match(item):
|
||||||
if app_id and game_name:
|
try:
|
||||||
install_path = os.path.join(folder, 'common', install_dir)
|
app_id, game_name, install_dir = parse_acf(os.path.join(folder, item))
|
||||||
if os.path.exists(install_path):
|
if app_id and game_name:
|
||||||
cream_installed = 'Cream installed' if 'cream.sh' in os.listdir(install_path) else ''
|
install_path = os.path.join(folder, 'common', install_dir)
|
||||||
games[app_id] = (game_name, cream_installed, install_path)
|
if os.path.exists(install_path):
|
||||||
|
cream_installed = 'Cream installed' if 'cream.sh' in os.listdir(install_path) else ''
|
||||||
|
games[app_id] = (game_name, cream_installed, install_path)
|
||||||
|
except Exception as e:
|
||||||
|
log_message(f"Error parsing {item}: {e}")
|
||||||
|
if not games:
|
||||||
|
raise FileNotFoundError("No Steam games found.")
|
||||||
|
except Exception as e:
|
||||||
|
log_message(f"Error finding Steam apps: {e}")
|
||||||
return games
|
return games
|
||||||
|
|
||||||
def parse_acf(file_path):
|
def parse_acf(file_path):
|
||||||
with open(file_path, 'r', encoding='utf-8') as file:
|
try:
|
||||||
data = file.read()
|
with open(file_path, 'r', encoding='utf-8') as file:
|
||||||
app_id = re.search(r'"appid"\s+"(\d+)"', data)
|
data = file.read()
|
||||||
name = re.search(r'"name"\s+"([^"]+)"', data)
|
app_id = re.search(r'"appid"\s+"(\d+)"', data)
|
||||||
install_dir = re.search(r'"installdir"\s+"([^"]+)"', data)
|
name = re.search(r'"name"\s+"([^"]+)"', data)
|
||||||
return app_id.group(1), name.group(1), install_dir.group(1)
|
install_dir = re.search(r'"installdir"\s+"([^"]+)"', data)
|
||||||
|
return app_id.group(1), name.group(1), install_dir.group(1)
|
||||||
|
except Exception as e:
|
||||||
|
log_message(f"Error reading ACF file {file_path}: {e}")
|
||||||
|
return None, None, None
|
||||||
|
|
||||||
def fetch_dlc_details(app_id):
|
def fetch_dlc_details(app_id):
|
||||||
base_url = f"https://store.steampowered.com/api/appdetails?appids={app_id}"
|
base_url = f"https://store.steampowered.com/api/appdetails?appids={app_id}"
|
||||||
response = requests.get(base_url)
|
try:
|
||||||
data = response.json()
|
response = requests.get(base_url)
|
||||||
if app_id not in data or "data" not in data[app_id]:
|
data = response.json()
|
||||||
print("Error: Unable to fetch game details.")
|
if app_id not in data or "data" not in data[app_id]:
|
||||||
return []
|
log_message("Error: Unable to fetch game details.")
|
||||||
game_data = data[app_id]["data"]
|
return []
|
||||||
dlcs = game_data.get("dlc", [])
|
game_data = data[app_id]["data"]
|
||||||
dlc_details = []
|
dlcs = game_data.get("dlc", [])
|
||||||
for dlc_id in dlcs:
|
dlc_details = []
|
||||||
try:
|
for dlc_id in dlcs:
|
||||||
time.sleep(0.3)
|
try:
|
||||||
dlc_url = f"https://store.steampowered.com/api/appdetails?appids={dlc_id}"
|
time.sleep(0.3)
|
||||||
dlc_response = requests.get(dlc_url)
|
dlc_url = f"https://store.steampowered.com/api/appdetails?appids={dlc_id}"
|
||||||
if dlc_response.status_code == 200:
|
dlc_response = requests.get(dlc_url)
|
||||||
dlc_data = dlc_response.json()
|
if dlc_response.status_code == 200:
|
||||||
if str(dlc_id) in dlc_data and "data" in dlc_data[str(dlc_id)]:
|
dlc_data = dlc_response.json()
|
||||||
dlc_name = dlc_data[str(dlc_id)]["data"].get("name", "Unknown DLC")
|
if str(dlc_id) in dlc_data and "data" in dlc_data[str(dlc_id)]:
|
||||||
dlc_details.append({"appid": dlc_id, "name": dlc_name})
|
dlc_name = dlc_data[str(dlc_id)]["data"].get("name", "Unknown DLC")
|
||||||
|
dlc_details.append({"appid": dlc_id, "name": dlc_name})
|
||||||
|
else:
|
||||||
|
log_message(f"Data missing for DLC {dlc_id}")
|
||||||
|
elif dlc_response.status_code == 429:
|
||||||
|
log_message("Rate limited! Please wait before trying again.")
|
||||||
|
time.sleep(10)
|
||||||
else:
|
else:
|
||||||
print(f"Data missing for DLC {dlc_id}")
|
log_message(f"Failed to fetch details for DLC {dlc_id}, Status Code: {dlc_response.status_code}")
|
||||||
elif dlc_response.status_code == 429:
|
except Exception as e:
|
||||||
print("Rate limited! Please wait before trying again.")
|
log_message(f"Exception for DLC {dlc_id}: {str(e)}")
|
||||||
time.sleep(10)
|
return dlc_details
|
||||||
else:
|
except requests.exceptions.RequestException as e:
|
||||||
print(f"Failed to fetch details for DLC {dlc_id}, Status Code: {dlc_response.status_code}")
|
log_message(f"Failed to fetch DLC details for {app_id}: {e}")
|
||||||
except Exception as e:
|
return []
|
||||||
print(f"Exception for DLC {dlc_id}: {str(e)}")
|
|
||||||
return dlc_details
|
|
||||||
|
|
||||||
def install_files(app_id, game_install_dir, dlcs, game_name):
|
def install_files(app_id, game_install_dir, dlcs, game_name):
|
||||||
zip_url = "https://github.com/anticitizn/creamlinux/releases/latest/download/creamlinux.zip"
|
zip_url = "https://github.com/anticitizn/creamlinux/releases/latest/download/creamlinux.zip"
|
||||||
zip_path = os.path.join(game_install_dir, 'creamlinux.zip')
|
zip_path = os.path.join(game_install_dir, 'creamlinux.zip')
|
||||||
response = requests.get(zip_url)
|
try:
|
||||||
if response.status_code == 200:
|
response = requests.get(zip_url)
|
||||||
with open(zip_path, 'wb') as f:
|
if response.status_code == 200:
|
||||||
f.write(response.content)
|
with open(zip_path, 'wb') as f:
|
||||||
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
f.write(response.content)
|
||||||
zip_ref.extractall(game_install_dir)
|
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
||||||
os.remove(zip_path)
|
zip_ref.extractall(game_install_dir)
|
||||||
|
os.remove(zip_path)
|
||||||
|
|
||||||
cream_sh_path = os.path.join(game_install_dir, 'cream.sh')
|
cream_sh_path = os.path.join(game_install_dir, 'cream.sh')
|
||||||
os.chmod(cream_sh_path, os.stat(cream_sh_path).st_mode | stat.S_IEXEC)
|
os.chmod(cream_sh_path, os.stat(cream_sh_path).st_mode | stat.S_IEXEC)
|
||||||
|
|
||||||
dlc_list = "\n".join([f"{dlc['appid']} = {dlc['name']}" for dlc in dlcs])
|
dlc_list = "\n".join([f"{dlc['appid']} = {dlc['name']}" for dlc in dlcs])
|
||||||
cream_api_path = os.path.join(game_install_dir, 'cream_api.ini')
|
cream_api_path = os.path.join(game_install_dir, 'cream_api.ini')
|
||||||
with open(cream_api_path, 'w') as f:
|
with open(cream_api_path, 'w') as f:
|
||||||
f.write(f"APPID = {app_id}\n[config]\nissubscribedapp_on_false_use_real = true\n[methods]\ndisable_steamapps_issubscribedapp = false\n[dlc]\n{dlc_list}")
|
f.write(f"APPID = {app_id}\n[config]\nissubscribedapp_on_false_use_real = true\n[methods]\ndisable_steamapps_issubscribedapp = false\n[dlc]\n{dlc_list}")
|
||||||
print(f"Custom cream_api.ini has been written to {game_install_dir}.")
|
print(f"Custom cream_api.ini has been written to {game_install_dir}.")
|
||||||
print(f"Installation complete. Set launch options in Steam: 'sh ./cream.sh %command%' for {game_name}.")
|
print(f"Installation complete. Set launch options in Steam: 'sh ./cream.sh %command%' for {game_name}.")
|
||||||
else:
|
else:
|
||||||
print("Failed to download the files needed for installation.")
|
log_message("Failed to download the files needed for installation.")
|
||||||
|
except Exception as e:
|
||||||
|
log_message(f"Failed to install files for {game_name}: {e}")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
library_folders = find_steam_library_folders()
|
show_header(app_version)
|
||||||
games = find_steam_apps(library_folders)
|
try:
|
||||||
if games:
|
library_folders = find_steam_library_folders()
|
||||||
print("Select the game for which you want to fetch DLCs:")
|
games = find_steam_apps(library_folders)
|
||||||
games_list = list(games.items())
|
if games:
|
||||||
GREEN = '\033[92m'
|
print("Select the game for which you want to fetch DLCs:")
|
||||||
RESET = '\033[0m'
|
games_list = list(games.items())
|
||||||
for idx, (app_id, (name, cream_status, _)) in enumerate(games_list, 1):
|
GREEN = '\033[92m'
|
||||||
if cream_status:
|
RESET = '\033[0m'
|
||||||
print(f"{idx}. {GREEN}{name} (App ID: {app_id}) - Cream installed{RESET}")
|
for idx, (app_id, (name, cream_status, _)) in enumerate(games_list, 1):
|
||||||
|
if cream_status:
|
||||||
|
print(f"{idx}. {GREEN}{name} (App ID: {app_id}) - Cream installed{RESET}")
|
||||||
|
else:
|
||||||
|
print(f"{idx}. {name} (App ID: {app_id})")
|
||||||
|
|
||||||
|
choice = int(input("Enter the number of the game: ")) - 1
|
||||||
|
if choice < 0 or choice >= len(games_list):
|
||||||
|
raise ValueError("Invalid selection.")
|
||||||
|
selected_app_id, (selected_game_name, _, selected_install_dir) = games_list[choice]
|
||||||
|
print(f"You selected: {selected_game_name} (App ID: {selected_app_id})")
|
||||||
|
|
||||||
|
dlcs = fetch_dlc_details(selected_app_id)
|
||||||
|
if dlcs:
|
||||||
|
print("DLC IDs found:", [dlc['appid'] for dlc in dlcs]) # Only print app IDs for clarity
|
||||||
|
install_files(selected_app_id, selected_install_dir, dlcs, selected_game_name)
|
||||||
else:
|
else:
|
||||||
print(f"{idx}. {name} (App ID: {app_id})")
|
print("No DLCs found for the selected game.")
|
||||||
|
else:
|
||||||
choice = int(input("Enter the number of the game: ")) - 1
|
print("No Steam games found on this computer or connected drives.")
|
||||||
selected_app_id, (selected_game_name, _, selected_install_dir) = games_list[choice]
|
except Exception as e:
|
||||||
print(f"You selected: {selected_game_name} (App ID: {selected_app_id})")
|
log_message(f"An error occurred: {e}")
|
||||||
|
|
||||||
dlcs = fetch_dlc_details(selected_app_id)
|
|
||||||
print("DLC IDs found:", [dlc['appid'] for dlc in dlcs]) # Only print app IDs for clarity
|
|
||||||
install_files(selected_app_id, selected_install_dir, dlcs, selected_game_name)
|
|
||||||
else:
|
|
||||||
print("No Steam games found on this computer or connected drives.")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user