diff options
| author | kaa <kaa@disroot.org> | 2025-06-09 00:22:13 -0700 | 
|---|---|---|
| committer | kaa <kaa@disroot.org> | 2025-06-09 00:22:13 -0700 | 
| commit | 20884258dfb5ff87bd0416899289480ec7d0fc31 (patch) | |
| tree | ca87d4de03cabcbd62ab7f0993bb774273f21211 | |
| parent | dd7c990688588d7d26dce0f9d165c97ddfba39f2 (diff) | |
Support for direct setting of outdir
| -rwxr-xr-x | concurrent_dl.sh | 24 | 
1 files changed, 20 insertions, 4 deletions
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()  | 
