scripts

shell scripts
git clone git://git.bitsmanent.org/scripts
Log | Files | Refs | README

commit 1c61584ca7019a998038b4949a625605d4ce1895
parent ebe0d6d46016804286c59dfb7fb57eca728288c8
Author: clamiax <smoppy@gmail.com>
Date:   Thu,  2 Jan 2014 17:11:12 +0100

Add a little Tumblr scraper.

Diffstat:
Ascrapthumb | 43+++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+), 0 deletions(-)

diff --git a/scrapthumb b/scrapthumb @@ -0,0 +1,43 @@ +#!/bin/bash +# Scrap Tumblr to get random images +# Usage: feh -dF $(./scrapthumb) + +# TODO +# - Allow more than JPEGs + +VIEWER=echo +MAXIMGS=5 + +# No trailing slash +SOURCES=( + "http://tgfcp.tumblr.com" + "http://nakedbeachess.tumblr.com" +) + +## +# Do not edit below. +## + +IMGS=() +preload() { + i=0 + mod=$(echo $MAXIMGS % ${#SOURCES[*]} |bc) + tot=$(echo $MAXIMGS / ${#SOURCES[*]} |bc) + + for src in ${SOURCES[*]} + do + [ $i -eq 0 -a $mod -ne 0 ] && t=$(echo $tot + 1 | bc) || t=$tot + for n in $(seq 1 $t) + do + IMGS[$i]="$(wget -qO - "$src/random" |grep 'property="og:image"' | sed 's/.*content="\(.*.jpg)\)".*/\1/')" + i=$(echo $i+1|bc) + done + done +} + +main() { + preload + $VIEWER ${IMGS[*]} +} + +main "$@"