You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
827 B
Plaintext

2 years ago
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# dchunks - fanta@56k.es
import sys
import requests
import time
chunkSize=2048
2 years ago
errorMsg="Example: chunkd http://fanta.56k.es/games/1990/1990-King_Quest_5/King_Quest_5.tar.gz"
if len(sys.argv) == 2: url=sys.argv[1]
else: print(errorMsg); exit(1)
session = requests.Session()
try: response = session.get(url,allow_redirects=True,stream=True)
except: print(errorMsg); exit(1)
fileLocalFilename = url.split('/')[-1]
print("\n[+] "+fileLocalFilename+" - chunk Size: ",chunkSize)
def downloadChunks():
totalbits = 0
response.raise_for_status()
for chunk in response.iter_content(chunk_size=chunkSize):
if chunk:
totalbits += len(chunk)
f.write(chunk)
if response.status_code == 200:
with open(fileLocalFilename, 'wb') as f:
downloadChunks()
2 years ago
print("\n")