mirror of
https://github.com/Novattz/creamlinux-installer.git
synced 2026-01-29 06:42:51 -05:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9d418805f | ||
|
|
c99d747642 | ||
|
|
2a94f19719 |
@@ -11,6 +11,7 @@
|
|||||||
- `python 3.x`
|
- `python 3.x`
|
||||||
- `requests` library
|
- `requests` library
|
||||||
- `zipfile` library
|
- `zipfile` library
|
||||||
|
- `tqdm` >=4.65.0
|
||||||
|
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|||||||
153
dlc_fetcher.py
153
dlc_fetcher.py
@@ -10,6 +10,7 @@ import logging
|
|||||||
import argparse
|
import argparse
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
import shutil
|
||||||
|
|
||||||
LOG_FILE = 'script.log'
|
LOG_FILE = 'script.log'
|
||||||
DEBUG_FILE = 'debug_script.log'
|
DEBUG_FILE = 'debug_script.log'
|
||||||
@@ -44,6 +45,23 @@ def read_steam_registry():
|
|||||||
return install_path.group(1)
|
return install_path.group(1)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def check_requirements():
|
||||||
|
required_commands = ['which', 'steam']
|
||||||
|
required_packages = ['requests', 'tqdm']
|
||||||
|
|
||||||
|
for cmd in required_commands:
|
||||||
|
if not subprocess.run(['which', cmd], capture_output=True).returncode == 0:
|
||||||
|
print(f"Missing required command: {cmd}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
for package in required_packages:
|
||||||
|
try:
|
||||||
|
__import__(package)
|
||||||
|
except ImportError:
|
||||||
|
print(f"Missing required package: {package}")
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def fetch_latest_version():
|
def fetch_latest_version():
|
||||||
try:
|
try:
|
||||||
response = requests.get("https://api.github.com/repos/Novattz/creamlinux-installer/releases/latest")
|
response = requests.get("https://api.github.com/repos/Novattz/creamlinux-installer/releases/latest")
|
||||||
@@ -81,6 +99,26 @@ def show_header(app_version, debug_mode):
|
|||||||
app_version = fetch_latest_version()
|
app_version = fetch_latest_version()
|
||||||
#app_version = "TESTING / LETS NOT OVERLOAD GITHUB FOR NO REASON"
|
#app_version = "TESTING / LETS NOT OVERLOAD GITHUB FOR NO REASON"
|
||||||
|
|
||||||
|
def filter_games(games_list, search_term):
|
||||||
|
filtered = [(idx, item) for idx, item in enumerate(games_list)
|
||||||
|
if search_term.lower() in item[1][0].lower()]
|
||||||
|
if not filtered:
|
||||||
|
print("No games found matching your search.")
|
||||||
|
return filtered
|
||||||
|
|
||||||
|
def select_multiple_games(games_list):
|
||||||
|
while True:
|
||||||
|
selections = input("Enter game numbers (comma-separated) or 'all': ").strip()
|
||||||
|
try:
|
||||||
|
if selections.lower() == 'all':
|
||||||
|
return list(range(len(games_list)))
|
||||||
|
numbers = [int(x.strip()) - 1 for x in selections.split(',')]
|
||||||
|
if all(0 <= n < len(games_list) for n in numbers):
|
||||||
|
return numbers
|
||||||
|
print("Some selections were out of range. Please try again.")
|
||||||
|
except ValueError:
|
||||||
|
print("Invalid input. Please enter numbers separated by commas.")
|
||||||
|
|
||||||
def parse_vdf(file_path):
|
def parse_vdf(file_path):
|
||||||
library_paths = []
|
library_paths = []
|
||||||
try:
|
try:
|
||||||
@@ -129,10 +167,12 @@ def find_steam_library_folders(manual_path=""):
|
|||||||
else:
|
else:
|
||||||
steam_binary_path = find_steam_binary()
|
steam_binary_path = find_steam_binary()
|
||||||
if steam_binary_path and steam_binary_path not in search_list:
|
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)
|
search_list.append(steam_binary_path)
|
||||||
|
|
||||||
steam_install_path = read_steam_registry()
|
steam_install_path = read_steam_registry()
|
||||||
if steam_install_path and steam_install_path not in search_list:
|
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)
|
search_list.append(steam_install_path)
|
||||||
|
|
||||||
log_debug(f"Paths that will be searched: {search_list}")
|
log_debug(f"Paths that will be searched: {search_list}")
|
||||||
@@ -157,6 +197,7 @@ def find_steam_library_folders(manual_path=""):
|
|||||||
|
|
||||||
if not library_folders:
|
if not library_folders:
|
||||||
raise FileNotFoundError("No Steam library folders found.")
|
raise FileNotFoundError("No Steam library folders found.")
|
||||||
|
log_debug(f"Total Steam library folders found: {len(library_folders)}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log_error(f"Error finding Steam library folders: {e}")
|
log_error(f"Error finding Steam library folders: {e}")
|
||||||
log_error("Scanned paths:")
|
log_error("Scanned paths:")
|
||||||
@@ -183,19 +224,29 @@ def find_steam_apps(library_folders):
|
|||||||
futures = []
|
futures = []
|
||||||
for folder in library_folders:
|
for folder in library_folders:
|
||||||
if os.path.exists(folder):
|
if os.path.exists(folder):
|
||||||
for item in os.listdir(folder):
|
log_debug(f"Scanning folder for ACF files: {folder}")
|
||||||
if acf_pattern.match(item):
|
folder_items = os.listdir(folder)
|
||||||
futures.append(
|
acf_count = 0
|
||||||
executor.submit(process_acf_file, folder, item)
|
with tqdm(total=len(folder_items), desc=f"Scanning {os.path.basename(folder)}") as pbar:
|
||||||
)
|
for item in folder_items:
|
||||||
|
if acf_pattern.match(item):
|
||||||
|
acf_count += 1
|
||||||
|
futures.append(executor.submit(process_acf_file, folder, item))
|
||||||
|
pbar.update(1)
|
||||||
|
log_debug(f"Found {acf_count} ACF files in {folder}")
|
||||||
|
|
||||||
for future in futures:
|
for future in futures:
|
||||||
result = future.result()
|
result = future.result()
|
||||||
if result:
|
if result:
|
||||||
app_id, game_name, install_path = result
|
app_id, game_name, install_path = result
|
||||||
cream_installed = 'Cream installed' if os.path.exists(os.path.join(install_path, 'cream.sh')) else ''
|
cream_installed = 'Cream installed' if os.path.exists(os.path.join(install_path, 'cream.sh')) else ''
|
||||||
|
log_debug(f"Found game: {game_name} (App ID: {app_id})")
|
||||||
games[app_id] = (game_name, cream_installed, install_path)
|
games[app_id] = (game_name, cream_installed, install_path)
|
||||||
|
|
||||||
|
if not games:
|
||||||
|
log_error("No Steam games found.")
|
||||||
|
log_debug(f"Total games found: {len(games)}")
|
||||||
|
|
||||||
return games
|
return games
|
||||||
|
|
||||||
def parse_acf(file_path):
|
def parse_acf(file_path):
|
||||||
@@ -248,25 +299,37 @@ def fetch_dlc_details(app_id):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
def install_files(app_id, game_install_dir, dlcs, game_name):
|
def install_files(app_id, game_install_dir, dlcs, game_name):
|
||||||
|
if dlcs:
|
||||||
|
print("\nFound DLCs:")
|
||||||
|
for idx, dlc in enumerate(dlcs, 1):
|
||||||
|
print(f"{idx}. {dlc['name']} (ID: {dlc['appid']})")
|
||||||
|
if input("\nProceed with installation? (Y/n): ").lower() != 'n':
|
||||||
|
return
|
||||||
GREEN = '\033[92m'
|
GREEN = '\033[92m'
|
||||||
YELLOW = '\033[93m'
|
YELLOW = '\033[93m'
|
||||||
RESET = '\033[0m'
|
RESET = '\033[0m'
|
||||||
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')
|
||||||
try:
|
try:
|
||||||
|
log_debug(f"Downloading creamlinux.zip from {zip_url}")
|
||||||
response = requests.get(zip_url)
|
response = requests.get(zip_url)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
|
log_debug("Successfully downloaded creamlinux.zip")
|
||||||
with open(zip_path, 'wb') as f:
|
with open(zip_path, 'wb') as f:
|
||||||
f.write(response.content)
|
f.write(response.content)
|
||||||
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
||||||
|
log_debug(f"Extracting files to {game_install_dir}")
|
||||||
zip_ref.extractall(game_install_dir)
|
zip_ref.extractall(game_install_dir)
|
||||||
os.remove(zip_path)
|
os.remove(zip_path)
|
||||||
|
log_debug("Removed temporary zip file")
|
||||||
|
|
||||||
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)
|
||||||
|
log_debug("Set executable permissions for cream.sh")
|
||||||
|
|
||||||
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')
|
||||||
|
log_debug(f"Writing cream_api.ini with {len(dlcs)} DLCs")
|
||||||
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}.")
|
||||||
@@ -283,13 +346,16 @@ def uninstall_creamlinux(install_path, game_name):
|
|||||||
GREEN = '\033[92m'
|
GREEN = '\033[92m'
|
||||||
RESET = '\033[0m'
|
RESET = '\033[0m'
|
||||||
try:
|
try:
|
||||||
|
log_debug(f"Starting uninstallation for {game_name}")
|
||||||
files_to_remove = ['cream.sh', 'cream_api.ini', 'cream_api.so', 'lib32Creamlinux.so', 'lib64Creamlinux.so']
|
files_to_remove = ['cream.sh', 'cream_api.ini', 'cream_api.so', 'lib32Creamlinux.so', 'lib64Creamlinux.so']
|
||||||
for file in files_to_remove:
|
for file in files_to_remove:
|
||||||
file_path = os.path.join(install_path, file)
|
file_path = os.path.join(install_path, file)
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
|
log_debug(f"Removing {file}")
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
print(f"\n{GREEN}Successfully uninstalled CreamLinux from {game_name}{RESET}")
|
print(f"\n{GREEN}Successfully uninstalled CreamLinux from {game_name}{RESET}")
|
||||||
print(f"\n{YELLOW}Make sure to remove{RESET} {GREEN}'sh ./cream.sh %command%'{RESET} {YELLOW}from launch options{RESET}")
|
print(f"\n{YELLOW}Make sure to remove{RESET} {GREEN}'sh ./cream.sh %command%'{RESET} {YELLOW}from launch options{RESET}")
|
||||||
|
log_debug("Uninstallation completed successfully")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log_error(f"Failed to uninstall CreamLinux: {e}")
|
log_error(f"Failed to uninstall CreamLinux: {e}")
|
||||||
|
|
||||||
@@ -302,6 +368,10 @@ def main():
|
|||||||
setup_logging(args.debug)
|
setup_logging(args.debug)
|
||||||
show_header(app_version, args.debug)
|
show_header(app_version, args.debug)
|
||||||
|
|
||||||
|
if not check_requirements():
|
||||||
|
print("Missing required dependencies. Please install them and try again.")
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
library_folders = find_steam_library_folders(args.manual)
|
library_folders = find_steam_library_folders(args.manual)
|
||||||
if not library_folders:
|
if not library_folders:
|
||||||
@@ -313,53 +383,66 @@ def main():
|
|||||||
print("Invalid path! Closing the program...")
|
print("Invalid path! Closing the program...")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Do initial game scan
|
||||||
games = find_steam_apps(library_folders)
|
games = find_steam_apps(library_folders)
|
||||||
if games:
|
if not games:
|
||||||
print("\nSelect the game for which you want to fetch DLCs:")
|
print("No Steam games found on this computer or connected drives.")
|
||||||
|
return
|
||||||
|
|
||||||
|
while True:
|
||||||
games_list = list(games.items())
|
games_list = list(games.items())
|
||||||
|
|
||||||
|
# Show game list
|
||||||
|
print("\nSelect the game(s) for which you want to fetch DLCs:")
|
||||||
GREEN = '\033[92m'
|
GREEN = '\033[92m'
|
||||||
RESET = '\033[0m'
|
RESET = '\033[0m'
|
||||||
|
|
||||||
for idx, (app_id, (name, cream_status, _)) in enumerate(games_list, 1):
|
for idx, (app_id, (name, cream_status, _)) in enumerate(games_list, 1):
|
||||||
status = []
|
status = f" ({GREEN}Cream installed{RESET})" if cream_status else ""
|
||||||
if cream_status:
|
print(f"{idx}. {name} (App ID: {app_id}){status}")
|
||||||
status.append(f"{GREEN}Cream installed{RESET}")
|
|
||||||
|
|
||||||
status_str = f" ({', '.join(status)})" if status else ""
|
try:
|
||||||
print(f"{idx}. {name} (App ID: {app_id}){status_str}")
|
choice = int(input("\nEnter the number of the game: ")) - 1
|
||||||
|
if not (0 <= choice < len(games_list)):
|
||||||
|
print("Invalid selection.")
|
||||||
|
continue
|
||||||
|
except ValueError:
|
||||||
|
print("Invalid input. Please enter a number.")
|
||||||
|
continue
|
||||||
|
|
||||||
choice = int(input("\nEnter the number of the game: ")) - 1
|
selected_app_id, (selected_game_name, cream_status, selected_install_dir) = games_list[choice]
|
||||||
if 0 <= choice < len(games_list):
|
|
||||||
selected_app_id, (selected_game_name, cream_status, selected_install_dir) = games_list[choice]
|
|
||||||
|
|
||||||
if cream_status:
|
if cream_status:
|
||||||
print("\nCreamLinux is installed. What would you like to do?")
|
print(f"\nCreamLinux is installed for {selected_game_name}. What would you like to do?")
|
||||||
print("1. Fetch DLC IDs")
|
print("1. Fetch DLC IDs")
|
||||||
print("2. Uninstall CreamLinux")
|
print("2. Uninstall CreamLinux")
|
||||||
action = input("Enter your choice (1-2): ")
|
action = input("Enter your choice (1-2): ")
|
||||||
|
|
||||||
if action == "1":
|
if action == "1":
|
||||||
print(f"\nSelected: {selected_game_name} (App ID: {selected_app_id})")
|
|
||||||
dlcs = fetch_dlc_details(selected_app_id)
|
|
||||||
if dlcs:
|
|
||||||
install_files(selected_app_id, selected_install_dir, dlcs, selected_game_name)
|
|
||||||
else:
|
|
||||||
print("No DLCs found for the selected game.")
|
|
||||||
elif action == "2":
|
|
||||||
uninstall_creamlinux(selected_install_dir, selected_game_name)
|
|
||||||
else:
|
|
||||||
print("Invalid choice.")
|
|
||||||
else:
|
|
||||||
print(f"\nSelected: {selected_game_name} (App ID: {selected_app_id})")
|
print(f"\nSelected: {selected_game_name} (App ID: {selected_app_id})")
|
||||||
dlcs = fetch_dlc_details(selected_app_id)
|
dlcs = fetch_dlc_details(selected_app_id)
|
||||||
if dlcs:
|
if dlcs:
|
||||||
install_files(selected_app_id, selected_install_dir, dlcs, selected_game_name)
|
install_files(selected_app_id, selected_install_dir, dlcs, selected_game_name)
|
||||||
else:
|
else:
|
||||||
print("No DLCs found for the selected game.")
|
print("No DLCs found for the selected game.")
|
||||||
|
elif action == "2":
|
||||||
|
uninstall_creamlinux(selected_install_dir, selected_game_name)
|
||||||
|
else:
|
||||||
|
print("Invalid choice.")
|
||||||
else:
|
else:
|
||||||
print("Invalid selection.")
|
print(f"\nSelected: {selected_game_name} (App ID: {selected_app_id})")
|
||||||
else:
|
dlcs = fetch_dlc_details(selected_app_id)
|
||||||
print("No Steam games found on this computer or connected drives.")
|
if dlcs:
|
||||||
|
install_files(selected_app_id, selected_install_dir, dlcs, selected_game_name)
|
||||||
|
else:
|
||||||
|
print("No DLCs found for the selected game.")
|
||||||
|
|
||||||
|
if input("\nWould you like to perform another operation? (y/N): ").lower() != 'y':
|
||||||
|
break
|
||||||
|
|
||||||
|
# Only scan again if user wants to continue
|
||||||
|
games = find_steam_apps(library_folders)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.exception("An error occurred:")
|
logging.exception("An error occurred:")
|
||||||
log_error(f"An error occurred: {e}")
|
log_error(f"An error occurred: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user