scripts

misc scripts and tools
git clone git://git.2f30.org/scripts
Log | Files | Refs

commit c6cd24b0f20d024cc736a1a9d9d2d5fb8bd2a66f
parent 480783541cf7d36b7e004458e8325f5c2f4b66de
Author: Haris <haris@feanor.lan>
Date:   Fri,  5 Jul 2013 15:18:32 +0300

4chan pic downloader.

Diffstat:
A4chandownload.sh | 40++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+), 0 deletions(-)

diff --git a/4chandownload.sh b/4chandownload.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +if [ "$1" = "" ]; then + echo "Usage: `basename $0` <4chan thread url>" + exit 1 +fi + +echo "4chan downloader" +echo "Downloading until canceled or 404'd" +LOC=$( echo "$1" | egrep -o '([0-9]*)$' | sed 's/\.html//g' ) +echo "Downloading to $LOC" + +if [ ! -d $LOC ]; then + mkdir $LOC +fi + +cd $LOC + +while [ true ]; do + TMP=`mktemp /tmp/4chan.XXXXXX` + TMP2=`mktemp /tmp/4chanm.XXXXXX` + WGET_CMD='wget -nv -nc' + + wget -O "$TMP" "$1" + if [ "$?" != "0" ]; then + rm $TMP $TMP2 + exit 1 + fi + + egrep '//images.4chan.org/[a-z0-9]+/src/([0-9]*).(jpg|png|gif)' "$TMP" -o | uniq > "$TMP2" + + sed 's|//images|http://images|g' $TMP2 > $TMP + + cat $TMP | xargs -P 5 -I _URL_ $WGET_CMD _URL_ + + rm $TMP $TMP2 + + echo "Waiting 30 seconds befor next run" + sleep 30 +done;