summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2011-03-18 17:20:34 (UTC)
committer Michael Krelin <hacker@klever.net>2011-03-19 16:26:43 (UTC)
commit0573764b7e7bdff6e5fbbb558d4d647c34f07271 (patch) (unidiff)
tree10dcb24ecb8cd173b656a8726ef5bbf35e07a56f
parent1d47a62116c7e238b950bdafa636e4cc5d3ea9a5 (diff)
downloadiii-0573764b7e7bdff6e5fbbb558d4d647c34f07271.zip
iii-0573764b7e7bdff6e5fbbb558d4d647c34f07271.tar.gz
iii-0573764b7e7bdff6e5fbbb558d4d647c34f07271.tar.bz2
on-upload-photo script
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--doc/Makefile.am4
-rwxr-xr-xdoc/on-upload-photo.bash54
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,6 +1,6 @@
1man_MANS=iiid.8 1man_MANS=iiid.8
2 2doc_DATA = 000000000000.conf
3EXTRA_DIST = 000000000000.conf 3pkglib_SCRIPTS = on-upload-photo.bash
4 4
5clean-local: 5clean-local:
6 rm -f iiid.8 6 rm -f iiid.8
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 @@
1#!/bin/bash
2test -z "$targetroot" && targetroot="$(dirname "$EYEFI_UPLOADED")"
3
4make_vars() {
5 echo -n "ttype=$1 "
6 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=,'
7}
8
9j_time() {
10 local j="$1"
11 local etime="$(exiftime -s / -tg "$j" 2>/dev/null)"
12 [[ -z "$etime" ]] && etime="$(exiftime -s / -td "$j" 2>/dev/null)"
13 [[ -z "$etime" ]] && etime="$(exiftime -s / -tc "$j" 2>/dev/null)"
14 [[ -z "$etime" ]] && return 1
15 make_vars jpg <<<$etime
16}
17
18a_time() {
19 local a="$1"
20 local etime="$(iii-extract-riff-chunk "$a" '/RIFF.AVI /LIST.ncdt/nctg'|dd bs=1 skip=82 count=19 2>/dev/null)"
21 [[ -z "$etime" ]] && return 1
22 make_vars avi <<<$etime
23}
24
25ul="$EYEFI_UPLOADED"
26
27if ! vars="$(j_time "$ul"||a_time "$ul")" ; then
28 report="Timeless $(basename "$ul") uploaded"
29else
30 eval "$vars"
31 stem="$(printf '%04d-%02d-%02d--%02d-%02d-%02d' "$year" "$month" "$day" "$hour" "$minute" "$second")"
32 targetdir="$(printf "%s/%04d-%02d" "$targetroot" "$year" "$month")"
33 mkdir -p "$targetdir"
34 success=false
35 for((i=0;i<100;++i)) do
36 [[ $i = 0 ]] && tf="$stem.$ttype" || tf="$stem ($i).$ttype"
37 tf="$targetdir/$tf"
38 if ln -T "$ul" "$tf" &>/dev/null && rm "$ul" ; then
39 success=true
40 break
41 fi
42 done
43 if $success ; then
44 report="$(basename "$tf") uploaded"
45 if [[ -n "$EYEFI_LOG" ]] ; then
46 ln -T "$EYEFI_LOG" "${tf}.log" && rm "$EYEFI_LOG" || report="$report, but log..."
47 fi
48 else
49 report="$(basename "$ul") uploaded, but..."
50 fi
51fi
52echo "$report"
53
54type iii_report &>/dev/null && iii_report "$report"