author | Michael Krelin <hacker@klever.net> | 2011-03-18 17:20:34 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2011-03-19 16:26:43 (UTC) |
commit | 0573764b7e7bdff6e5fbbb558d4d647c34f07271 (patch) (side-by-side diff) | |
tree | 10dcb24ecb8cd173b656a8726ef5bbf35e07a56f | |
parent | 1d47a62116c7e238b950bdafa636e4cc5d3ea9a5 (diff) | |
download | iii-0573764b7e7bdff6e5fbbb558d4d647c34f07271.zip iii-0573764b7e7bdff6e5fbbb558d4d647c34f07271.tar.gz iii-0573764b7e7bdff6e5fbbb558d4d647c34f07271.tar.bz2 |
on-upload-photo script
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | doc/Makefile.am | 4 | ||||
-rwxr-xr-x | doc/on-upload-photo.bash | 54 |
2 files changed, 56 insertions, 2 deletions
diff --git a/doc/Makefile.am b/doc/Makefile.am index 4a22498..ca56ef3 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,4 +1,4 @@ man_MANS=iiid.8 - -EXTRA_DIST = 000000000000.conf +doc_DATA = 000000000000.conf +pkglib_SCRIPTS = on-upload-photo.bash diff --git a/doc/on-upload-photo.bash b/doc/on-upload-photo.bash new file mode 100755 index 0000000..483b68a --- a/dev/null +++ b/doc/on-upload-photo.bash @@ -0,0 +1,54 @@ +#!/bin/bash +test -z "$targetroot" && targetroot="$(dirname "$EYEFI_UPLOADED")" + +make_vars() { + echo -n "ttype=$1 " + sed <<<$etime -e 's,^[^/]\+/,,' -e 's, 0*, hour=,' -e 's,^0*,year=,' -e 's,:0*, month=,' -e 's,:0*, day=,' -e 's,:0*, minute=,' -e 's,:0*, second=,' +} + +j_time() { + local j="$1" + local etime="$(exiftime -s / -tg "$j" 2>/dev/null)" + [[ -z "$etime" ]] && etime="$(exiftime -s / -td "$j" 2>/dev/null)" + [[ -z "$etime" ]] && etime="$(exiftime -s / -tc "$j" 2>/dev/null)" + [[ -z "$etime" ]] && return 1 + make_vars jpg <<<$etime +} + +a_time() { + local a="$1" + local etime="$(iii-extract-riff-chunk "$a" '/RIFF.AVI /LIST.ncdt/nctg'|dd bs=1 skip=82 count=19 2>/dev/null)" + [[ -z "$etime" ]] && return 1 + make_vars avi <<<$etime +} + +ul="$EYEFI_UPLOADED" + +if ! vars="$(j_time "$ul"||a_time "$ul")" ; then + report="Timeless $(basename "$ul") uploaded" +else + eval "$vars" + stem="$(printf '%04d-%02d-%02d--%02d-%02d-%02d' "$year" "$month" "$day" "$hour" "$minute" "$second")" + targetdir="$(printf "%s/%04d-%02d" "$targetroot" "$year" "$month")" + mkdir -p "$targetdir" + success=false + for((i=0;i<100;++i)) do + [[ $i = 0 ]] && tf="$stem.$ttype" || tf="$stem ($i).$ttype" + tf="$targetdir/$tf" + if ln -T "$ul" "$tf" &>/dev/null && rm "$ul" ; then + success=true + break + fi + done + if $success ; then + report="$(basename "$tf") uploaded" + if [[ -n "$EYEFI_LOG" ]] ; then + ln -T "$EYEFI_LOG" "${tf}.log" && rm "$EYEFI_LOG" || report="$report, but log..." + fi + else + report="$(basename "$ul") uploaded, but..." + fi +fi +echo "$report" + +type iii_report &>/dev/null && iii_report "$report" |