scripts

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

commit caea61a72981f6747bf3ba255bfced2b4f29c6d9
parent 0c44fdae9c7fac6b05961d2dc70ba94edce7ccdd
Author: sin <sin@2f30.org>
Date:   Sat Jul  6 15:53:28 +0100

Rename to 4chanfetch

Diffstat:
4chandownload.sh | 56--------------------------------------------------------
4chanfetch | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 56 deletions(-)
diff --git a/4chandownload.sh b/4chandownload.sh @@ -1,56 +0,0 @@ -#!/bin/sh - -if [ $# -lt 1 ]; then - echo "Usage: $(basename $0) <4chan-thread-url...> " - exit 1 -fi - -pullthread() { - trap 'rm -f ${tmp} ${tmp2}; exit 0' 2 - - tmp=$(mktemp /tmp/4chan.XXXXXX) - tmp2=$(mktemp /tmp/4chanm.XXXXXX) - wget_cmd='wget -nv -nc' - - wget -O ${tmp} "$1" - if [ ! $? -eq 0 ]; then - rm ${tmp} ${tmp2} - return 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} - - return 0 -} - -echo "4chan downloader" - -while :; do - done=1 - - for arg in "$@"; do - path=$(echo "$arg" | egrep -o '([0-9]*)$' | sed 's/\.html//g') - mkdir -p ${path} - cd ${path} - - pullthread "$arg" - if [ $? -eq 0 ]; then - done=0 - fi - - cd - &>/dev/null - done - - if [ $done -eq 1 ]; then - exit 1 - fi - - echo "Waiting 30 seconds before next run" - sleep 30 -done diff --git a/4chanfetch b/4chanfetch @@ -0,0 +1,56 @@ +#!/bin/sh + +if [ $# -lt 1 ]; then + echo "Usage: $(basename $0) <4chan-thread-url...> " + exit 1 +fi + +pullthread() { + trap 'rm -f ${tmp} ${tmp2}; exit 0' 2 + + tmp=$(mktemp /tmp/4chan.XXXXXX) + tmp2=$(mktemp /tmp/4chanm.XXXXXX) + wget_cmd='wget -nv -nc' + + wget -O ${tmp} "$1" + if [ ! $? -eq 0 ]; then + rm ${tmp} ${tmp2} + return 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} + + return 0 +} + +echo "4chan downloader" + +while :; do + done=1 + + for arg in "$@"; do + path=$(echo "$arg" | egrep -o '([0-9]*)$' | sed 's/\.html//g') + mkdir -p ${path} + cd ${path} + + pullthread "$arg" + if [ $? -eq 0 ]; then + done=0 + fi + + cd - &>/dev/null + done + + if [ $done -eq 1 ]; then + exit 1 + fi + + echo "Waiting 30 seconds before next run" + sleep 30 +done