chunkd script download http1
parent
8ffecd96b0
commit
ebe0f8b07b
@ -0,0 +1,22 @@
|
||||
Copyright (c) <year> <owner>. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@ -0,0 +1,5 @@
|
||||
# chunkd
|
||||
|
||||
Para descargar archivos grandes modificando el chunksize . Si tienes mucha memoria RAM prueba con sizeChunk=1024*1024*1024 por ejemplo.
|
||||
|
||||
Si tienes poca y el archivo es largo pues pudes probar con 256*1024*1024 o 1024 . haz tus pruebas
|
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# dchunks - fanta@56k.es
|
||||
|
||||
import sys
|
||||
import requests
|
||||
import time
|
||||
|
||||
chunkSize=2048
|
||||
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()
|
||||
|
||||
print("\n")
|
Loading…
Reference in New Issue