From ebe0f8b07bbc1f1c76ee31e0b5b735fbb73401ec Mon Sep 17 00:00:00 2001 From: fanta Date: Sun, 5 Jan 2025 19:26:58 +0100 Subject: [PATCH] chunkd script download http1 --- chunkd/LICENSE | 22 ++++++++++++++++++++++ chunkd/README.md | 5 +++++ chunkd/chunkd | 31 +++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 chunkd/LICENSE create mode 100644 chunkd/README.md create mode 100755 chunkd/chunkd diff --git a/chunkd/LICENSE b/chunkd/LICENSE new file mode 100644 index 0000000..2d2bab1 --- /dev/null +++ b/chunkd/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) . 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. diff --git a/chunkd/README.md b/chunkd/README.md new file mode 100644 index 0000000..e0df968 --- /dev/null +++ b/chunkd/README.md @@ -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 \ No newline at end of file diff --git a/chunkd/chunkd b/chunkd/chunkd new file mode 100755 index 0000000..de45d88 --- /dev/null +++ b/chunkd/chunkd @@ -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")