import re
import subprocess
def extract_steam_id():
while True:
url = input("Please enter the Steam link (or type 'exit' to quit): ")
if url.lower() == 'exit':
print("Exiting program...")
break
# Regex pattern to find the Steam Workshop ID from the given URL
pattern = r"(?<=id=)\d+"
match = re.search(pattern, url)
if match:
steam_id = match.group()
command = f"workshop_download_item 457140 {steam_id}"
print(f"Executing: {command}")
try:
subprocess.run(["C:\\SteamCMD\\steamcmd.exe", "+login", "anonymous", "+workshop_download_item", "294100", steam_id, "+quit"], check=True)
print("Command executed successfully.")
except FileNotFoundError:
print("Error: 'steamcmd.exe' not found. Ensure SteamCMD is installed at 'C:\\SteamCMD\\steamcmd.exe'.")
except subprocess.CalledProcessError as e:
print(f"Error while executing SteamCMD: {e}")
else:
print("Invalid URL or ID not found")
# Example usage
if __name__ == "__main__":
extract_steam_id()