From 45c1d80326c4d30f7c11e8feef23057225e5cb75 Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Mon, 30 Oct 2017 04:36:06 -0500 Subject: [PATCH] Add noop mode to fetch --- fetch | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/fetch b/fetch index 476f072..babb62c 100755 --- a/fetch +++ b/fetch @@ -3,12 +3,13 @@ pebkac() { [ "${*}" ] && printf "%s\n\n" "${*}" cat < +Usage: $(basename "${0}") Given a post URL number from the site: * downloads and stashes the full-size image in the md5 directory * adds whatever tags are found into the tag area + -n Noop-mode; do not download image nor write tags -p Associates the downloaded image with a pool -i Used with -p to indicate the position in the pool @@ -19,9 +20,11 @@ EOF exit 1 } -while getopts p:i:tf: OPT +while getopts dnp:i:tf: OPT do case "${OPT}" in + d) DEBUG=DEBUG ;; + n) noop=noop ;; p) pool="${OPTARG}" ;; i) indx="${OPTARG}" ;; t) tags=TAGS ;; @@ -86,18 +89,31 @@ then then echo "Filename ${name} already exists" else - taggery_fetch_image "${id}" - nabbed=NABBED + if [ "${noop}" ] + then + echo "taggery_fetch_image(${id})" + echo "taggery_image_url => $(taggery_image_url "${id}")" + echo "taggery_image_name => $(taggery_image_name "${id}")" + else + taggery_fetch_image "${id}" + nabbed=NABBED + fi fi fi if [ "${nabbed}" -o "${tags}" ] then - taggery_link_tags "${id}" + if [ "${noop}" ] + then + echo "taggery_link_tags(${id}):" + echo "${tags}" | sed -e 's/^/ /g' + else + taggery_link_tags "${id}" + fi fi # Even if we didn't download it, try to link it into the pool -[ "${pool}" ] && { +[ -z "${noop}" ] && [ "${pool}" ] && { plnm="${taggery_base}/pool/${pool}/${indx}.${extn}" if [ -e "${plnm}" ] then -- 2.42.0