aria2-feeder: hacer una gran request en vez de varias chicas

This commit is contained in:
Cat /dev/Nulo 2021-11-30 21:33:59 -03:00
parent f6fb1e8177
commit 0fd06c53a7
2 changed files with 14 additions and 12 deletions

View file

@ -27,7 +27,7 @@ if ! curl -q localhost:6850 >/dev/null 2>/dev/null; then
echo "> Iniciando aria2..."
mkdir -p datos/
cd datos/
aria2c --enable-rpc --rpc-listen-all=false --rpc-listen-port=6850 --max-concurrent-downloads=50 --max-connection-per-server=16 --continue >> ../aria2.log &
aria2c --enable-rpc --rpc-listen-all=false --rpc-listen-port=6850 --rpc-max-request-size=200M --max-concurrent-downloads=50 --max-connection-per-server=16 --continue >> ../aria2.log &
sleep 3 # Esperar a que inicie
cd ..
fi
@ -39,7 +39,7 @@ if test -f lista-paginas.zst; then
echo "Son $(cat lista-paginas | wc -l) páginas."
echo "> Alimentando a aria2..."
cd aria2-feeder/
lua feed-aria2.lua ../lista-paginas localhost:6850 | busybox ash -e
lua feed-aria2.lua ../lista-paginas | curl --data "@-" http://localhost:6850/jsonrpc >/dev/null
echo "Terminé de alimentar. ¡Suerte!"
else
echo "No tengo ninguna lista para descargar. ¡Chau!"

View file

@ -4,20 +4,22 @@ local json = require "json"
local file = arg[1]
local handle = io.open(file)
local rpc = arg[2]
if not rpc then
rpc = "localhost:6800"
end
local full_request = {}
local i = math.random(1, 99999999)
while 1 do
local line = handle:read("*l")
if not line then break end
local params = json.encode({{ line }, { header = { "accept-encoding: gzip, br" } }})
local b64params = base64.encode(params)
local id = math.random(1, 99999999)
print("curl -q '"..rpc.."/jsonrpc?method=aria2.addUri&id="..id.."&params="..b64params.."' >/dev/null 2>/dev/null")
table.insert(full_request, {
jsonrpc = "2.0",
id = i,
method = "aria2.addUri",
params = {{ line }, { header = { "accept-encoding: gzip, br" } }}
})
i = i + 1
end
print(json.encode(full_request))