Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Dependencies:
- # - curl
- # - jq (for JSON object processing)
- if [[ "$1" == "" || "$2" == "" ]] ; then
- echo usage: $0 board_name thread_number
- exit 1
- fi
- board_name=$1
- thread_no=$2
- thread_url="https://api.420chan.org/$board_name/res/$thread_no.json"
- echo "Downloading thread page at $thread_url"
- image_names=$(curl $thread_url \
- | jq '.posts|map(.filename + .ext)' \
- | jq 'map(select(. != null))' \
- | jq -r 'join("\n")')
- image_fmt="https://boards.420chan.org/%s/src/%s"
- download_folder="420chan_thread_$thread_no"
- test -d $download_folder || mkdir $download_folder
- for image_name in $image_names; do
- image_url="$(printf $image_fmt $board_name $image_name)"
- echo "Downloading $image_url..."
- curl "$image_url" > "$download_folder/$image_name" 2>/dev/null
- done
Add Comment
Please, Sign In to add comment