4 [ "${*}" ] && printf "%s\n\n" "${*}"
6 Usage: $(basename "${0}") <id>
8 Given a post URL 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
12 -p <poolname> Associates the downloaded image with a pool
13 -i <indexnum> Used with -p to indicate the position in the pool
15 -t Refresh the tags, not the picture
16 -f <filename> If the image is deleted, provide the local filename
22 while getopts p:i:tf: OPT
25 p) pool="${OPTARG}" ;;
26 i) indx="${OPTARG}" ;;
28 f) hash="${OPTARG}" ;;
32 shift $(( $OPTIND - 1 ))
36 #[ -z "$(echo "${id}" | tr -d '[0-9]')" ] || pebkac "ID should be an integer"
38 taggery_base="$(dirname "${0}")"
39 taggery_libs="$(dirname "${0}")/lib"
41 # Try and find the profile that can handle the url
42 profiles="$(cd "${taggery_libs}/profiles"; ls -1)"
43 for profile in ${profiles}
45 . "${taggery_libs}/profiles/${profile}"
46 "${profile}_can_handle" "${url}" || continue
47 taggery_name="${profile}"
51 # Set up temporary area
52 #mkdir -p "$(dirname "${0}")/tmp"
53 #TMPDIR="$(dirname "${0}")/tmp"
56 #kvs="${TMPDIR}/.${taggery_name}.kvdb"
57 #. "$(dirname "${0}")/lib/kvs.sh"
60 . "${taggery_libs}/taggery.sh"
62 id="$(taggery_id "${url}")"
63 name="$(taggery_image_name "${id}")"
64 file="$(taggery_image_url "${id}")"
65 tags="$(taggery_image_tags "${id}")"
66 [ "${file}" ] || name="${hash}"
75 kvs_get_all "${taggery_name}/${id}"
79 [ "${file}" -o "${hash}" ] || { echo "No download URL (deleted?) and -f not provided" >&2; kill -ABRT $$; exit 1; }
80 [ "${tags}" ] || { echo "No tags found" >&2; kill -ABRT $$; exit 1; }
85 if [ -e "${taggery_base}/md5/${name}" ]
87 echo "Filename ${name} already exists"
89 taggery_fetch_image "${id}"
94 if [ "${nabbed}" -o "${tags}" ]
96 taggery_link_tags "${id}"
99 # Even if we didn't download it, try to link it into the pool
101 plnm="${taggery_base}/pool/${pool}/${indx}.${extn}"
104 echo "Filename ${plnm} already exists"
106 mkdir -p "${taggery_base}/pool/${pool}"
107 ln -svf "../../md5/${name}" "${plnm}"