4 [ "${*}" ] && printf "%s\n\n" "${*}"
6 Usage: $(basename "${0}") <url>
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 -n Noop-mode; do not download image nor write tags
13 -p <poolname> Associates the downloaded image with a pool
14 -i <indexnum> Used with -p to indicate the position in the pool
16 -t Refresh the tags, not the picture
17 -f <filename> If the image is deleted, provide the local filename
23 while getopts dnp:i:tf: OPT
28 p) pool="${OPTARG}" ;;
29 i) indx="${OPTARG}" ;;
31 f) hash="${OPTARG}" ;;
35 shift $(( $OPTIND - 1 ))
39 #[ -z "$(echo "${id}" | tr -d '[0-9]')" ] || pebkac "ID should be an integer"
41 taggery_base="$(dirname "${0}")"
42 taggery_libs="$(dirname "${0}")/lib"
44 # Try and find the profile that can handle the url
45 profiles="$(cd "${taggery_libs}/profiles"; ls -1 | sed -e 's/.sh$//')"
46 for profile in ${profiles}
48 . "${taggery_libs}/profiles/${profile}.sh"
49 "${profile}_can_handle" "${url}" || continue
50 taggery_name="${profile}"
54 # Set up temporary area
55 #mkdir -p "$(dirname "${0}")/tmp"
56 #TMPDIR="$(dirname "${0}")/tmp"
59 #kvs="${TMPDIR}/.${taggery_name}.kvdb"
60 #. "$(dirname "${0}")/lib/kvs.sh"
63 . "${taggery_libs}/taggery.sh"
65 id="$(taggery_id "${url}")"
66 name="$(taggery_image_name "${id}")"
67 file="$(taggery_image_url "${id}")"
68 tags="$(taggery_image_tags "${id}")"
69 [ "${file}" ] || name="${hash}"
78 kvs_get_all "${taggery_name}/${id}"
82 [ "${file}" -o "${hash}" ] || { echo "No download URL (deleted?) and -f not provided" >&2; kill -ABRT $$; exit 1; }
83 [ "${tags}" ] || { echo "No tags found" >&2; kill -ABRT $$; exit 1; }
88 if [ -e "${taggery_base}/md5/${name}" ]
90 echo "Filename ${name} already exists"
94 echo "taggery_fetch_image(${id})"
95 echo "taggery_image_url => $(taggery_image_url "${id}")"
96 echo "taggery_image_name => $(taggery_image_name "${id}")"
98 taggery_fetch_image "${id}"
104 if [ "${nabbed}" -o "${tags}" ]
108 echo "taggery_link_tags(${id}):"
109 echo "${tags}" | sed -e 's/^/ /g'
111 taggery_link_tags "${id}"
115 # Even if we didn't download it, try to link it into the pool
116 [ -z "${noop}" ] && [ "${pool}" ] && {
117 plnm="${taggery_base}/pool/${pool}/${indx}.${extn}"
120 echo "Filename ${plnm} already exists"
122 mkdir -p "${taggery_base}/pool/${pool}"
123 ln -svf "../../md5/${name}" "${plnm}"