mirror of
https://github.com/Novattz/creamlinux-installer.git
synced 2026-01-24 20:32:51 -05:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b9e3fd350 | ||
|
|
dab8787f1d | ||
|
|
723c5873b5 | ||
|
|
649abe709a | ||
|
|
41f8e80df1 | ||
|
|
5a3fafac49 | ||
|
|
a2d081d3b6 | ||
|
|
a13a56cbc3 |
26
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
26
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: "[BUG]"
|
||||
labels: bug
|
||||
assignees: Novattz
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
- A clear and concise description of what the bug is.
|
||||
|
||||
**Terminal output**
|
||||
- Copy and paste the entire terminal output when running the script.
|
||||
|
||||
**Log File Output**
|
||||
- If the script logged any errors, attach the log file **`script.log`** to this issue.
|
||||
|
||||
**Debug Output**
|
||||
- Run the script with the **`--debug`** argument and attach the log file **`debug_script.log`** to this issue.
|
||||
|
||||
**Steam library path**
|
||||
- Provide the path where your steam library is.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: "[ Feature Request ]"
|
||||
labels: enhancement
|
||||
assignees: Novattz
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -30,6 +30,7 @@ git clone https://github.com/Novattz/creamlinux-installer;cd creamlinux-installe
|
||||
- [ ] Add the possibility to install cream/smokeapi for games running proton.
|
||||
- [ ] Check if the game already has dlc files installed
|
||||
- [ ] Gui?
|
||||
- [ ] Add checker for configs already applied to games. (i.e script will check for new dlc id's for already applied games.)
|
||||
|
||||
### Issues?
|
||||
- Open a issue and attach all relevant errors/logs.
|
||||
|
||||
131
dlc_fetcher.py
131
dlc_fetcher.py
@@ -6,21 +6,36 @@ import time
|
||||
import stat
|
||||
import subprocess
|
||||
import psutil
|
||||
from collections import defaultdict
|
||||
import logging
|
||||
import argparse
|
||||
|
||||
LOG_FILE = 'script.log'
|
||||
DEBUG_FILE = 'debug_script.log'
|
||||
TIMEOUT = 180 # Timeout in seconds (3 minutes)
|
||||
|
||||
def setup_logging(debug):
|
||||
log_format = '%(asctime)s [%(levelname)s] %(message)s'
|
||||
date_format = '%m-%d %H:%M:%S'
|
||||
if debug:
|
||||
logging.basicConfig(filename=DEBUG_FILE, level=logging.DEBUG, format=log_format, datefmt=date_format)
|
||||
else:
|
||||
logging.basicConfig(filename=LOG_FILE, level=logging.ERROR, format=log_format, datefmt=date_format)
|
||||
|
||||
def clear_screen():
|
||||
os.system('cls' if os.name == 'nt' else 'clear')
|
||||
|
||||
def log_error(message):
|
||||
timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
|
||||
with open(LOG_FILE, 'a') as log_file:
|
||||
log_file.write(f"[{timestamp}] {message}\n")
|
||||
logging.error(message)
|
||||
print(message)
|
||||
|
||||
def log_debug(message):
|
||||
logging.debug(message)
|
||||
|
||||
def read_steam_registry():
|
||||
registry_path = os.path.expanduser('~/.steam/registry.vdf')
|
||||
if os.path.exists(registry_path):
|
||||
log_debug(f"Found Steam registry file: {registry_path}")
|
||||
with open(registry_path, 'r') as f:
|
||||
content = f.read()
|
||||
install_path = re.search(r'"InstallPath"\s*"([^"]+)"', content)
|
||||
@@ -37,9 +52,10 @@ def fetch_latest_version():
|
||||
log_error(f"Failed to fetch latest version: {str(e)}")
|
||||
return "Unknown"
|
||||
|
||||
def show_header(app_version):
|
||||
def show_header(app_version, debug_mode):
|
||||
clear_screen()
|
||||
cyan = '\033[96m'
|
||||
red = '\033[91m'
|
||||
reset = '\033[0m'
|
||||
print(f"{cyan}")
|
||||
print(r"""
|
||||
@@ -57,8 +73,12 @@ def show_header(app_version):
|
||||
> Version: {app_version}
|
||||
{reset}
|
||||
""")
|
||||
if debug_mode:
|
||||
print(f"{red} [Running in DEBUG mode]{reset}\n")
|
||||
print()
|
||||
|
||||
app_version = fetch_latest_version()
|
||||
#app_version = "TESTING / LETS NOT OVERLOAD GITHUB FOR NO REASON"
|
||||
|
||||
def parse_vdf(file_path):
|
||||
library_paths = []
|
||||
@@ -81,47 +101,70 @@ def find_steam_binary():
|
||||
log_error(f"Failed to locate steam binary: {str(e)}")
|
||||
return None
|
||||
|
||||
def find_steam_library_folders():
|
||||
steam_binary_path = find_steam_binary()
|
||||
base_paths = [
|
||||
def find_steam_library_folders(manual_path=""):
|
||||
search_list = [
|
||||
# Default
|
||||
os.path.expanduser('~/.steam/steam'),
|
||||
os.path.expanduser('~/.local/share/Steam'),
|
||||
|
||||
# Steam Deck
|
||||
os.path.expanduser('/home/deck/.steam/steam'),
|
||||
os.path.expanduser('/home/deck/.local/share/Steam'),
|
||||
'/mnt', '/media',
|
||||
'/run/media/mmcblk0p1/steamapps'
|
||||
]
|
||||
if steam_binary_path:
|
||||
base_paths.append(steam_binary_path)
|
||||
|
||||
steam_install_path = read_steam_registry()
|
||||
if steam_install_path:
|
||||
base_paths.append(steam_install_path)
|
||||
# Others
|
||||
'/mnt/Jogos/Steam',
|
||||
'/run/media/mmcblk0p1',
|
||||
|
||||
# Flatpak
|
||||
os.path.expanduser('~/.var/app/com.valvesoftware.Steam/.local/share/Steam'),
|
||||
os.path.expanduser('~/.var/app/com.valvesoftware.Steam/data/Steam/steamapps/common')
|
||||
]
|
||||
|
||||
library_folders = []
|
||||
scanned_paths = []
|
||||
try:
|
||||
for base_path in base_paths:
|
||||
if os.path.exists(base_path):
|
||||
for root, dirs, files in os.walk(base_path, topdown=True, followlinks=True):
|
||||
scanned_paths.append(root)
|
||||
if 'steamapps' in dirs:
|
||||
steamapps_path = os.path.join(root, 'steamapps')
|
||||
if manual_path != "" and manual_path != None:
|
||||
log_debug(f"Manual game path set to \"{manual_path}\" skipping path lookup")
|
||||
library_folders.append(manual_path)
|
||||
|
||||
else:
|
||||
steam_binary_path = find_steam_binary()
|
||||
if steam_binary_path and steam_binary_path not in search_list:
|
||||
log_debug(f"Found Steam Binary path! adding it to search paths: {steam_binary_path}")
|
||||
search_list.append(steam_binary_path)
|
||||
|
||||
steam_install_path = read_steam_registry()
|
||||
if steam_install_path and steam_install_path not in search_list:
|
||||
log_debug(f"Found Steam Binary path! adding it to search paths: {steam_install_path}")
|
||||
search_list.append(steam_install_path)
|
||||
|
||||
log_debug(f"Paths that will be searched: {search_list}")
|
||||
|
||||
for search_path in search_list:
|
||||
if os.path.exists(search_path):
|
||||
log_debug(f"Scanning path: {search_path}")
|
||||
|
||||
steamapps_path = str(os.path.normpath(f"{search_path}/steamapps"))
|
||||
if os.path.exists(steamapps_path):
|
||||
library_folders.append(steamapps_path)
|
||||
log_debug(f"Found steamapps folder: {steamapps_path}")
|
||||
|
||||
vdf_path = os.path.join(steamapps_path, 'libraryfolders.vdf')
|
||||
if os.path.exists(vdf_path):
|
||||
log_debug(f"Found libraryfolders.vdf: {vdf_path}")
|
||||
additional_paths = parse_vdf(vdf_path)
|
||||
for path in additional_paths:
|
||||
new_steamapps_path = os.path.join(path, 'steamapps')
|
||||
if os.path.exists(new_steamapps_path):
|
||||
library_folders.append(new_steamapps_path)
|
||||
dirs[:] = [] # Prevent further scanning into subdirectories
|
||||
if not library_folders:
|
||||
raise FileNotFoundError("No Steam library folders found.")
|
||||
log_debug(f"Added additional steamapps folder: {new_steamapps_path}")
|
||||
|
||||
if not library_folders:
|
||||
raise FileNotFoundError("No Steam library folders found.")
|
||||
log_debug(f"Total Steam library folders found: {len(library_folders)}")
|
||||
except Exception as e:
|
||||
log_error(f"Error finding Steam library folders: {e}")
|
||||
log_error("Scanned paths:")
|
||||
for path in scanned_paths:
|
||||
for path in search_list:
|
||||
log_error(f" - {path}")
|
||||
return library_folders
|
||||
|
||||
@@ -129,12 +172,20 @@ def find_steam_apps(library_folders):
|
||||
acf_pattern = re.compile(r'^appmanifest_(\d+)\.acf$')
|
||||
games = {}
|
||||
scanned_folders = []
|
||||
start_time = time.time()
|
||||
|
||||
try:
|
||||
for folder in library_folders:
|
||||
if time.time() - start_time > TIMEOUT:
|
||||
log_error("Script timeout reached. Stopping Steam app scan.")
|
||||
return games
|
||||
scanned_folders.append(folder)
|
||||
if os.path.exists(folder):
|
||||
log_debug(f"Scanning folder for ACF files: {folder}")
|
||||
acf_count = 0
|
||||
for item in os.listdir(folder):
|
||||
if acf_pattern.match(item):
|
||||
acf_count += 1
|
||||
try:
|
||||
app_id, game_name, install_dir = parse_acf(os.path.join(folder, item))
|
||||
if app_id and game_name:
|
||||
@@ -142,15 +193,20 @@ def find_steam_apps(library_folders):
|
||||
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)
|
||||
log_debug(f"Found game: {game_name} (App ID: {app_id})")
|
||||
except Exception as e:
|
||||
log_error(f"Error parsing {item}: {e}")
|
||||
log_debug(f"Found {acf_count} ACF files in {folder}")
|
||||
if not games:
|
||||
raise FileNotFoundError("No Steam games found.")
|
||||
log_debug(f"Total games found: {len(games)}")
|
||||
except Exception as e:
|
||||
log_error(f"Error finding Steam apps: {e}")
|
||||
|
||||
log_error("Scanned folders:")
|
||||
for folder in scanned_folders:
|
||||
log_error(f" - {folder}")
|
||||
|
||||
return games
|
||||
|
||||
def parse_acf(file_path):
|
||||
@@ -227,9 +283,27 @@ def install_files(app_id, game_install_dir, dlcs, game_name):
|
||||
log_error(f"Failed to install files for {game_name}: {e}")
|
||||
|
||||
def main():
|
||||
show_header(app_version)
|
||||
parser = argparse.ArgumentParser(description="Steam DLC Fetcher")
|
||||
parser.add_argument("--manual", metavar='steamapps_path', help="Sets the steamapps path for faster operation", required=False)
|
||||
parser.add_argument("--debug", action="store_true", help="Enable debug logging")
|
||||
args = parser.parse_args()
|
||||
|
||||
setup_logging(args.debug)
|
||||
show_header(app_version, args.debug)
|
||||
|
||||
try:
|
||||
library_folders = find_steam_library_folders()
|
||||
library_folders = find_steam_library_folders(args.manual)
|
||||
if library_folders == [] or library_folders == None:
|
||||
print("Falling back to Manual Method since no library folder was found")
|
||||
steamapps_path = input("Steamapps Path: ")
|
||||
|
||||
if len(steamapps_path) > 3:
|
||||
library_folders = [ steamapps_path ]
|
||||
|
||||
else:
|
||||
print("Invalid path! Closing the program...")
|
||||
return
|
||||
|
||||
games = find_steam_apps(library_folders)
|
||||
if games:
|
||||
print("Select the game for which you want to fetch DLCs:")
|
||||
@@ -257,6 +331,7 @@ def main():
|
||||
else:
|
||||
print("No Steam games found on this computer or connected drives.")
|
||||
except Exception as e:
|
||||
logging.exception("An error occurred:")
|
||||
log_error(f"An error occurred: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user