From 20884258dfb5ff87bd0416899289480ec7d0fc31 Mon Sep 17 00:00:00 2001 From: kaa Date: Mon, 9 Jun 2025 00:22:13 -0700 Subject: Support for direct setting of outdir --- concurrent_dl.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'concurrent_dl.sh') diff --git a/concurrent_dl.sh b/concurrent_dl.sh index a824514..d2c9d36 100755 --- a/concurrent_dl.sh +++ b/concurrent_dl.sh @@ -15,7 +15,7 @@ dl_safe() limit=10 while [ $done -ne 0 ] && [ $i -lt $limit ] do - curl --max-time 10 -sLo $1 $2 -H @$3 + curl --compressed --max-time 10 -sLo $1 $2 -H @$3 done=$? i=$((i+1)) done @@ -24,12 +24,28 @@ dl_safe() echo Tried $limit times, bad URL. fi } +if [ -z "$outdir" ] +then + outdir=page +fi +if [ -z "$depth" ] +then + depth=0 +fi strip_path() { - sed -e 's|.*/|page/|' - if ! [ -d page ] + sed -e 's|/$||' -e "s|?.*||" | ( + if [ $depth -eq 1 ] + then + sed -E -e "s|.*/([^/]*/[^/]*)$|\1|" + else + sed -e "s|.*/|$outdir/|" + fi + ) + + if ! [ -d $outdir ] then - mkdir page + mkdir -p $outdir fi } concurrent_dl() -- cgit v1.2.3