Skip to content

Commit

Permalink
Merge pull request #68 from monkeydone/main
Browse files Browse the repository at this point in the history
Support terminal proxy in code
  • Loading branch information
pythongosssss authored Oct 23, 2024
2 parents 4f1a857 + 5b160bd commit ac5601e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pysssss.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,13 @@ async def download_to_file(url, destination, update_callback, is_ext_subpath=Tru
if is_ext_subpath:
destination = get_ext_dir(destination)
try:
async with session.get(url) as response:
proxy = os.getenv("HTTP_PROXY") or os.getenv("http_proxy")
print("proxy:", proxy)
proxy_auth = None
if proxy:
proxy_auth = aiohttp.BasicAuth(os.getenv("PROXY_USER", ""), os.getenv("PROXY_PASS", ""))

async with session.get(url, proxy=proxy, proxy_auth=proxy_auth) as response:
size = int(response.headers.get('content-length', 0)) or None

with tqdm(
Expand Down

0 comments on commit ac5601e

Please sign in to comment.