biome: 1.9.2 -> 1.9.3
[NixPkgs.git] / pkgs / by-name / st / steam-unwrapped / update.py
blobe49014fee8999eb0800e0a7cdf9db8bd4e4ff4f0
1 #!/usr/bin/env nix-shell
2 #!nix-shell --pure --keep NIX_PATH -i python3 -p git nix-update "python3.withPackages (ps: [ ps.beautifulsoup4 ps.requests ])"
4 import sys
5 import re
6 import requests
7 import subprocess
8 from bs4 import BeautifulSoup
10 VERSION_PATTERN = re.compile(r'^steam_(?P<ver>(\d+\.)+)tar.gz$')
12 found_versions = []
13 response = requests.get("https://repo.steampowered.com/steam/archive/stable/")
14 soup = BeautifulSoup (response.text, "html.parser")
15 for a in soup.find_all("a"):
16 href = a["href"]
17 if not href.endswith(".tar.gz"):
18 continue
20 match = VERSION_PATTERN.match(href)
21 if match is not None:
22 version = match.groupdict()["ver"][0:-1]
23 found_versions.append(version)
25 if len(found_versions) == 0:
26 print("Failed to find available versions!", file=sys.stderr)
27 sys.exit(1)
29 found_versions.sort()
30 subprocess.run(["nix-update", "--version", found_versions[-1], "steam-unwrapped"])
31 found_versions[0]