Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- SAVEDIR='/home/anon/stuff/2ch'
- [[ $1 =~ (.+)/([a-z0-9]+)/res/([0-9]+) ]]
- if [ $? != 0 ]
- then
- echo "wrong args"
- exit 1
- fi
- domain=${BASH_REMATCH[1]}
- board=${BASH_REMATCH[2]}
- num=${BASH_REMATCH[3]}
- url="$domain/makaba/mobile.fcgi?task=get_thread&board=$board&thread=$num&num=$num"
- mkdir -p "$SAVEDIR/$board/$num"
- cd "$SAVEDIR/$board/$num"
- if [ $? != 0 ]
- then
- echo "cd fail"
- exit 1
- fi
- wget -O thread.json.new "$url"
- if [ $? != 0 ]
- then
- echo "wget fail"
- exit 1
- fi
- jq -r -e '.[] | .files[]?.path' thread.json.new > urls.txt
- if [ $? != 0 ]
- then
- echo "jq fail, thread doesn't exists?"
- exit 1
- fi
- mv thread.json.new thread.json
- wget --no-clobber --base="$domain/$board/" --input urls.txt
- if [ $? != 0 ]
- then
- echo "wget fail"
- exit 1
- fi
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment