#!/bin/bash ##################### # # name: comicget (comicget.sh) # vers: 0.2a # date: 071206 # first: 070706 # auth: "Keith Beckman" # site: http://alphahelical.com/code/scripts/comicget # desc: comicget is a comics.com client for bash. Currently it only supports # curl as a user-agent. # # todo: archive retrieval, wget/lynx/links/telnet support # also, a more robust 'recent' mode that allows date selection # archival of comics by month into compressed archives # generate a "latest comics page" suitable for using as a browser homepage # # license: comicget is copyright 2006 Keith Beckman and is licensed under the # GNU General Public License (http://gnu.org/licenses/gpl.txt) # ##################### ####configuration#### datadir='/tmp' open_command='open' open_multiple=1 # 1 if $open_command can handle a list of items, 0 otherwise # under X11, you might have #open_command='xv' #open_multiple=0 #comics dwelling under comics.com/comics comics_list="alleyoop dilbert drabble getfuzzy hedge jumpstart pearls" #comics dwelling under comics.com/creators, from the old Creators Syndicate creators_list="bc wizardofid" host='http://comics.com' silent_flag='-s' # what option(s) to pass the UA for silent downloads seconds=43200 # seconds between updates verbose=1 # default verbosity level, 0-2 mode='retrieval' # default mode verstring='comicget v0.2a 071206 keith beckman' ##end configuration## function echo_usage() { cat <.*/\1/") # how we know if we're online if [ $imgpath == "$host/" ]; then return 1; fi extension=$(sed 's/.*\.\(...\)$/\1/' <<< $imgpath) if [ "$(cat $datadir/$1/touch)" != $imgpath ]; then if [ $verbose -gt 0 ]; then echo "Updating $1" fi if [ $verbose -gt 1 ]; then echo $imgpath; fi curl $img_dl_flags $imgpath > $datadir/$1/$1-$(date +%F).$extension echo $imgpath > $datadir/$1/touch fi } natch=1 for comic in $comics_list; do grab_image $comic comics if [[ $? -eq 0 && $natch -eq 1 ]]; then natch=1; else natch=0; fi done for comic in $creators_list; do grab_image $comic creators if [[ $? -eq 0 && $natch -eq 1 ]]; then natch=1; else natch=0; fi done if [ $natch -eq 1 ]; then touch $datadir/touch; fi ##MODE: RECENT## elif [ $mode == 'recent' ]; then if [ "$open_multiple" -eq 1 ]; then $open_command $(find $datadir -mtime 1 | grep '\....$'); else for item in $(find $datadir -mtime 1 | grep '\....$'); do $open_command $item done fi fi