|
|
@ -65,9 +65,28 @@ url = args.url |
|
|
|
pager = shlex.split(args.pager) |
|
|
|
pager = shlex.split(args.pager) |
|
|
|
interpreter = shlex.split(args.interpreter) |
|
|
|
interpreter = shlex.split(args.interpreter) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while True: |
|
|
|
if not args.quiet: |
|
|
|
if not args.quiet: |
|
|
|
print(f"Downloading `{url}`...") |
|
|
|
print(f"Downloading `{url}`...") |
|
|
|
content = requests.get(url).content |
|
|
|
|
|
|
|
|
|
|
|
response = requests.get(url, allow_redirects=False) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if response.status_code == 200: |
|
|
|
|
|
|
|
content = response.content |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
print(f"{response.status_code} {response.reason} (redirect to `{response.headers['location']}`)") |
|
|
|
|
|
|
|
if yn("Do you want to follow this redirect?") == 'y': |
|
|
|
|
|
|
|
url = response.headers['location'] |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
print("Not redirecting.") |
|
|
|
|
|
|
|
sys.exit(0) |
|
|
|
|
|
|
|
except KeyError: |
|
|
|
|
|
|
|
print(f"Download failed: {response.status_code} {response.reason}") |
|
|
|
|
|
|
|
sys.exit(0) |
|
|
|
|
|
|
|
|
|
|
|
if not args.quiet: |
|
|
|
if not args.quiet: |
|
|
|
print("Download successful.") |
|
|
|
print("Download successful.") |
|
|
|
print("=" * os.get_terminal_size().columns) |
|
|
|
print("=" * os.get_terminal_size().columns) |
|
|
|