diff --git a/custom/functions.zsh b/custom/functions.zsh index 461b1f6..b48dc91 100644 --- a/custom/functions.zsh +++ b/custom/functions.zsh @@ -19,12 +19,12 @@ function getnhentai { local types=($(print $pageinfo | jq -r '.types[]')) local num_pages=$(print $pageinfo | jq '.pages') local urls=() - for i in {0..$num_pages}; do - local itoc=$(($i + 1)) - [[ ${types[$i]} == p ]] && local type=png || local type=jpg - urls+=("https://i.nhentai.net/galleries/$media_id/$itoc.$type") + for i in {1..$num_pages}; do + local ctoi=$(($i - 1)) + [[ ${types[$ctoi]} == p ]] && local type=png || local type=jpg + urls+=("https://i.nhentai.net/galleries/$media_id/$i.$type") done - curl -\#ZL --remote-name-all ${urls} + curl --retry 10 -\#L --remote-name-all ${urls} for i in *; do local sortname="$(printf "%.3i" "${i%%.*}").${i##*.}" [ $sortname = $i ] || mv $i $sortname