From 42ba030b846e6f81a2853e63f1b0d3fe448d4739 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:26:24 -0700 Subject: [PATCH] Revert "Remove request headers" This reverts commit 896a78cce8c48d8baa0da977e6ed5a6ec696419c. --- tools/check_gamefixes.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/check_gamefixes.py b/tools/check_gamefixes.py index e46a1cfb..df1baeed 100644 --- a/tools/check_gamefixes.py +++ b/tools/check_gamefixes.py @@ -33,6 +33,14 @@ class UMUEntry(TypedDict): # pylint: disable=C0115 notes: Union[None, str] +# HTTP request headers +headers = { + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0", + "Accept": "application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8", + "Accept-Language": "en-US,en;q=0.5", +} + + def check_steamfixes(project: Path, url: str, api: ApiEndpoint) -> None: """Verifies if the name of Steam gamefix modules are valid entries. @@ -48,7 +56,7 @@ def check_steamfixes(project: Path, url: str, api: ApiEndpoint) -> None: appids.add(int(appid)) # Check the IDs against ours - with urlopen(Request(url), timeout=500) as r: + with urlopen(Request(url, headers=headers), timeout=500) as r: for obj in ijson.items(r, "applist.apps.item"): if obj["appid"] in appids: appids.remove(obj["appid"]) @@ -93,7 +101,9 @@ def check_gogfixes(project: Path, url: str, api: ApiEndpoint) -> None: sep = "%2C" # Required comma separator character. See the docs. appids = gogids.copy() - with urlopen(Request(f"{url}{sep.join(appids)}"), timeout=500) as r: + with urlopen( + Request(f"{url}{sep.join(appids)}", headers=headers), timeout=500 + ) as r: for obj in ijson.items(r, "item"): # Like Steam's, app ids are integers if (appid := str(obj["id"])) in appids: