3 [ "$include_dbmeta" ] && return 0
6 . "$_EXEC/cgilite/storage.sh"
9 # LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP
13 META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT META_NAME META_GROUP
17 META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT META_NAME META_GROUP
23 local name="$1" meta_db="$_DATA/.index/meta"
25 [ "${name%%/*}" != "$name" ] \
26 && meta_db="$_DATA/${name%%/*}/.index/meta"
27 name="$(STRING "${name##*/}")"
30 META_LENGTH='' META_WIDTH='' META_HEIGHT='' META_TAGS=''
31 META_COMMENT='' META_NAME='' META_GROUP='' META_GROUPORDER=''
34 read -r META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT \
35 META_NAME META_GROUP META_GROUPORDER
36 elif [ "$name" -a -f "$meta_db" -a -r "$meta_db" ]; then
37 read -r META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT \
38 META_NAME META_GROUP META_GROUPORDER <<-EOF
39 $(grep -F " ${name}${CR}" "$meta_db" |dbmeta_autogroup)
42 if [ "$META_NAME" ]; then
43 META_NAME="$(UNSTRING "${META_NAME%${CR}}")"
44 META_COMMENT="$(UNSTRING "${META_COMMENT#comment=}")"
45 META_TAGS="$(UNSTRING "${META_TAGS#tags=}")"
46 META_GROUP="${META_GROUP#\\}"
54 local name="${1:=${META_NAME}}" tags comment length width height group
55 local LENGTH WIDTH HEIGH TAGS COMMENT NAME GROUP
56 local arg cnt meta_db="$_DATA/.index/meta"
58 [ "${name%%/*}" != "$name" ] \
59 && meta_db="$_DATA/${name%%/*}/.index/meta"
60 name="$(STRING "${name##*/}")"
62 for arg in "$@"; do case $arg in
63 comment=*) comment="${arg#*=}";;
64 tags=*) tags="${arg#*=}";;
65 lenght=*) lenght="${arg#*=}";;
66 width=*) width="${arg#*=}";;
67 height=*) height="${arg#*=}";;
68 group=*) group="${arg#*=}";;
71 if LOCK "$meta_db"; then
72 read -r LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP <<-EOF
73 $(grep -F " ${name}${CR}" "$meta_db")
75 if [ ! "$NAME" ]; then
79 printf '%i %i %i tags=%s comment=%s %s\r %s\n' \
80 "${length:-${length-${LENGTH}}${length+0}}" \
81 "${width:-${width-${WIDTH}}${width+0}}" \
82 "${height:-${height-${HEIGHT}}${height+0}}" \
83 "$(STRING "${tags-$(UNSTRING "${TAGS#tags=}")}")" \
84 "$(STRING "${comment-$(UNSTRING "${COMMENT#comment=}")}")" \
85 "${NAME%${CR}}" "${group:-${GROUP:-\\}}" \
88 grep -vF " ${name}${CR}" "$meta_db" >>"${meta_db}.$$"
90 mv -- "${meta_db}.$$" "${meta_db}"
98 local name="$1" meta_db="$_DATA/.index/meta"
99 local LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP
101 [ "${name%%/*}" != "$name" ] \
102 && meta_db="$_DATA/${name%%/*}/.index/meta"
103 name="$(STRING "${name##*/}")"
105 if LOCK "$meta_db"; then
106 while read -r LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP; do
107 if [ "$name" = "${NAME%${CR}}" ]; then
112 printf '0 0 0 tags=\\ comment=\\ %s\r \\\n' \
113 "${name}" >>"$meta_db"
121 local name="$1" meta_db="$_DATA/.index/meta"
122 local LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP
124 [ "${name%%/*}" != "$name" ] \
125 && meta_db="$_DATA/${name%%/*}/.index/meta"
126 name="$(STRING "${name##*/}")"
128 if LOCK "$meta_db"; then
129 while read -r LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP; do
130 [ "$name" = "${NAME%${CR}}" ] \
131 || printf '%i %i %i tags=%s comment=%s %s\r %s\n' \
132 "$length" "$width" "$height" "${TAGS#tags=}" \
133 "${COMMENT#comment=}" "${NAME%${CR}}" "${GROUP:-\\}"
134 done <"$meta_db" >"${meta_db}.$$"
136 mv -- "${meta_db}.$$" "$meta_db"
145 local LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP
147 if [ "$#" -eq 0 ]; then
148 find "$_DATA" -path '*/.index/meta'
152 | while read meta; do
154 pfx="${pfx%/.index/meta}"
155 pfx="$(STRING "${pfx#/}")"
156 [ "$pfx" = '\' ] && pfx='' || pfx="${pfx}/"
158 dbmeta_autogroup "$meta" \
159 | while read -r LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP; do
160 printf '%i %i %i %s %s %s%s %s\n' \
161 $LENGTH $WIDTH $HEIGHT "${TAGS}" "${COMMENT}" \
162 "${pfx}" "${NAME}" "${GROUP}"
169 # strip empty group field
171 h; # save original dataset
173 # strip common suffixes of web video sites
174 s;-([0-9a-zA-Z_-]{11}|ph[0-9a-f]{13}|xh[0-9a-zA-Z]{5}|[0-9]{6,})\r;-\r;;
176 # perform auto grouping if group id is missing or empty
179 # only perform ordering if manual group id is present
182 b; # pass invalid records without processing
185 # strip all fields but the name
186 s;^([^\t]+ [^\t]+ [^\t]+ [^\t]+ [^\t]+ )([^\r]+)\r (.+)$;\2;
191 # append ordering field to dataset
196 # strip all fields but the name
197 s;^[^\t]+ [^\t]+ [^\t]+ [^\t]+ [^\t]+ ;;
199 # replace all numeric parts and append numerals to an ordering field
200 # the group id will be made up of only the non-numeric character frame
201 # the ordering field will hold all numbers from the name
202 :X s;^([^0-9]*)([0-9]+)([^\r]*)\r\t?([0-9]*)$;\1\r\3\r \4\2;; tX;
204 # append group id and ordering field to dataset