Home >Backend Development >Python Tutorial >Building an Availability Checker for Refurbished Steam Decks in Europe
Securing a refurbished Steam Deck in Europe can be challenging due to fluctuating stock. This Python-based availability checker automates the process, providing real-time notifications when refurbished units appear. This post details the project's technical implementation and encourages community contributions.
Project Overview
This Python script monitors Steam's store for refurbished Steam Deck availability in Europe. Leveraging the ntfy notification service, it instantly alerts users when stock becomes available. The project showcases efficient problem-solving using readily available Python libraries and APIs.
Functionality
The script operates as follows:
Core Logic:
<code class="language-python">from urllib.request import urlopen # Configure your ntfy URL ntfy_url = "ntfy.sh/YOUR_NTFY_URL" # Timeout to prevent script hang-ups timeout = 8 def parse_availability(data: bytes) -> bool: parsed = " ".join(f"{c:02X}" for c in data) not_available = "08 00 10 00" return parsed != not_available def is_available(id_: str) -> bool: url = ( "api.steampowered.com/IPhysicalGoodsService/" "CheckInventoryAvailableByPackage/v1?origin=" f"https://store.steampowered.com&input_protobuf_encoded={id_}" ) with urlopen(f"https://{url}", timeout=timeout) as response: data = response.read() return parse_availability(data) def notify(name: str) -> None: message = f"Refurbished {name} Steam Deck is available!" print(message) with urlopen(f"https://{ntfy_url}", data=str.encode(message), timeout=timeout): pass if __name__ == "__main__": # Uncomment for notification testing # notify("TEST") # Refurbished 64GB (European region, tested in Poland) if is_available("COGVNxICUEw="): notify("64GB")</code>
Execution
ntfy_url
with your personal ntfy URL (obtain one from the ntfy website). The ntfy mobile app is recommended for notifications.ntfy.sh
and api.steampowered.com
to your trusted sites in Internet Explorer settings.Conclusion
This project highlights the power of concise Python scripts for practical tasks. It serves as a valuable learning resource for API interaction, notifications, and Python automation. The complete code is available on GitHub, welcoming contributions and customization.
The above is the detailed content of Building an Availability Checker for Refurbished Steam Decks in Europe. For more information, please follow other related articles on the PHP Chinese website!