contrib: process_linux_firmware: set user agent

This should help avoid getting banned for looking like a bot since
the script polls.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
main
Mario Limonciello 2025-04-20 23:41:52 -05:00
parent 5aa42075d0
commit b91a362b8e
1 changed files with 10 additions and 1 deletions

View File

@ -71,7 +71,16 @@ def classify_content(content):

def fetch_url(url):
blob = None
with urllib.request.urlopen(url) as response:
req = urllib.request.Request(
url,
data=None,
headers={
"User-Agent": "linux-firmware-ci/1.x ({email})".format(
email=os.getenv("EMAIL")
)
},
)
with urllib.request.urlopen(req) as response:
blob = response.read()
m = magic.Magic(mime_encoding=True)
return blob.decode(m.from_buffer(blob))