4 [ "${*}" ] && printf "%s\n\n" "${*}"
6 Usage: $(basename "${0}") <id>
8 Given an ID number from the site:
9 * downloads and stashes the full-size image in the md5 directory
10 * adds whatever tags are found into the tag area
16 while getopts p:i: OPT
19 p) pool="${OPTARG}" ;;
20 i) indx="${OPTARG}" ;;
24 shift $(( $OPTIND - 1 ))
28 [ -z "$(echo "${id}" | tr -d '[0-9]')" ] || pebkac "ID should be an integer"
30 taggery_name="$(basename "${0}")"
31 taggery_profile="$(dirname "${0}")/lib/profiles/${taggery_name}"
32 [ -f "${taggery_profile}" ] || pebkac "Unsupported profile: ${taggery_name}"
33 . "${taggery_profile}"
35 # Set up temporary area
36 mkdir -p "$(dirname "${0}")/tmp"
37 TMPDIR="$(dirname "${0}")/tmp"
40 kvs="${TMPDIR}/.${taggery_name}.kvdb"
41 . "$(dirname "${0}")/lib/kvs.sh"
44 . "$(dirname "${0}")/lib/taggery.sh"
45 image_url() { taggery_image_url "${@}"; }
46 image_tags() { taggery_image_tags "${@}"; }
48 cd "$(dirname "${0}")"
50 file="$(image_url "${id}")"
51 tags="$(image_tags "${id}")"
53 [ "${file}" -a "${tags}" ] || { echo "Nothing found!"; kill $$; exit 1; }
55 name="$(basename "${file}")"
58 if [ -e "md5/${name}" ]
60 echo "Filename md5/${name} already exists"
62 wget -O "md5/${name}" "${file}"
66 tag="$(echo "${tag}" | sed -e 's/\//%47/g; s/[\]/\\&/g')"
68 ln -sf "../../md5/${name}" "tag/${tag}/"
72 # Even if we didn't download it, try to link it into the pool
74 plnm="pool/${pool}/${indx}.${extn}"
77 echo "Filename ${plnm} already exists"
79 mkdir -p "pool/${pool}"
80 ln -svf "../../md5/${name}" "${plnm}"