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"
61 url_id() { taggery_id "${@}"; }
62 image_name() { taggery_image_name "${@}"; }
63 image_url() { taggery_image_url "${@}"; }
64 image_tags() { taggery_image_tags "${@}"; }
66 id="$(url_id "${url}")"
67 name="$(image_name "${id}")"
68 file="$(image_url "${id}")"
69 tags="$(image_tags "${id}")"
70 [ "${file}" ] || name="${hash}"
79 kvs_get_all "${taggery_name}/${id}"
83 [ "${file}" -o "${hash}" ] || { echo "No download URL (deleted?) and -f not provided" >&2; kill -ABRT $$; exit 1; }
84 [ "${tags}" ] || { echo "No tags found" >&2; kill -ABRT $$; exit 1; }
89 if [ -e "${taggery_base}/md5/${name}" ]
91 echo "Filename ${name} already exists"
93 taggery_fetch_image "${id}"
98 if [ "${nabbed}" -o "${tags}" ]
100 taggery_link_tags "${id}"
103 # Even if we didn't download it, try to link it into the pool
105 plnm="${taggery_base}/pool/${pool}/${indx}.${extn}"
108 echo "Filename ${plnm} already exists"
110 mkdir -p "${taggery_base}/pool/${pool}"
111 ln -svf "../../md5/${name}" "${plnm}"