Created
October 15, 2025 08:23
-
-
Save Mte90/09b7de1ad7cdaf7e7c233561f6f3c3ea to your computer and use it in GitHub Desktop.
steam-multiplayer-games.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # Print a list of your steam games that are playable locally with more people | |
| import requests | |
| import json | |
| import time | |
| import html | |
| import re | |
| import lxml.etree as etree | |
| # Replace with your own Steam API key and Steam ID | |
| STEAM_API_KEY = "your-key" # https://steamcommunity.com/dev/apikey | |
| STEAM_ID = "76561198055726040" # https://steamid.io | |
| def get_owned_games(steam_id, api_key): | |
| """Fetch the list of owned games from the Steam API.""" | |
| url = ( | |
| f"http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/" | |
| f"?key={api_key}&steamid={steam_id}&include_appinfo=true&format=json" | |
| ) | |
| headers = {"User-Agent": "Mozilla/5.0"} | |
| response = requests.get(url, headers=headers) | |
| if response.status_code == 200: | |
| data = response.json() | |
| if "response" in data and "games" in data["response"]: | |
| return data["response"]["games"] | |
| return [] | |
| def check_cooptimus_local_players(steam_app_id): | |
| """Check the number of local players supported using the Co-Optimus API.""" | |
| url = f"https://api.co-optimus.com/games.php?search=true&steam={steam_app_id}" | |
| try: | |
| response = requests.get(url, timeout=10) | |
| if response.status_code != 200: | |
| return None | |
| safe_text = re.sub(r"&(?![a-zA-Z#0-9]+;)", "&", response.text) | |
| cleaned_content = html.unescape(safe_text) | |
| parser = etree.HTMLParser() | |
| root = etree.fromstring(cleaned_content.encode("utf-8"), parser) | |
| game = root.find(".//game") | |
| if game is not None: | |
| local = game.find("local") | |
| if local is not None and local.text: | |
| text = local.text.strip() | |
| if text.isdigit(): | |
| return int(text) | |
| return None | |
| except Exception as e: | |
| print(f"Error fetching Co-Optimus data for {steam_app_id}: {e}") | |
| return None | |
| def main(): | |
| games = get_owned_games(STEAM_ID, STEAM_API_KEY) | |
| if not games: | |
| print("No games found.") | |
| return | |
| print("Local multiplayer support (number of players):") | |
| for game in games: | |
| app_id = game["appid"] | |
| name = game["name"] | |
| local_players = check_cooptimus_local_players(app_id) | |
| if local_players: | |
| print(f"- {name}: {local_players} local players") | |
| time.sleep(1) # Avoid rate limiting | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment