feat: implement HTTP auth
Some checks failed
ci / docker (push) Has been cancelled

This commit is contained in:
2025-04-18 11:59:59 +02:00
parent cf55f6f387
commit 472d9cfca2
3 changed files with 17 additions and 15 deletions

View File

@@ -20,6 +20,7 @@ class DataBackend:
self.user = user
self.password = password
self.auth = (self.user, self.password)
self.remote_root_dir = remote_root_dir
self.server = server
self.install_dir = install_dir
@@ -92,6 +93,7 @@ class LocalFS(DataBackend):
meta_info_list.append(software.Software(meta_file, self, self.progress_bar_wrapper))
return list(filter(lambda x: not x.invalid, meta_info_list))
class HTTP(DataBackend):
paths_listed = {}
@@ -165,7 +167,7 @@ class HTTP(DataBackend):
# this is with streaming
chunk_size = 1024 * 1024 * 5 # 5MB
r = requests.get(self._get_url(), params={"path": path, "as_string": True}, stream=True)
r = requests.get(self._get_url(), params={"path": path, "as_string": True}, stream=True, auth=(self.user, self.password))
r.raise_for_status()
if path.endswith(".txt"):
@@ -197,7 +199,7 @@ class HTTP(DataBackend):
else:
print("Async Requested for:", local_file)
statekeeper.add_to_download_queue(self._get_url(), path)
statekeeper.add_to_download_queue(self._get_url(), path, auth=(self.user, self.password))
return local_file
elif return_content:
@@ -220,7 +222,7 @@ class HTTP(DataBackend):
paths = self.paths_listed[fullpath]
else:
r = requests.get(self._get_url(), params={ "path" : path })
r = requests.get(self._get_url(), params={ "path" : path }, auth=(self.user, self.password))
r.raise_for_status()
#print(r, r.status_code, r.content)
paths = r.json()["contents"]
@@ -273,4 +275,4 @@ class HTTP(DataBackend):
print("Age limit set to", self.hide_above_age, "games have", [x.age_limit for x in software_list])
results_with_age = list(filter(lambda x: x.age_limit <= self.hide_above_age, results_valid))
return results_with_age
return results_with_age