summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxyz <gky44px1999@gmail.com>2021-08-31 13:06:14 -0700
committerxyz <gky44px1999@gmail.com>2021-08-31 13:06:14 -0700
commit0c908e6e84248bdcfad00fb8cb4810e826be8d7d (patch)
tree7ecf7d45e4a139750110440a58a22198f718b7fa
parent46429d089093fd1485e578863dbd789626e74481 (diff)
curlkg, consider x%n==0
-rwxr-xr-x.local/bin/curlkg6
1 files changed, 4 insertions, 2 deletions
diff --git a/.local/bin/curlkg b/.local/bin/curlkg
index d13ceebf..d3248953 100755
--- a/.local/bin/curlkg
+++ b/.local/bin/curlkg
@@ -30,14 +30,16 @@ get_json ()
curl -s -G --data-urlencode type=get_uinfo -d outCharset=utf-8 -d start="$1" -d num=$num -d share_uid="$uid" "$homepage_url" | sed -e 's/^MusicJsonCallback(//' -e 's/)$//'
}
+# is it possible not to write to a file? only pipe stdout?
get_json 1 > "$tmp_json_file"
ugc_total_count=$(jq '.data.ugc_total_count' "$tmp_json_file")
# can also use while loop with i=$((i+1))
-# maybe can improve to consider if ugc_total_count is num, numx2 ...
-for i in $(seq 2 $((ugc_total_count/num+1))); do
+# the calculation considers both ugc_total_count%num==0 and ugc_total_count%num>0
+for i in $(seq 2 $(((ugc_total_count+num-1)/num))); do
get_json "$i" >> "$tmp_json_file"
done
+# how to show less aria2c stdout?
jq -r '.data.ugclist[]|"'"$music_url"'?shareid=\(.shareid)\n out=\(.title)_\(.time).m4a"' "$tmp_json_file" | aria2c -d "$download_dir" --auto-file-renaming=false -i-
## ytfzf way with curl only