Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- image_dir="images"
- tags_dir="tags"
- mkdir -p "$image_dir"
- mkdir -p "$tags_dir"
- max_id=$(curl https://rmbooru.org/post.json --no-progress-meter | jq -r '.[0] | .id')
- max_page=$(($max_id/40+1))
- for page in `seq 1 $max_page` ; do
- echo -ne "\rDownloading page = $page/$max_page"
- curl "https://rmbooru.org/post.json?page=$page" --no-progress-meter | jq -r '.[] | (.id|tostring) + " " + .file_url + " " + .tags' >> /tmp/list_of_rmbooru_posts.txt
- done
- echo -e ""
- while read -r line ; do
- id=$(echo -e "$line" | awk '{print $1}')
- uri=$(echo -e "$line" | awk '{print $2}')
- filename=$(basename "$uri")
- file_path=${image_dir}/${filename}
- tags_path=${tags_dir}/${filename}_tags.txt
- echo -ne "\r$id "
- echo -e "$line" | awk '{$1= ""; $2= "" ;print $0}' > "$tags_path"
- if [ ! -f "$file_path" ] ; then
- curl "https://rmbooru.org/$uri" --no-progress-meter > "$file_path"
- fi
- done < /tmp/list_of_rmbooru_posts.txt
- rm /tmp/list_of_rmbooru_posts.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement