Created
July 13, 2024 20:49
-
-
Save Sardonyx001/b630720a2e8a98fe7d813b29b48226f7 to your computer and use it in GitHub Desktop.
Fish shell function to download all pictures in a 4chan thread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function 4get -a THREADURL -a OUTPUTDIR --description 'Get all the pictures in a 4chan thread' | |
if string-empty $THREADURL | |
echo "Must provide a thread URL" | |
return | |
end | |
if string-empty $OUTPUTDIR | |
set OUTPUTDIR "." | |
end | |
mkdir -p $OUTPUTDIR | |
set threadId $(echo $THREADURL | sed 's/.*\///g') | |
set boardId $(echo $THREADURL | sed 's/.*org\///g' | sed 's/\/.*//g' ) | |
gum log -t kitchen -sl info "Downloading from" thread $threadId | |
gum log -t kitchen -sl info "On " board $boardId | |
gum log -t kitchen -sl info "To " output_dir $OUTPUTDIR | |
curl -s "https://a.4cdn.org/$boardId/thread/$threadId.json" \ | |
| jq " | |
.posts[] | |
| if .tim != null then | |
[.tim, .ext] | |
else empty | |
end | |
| map(tostring) | |
| \"https://i.4cdn.org/$boardId/\"+.[0]+.[1]" \ | |
| xargs -n 1 wget -P $OUTPUTDIR --no-verbose | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use responsibly!