-Subproject commit d480b7cb55bbd085b361398bdc4903817de1709a
+Subproject commit 813580b4cdebfe5161ef01bcbd126405c3162d7a
--- /dev/null
+#!/bin/sh
+
+[ -n "$include_indexmeta" ] && return 0
+include_indexmeta="$0"
+
+. "$_EXEC/cgilite/storage.sh"
+file_pattern='^.*\.(mov|ts|mpg|mpeg|mp4|m4v|avi|mkv|flv|sfv|wmv|ogm|ogv|webm|iso|rmvb)$'
+
+meta_name() {
+ fn="$1"
+ fn="${fn##*/}"
+ fn="${fn%.*}"
+ STRING "$fn"
+}
+
+meta_line() {
+ video="$1"
+
+ read l h w <<__EOF
+ $(printf '' \
+ | mplayer -input nodefault-bindings -nosound -vo null -identify -frames 0 "$video" 2>&- \
+ | sort | sed -rn '
+ s:ID_LENGTH=(.*)(\..*)$:\1:p;
+ s:ID_VIDEO_HEIGHT=(.*):\1:p;
+ s:ID_VIDEO_WIDTH=(.*):\1:p;' \
+ | tr '\n' ' '
+ )
+__EOF
+ printf '%i\t%i\t%i\ttags=\tcomment=\t%s\n' \
+ "${l-0}" "${w-0}" "${h-0}" "$(meta_name "$video")"
+}
+
+meta_dir(){
+ dir="${1}"
+ meta="${dir}/.index/meta"
+
+ if [ -d "$dir/.index" -a \! -f "$meta" ] && LOCK "$meta"; then
+ touch "$meta" # preliminary touch to prevent concurrent generators
+ find "$dir" -type f -mindepth 1 -maxdepth 1 \
+ | grep -E "$file_pattern" \
+ | while v="$(line)"; do
+ meta_line "$v"
+ done >"$meta"
+
+ RELEASE "$meta"
+ elif [ -d "$dir/.index" -a "$dir" -nt "$meta" ] && LOCK "$meta"; then
+ touch "$meta"
+ find "$dir" -type f -mindepth 1 -maxdepth 1 \
+ | grep -E "$file_pattern" \
+ | while v="$(line)"; do
+ if [ "$v" -nt "$meta" ]; then
+ grep -qF " $(meta_name "$v")" "$meta" \
+ || meta_line "$v"
+ fi
+ done >>"$meta"
+
+ RELEASE "$meta"
+ fi
+}
#!/bin/sh
+. "$_EXEC/indexmeta.sh"
+
list_item() {
name="$(HTML "$1")"
path="$(HTML "$ITEM/$1")"
"$path" "$(HTML "$QUERY_STRING")" "$name"
elif [ -f "$meta" ]; then
read -r length width height tags comment n <<-EOF
- $(grep -m1 -F " ${1##*/}" "$meta")
+ $(grep -m1 -F " $(meta_name "$1")" "$meta")
EOF
printf '[div .list .file
[a href="%s" [img src="%s?a=thumbnail"][label %s]]
}
list_fs_browse(){
- [ -d "$_DATA/$ITEM/.index" -a \! "$_DATA/$ITEM" -ot "$_DATA/$ITEM/.index/meta" ] \
- && dir="$_DATA/$ITEM" . "$_EXEC/update_meta.sh"
+ meta_dir "$_DATA/$ITEM"
(cd "$_DATA/$ITEM";
find ./ -type d \! -name .index -mindepth 1 -maxdepth 1 \
-exec stat -c '%Y %n' '{}' +
list_fs_index(){
find "$_DATA/$ITEM" -type d -name .index \
| while d="$(line)"; do
- [ ! "${d%/.index}" -ot "$d/meta" ] \
- && dir="${d%/.index}" . "$_EXEC/update_meta.sh"
+ meta_dir "${d%/.index}"
done
(cd "$_DATA/$ITEM";
find ./ \! -path '*/.index/*' -type f \
list_browse(){
meta="$_DATA/$ITEM/.index/meta"
- [ -d "${meta%/meta}" -a \! "$_DATA/$ITEM" -ot "${meta}" ] \
- && dir="$_DATA/$ITEM" . "$_EXEC/update_meta.sh"
+ meta_dir "$_DATA/$ITEM"
(cd "$_DATA/$ITEM";
find ./ -type d \! -name .index -mindepth 1 -maxdepth 1 \
) | cut -d/ -f2- | sort
find ./ -path '*/.index/meta'
) | while meta="$(line)"; do
base="${meta%/.index/meta}"
- [ \! "$_DATA/$ITEM/$base" -ot "$_DATA/$ITEM/$meta" ] \
- && dir="$_DATA/$ITEM/$base" . "$_EXEC/update_meta.sh"
+ meta_dir "$_DATA/$ITEM/$base"
cut -f1,6- <"$_DATA/$ITEM/$meta" \
| while f="$(line)"; do
- [ -e "$_DATA/$ITEM/$base/${f#* }" ] \
- && printf '%s %s\n' "${f%% *}" "${base}/${f#* }"
+ fn="$(printf '%s\n' "$_DATA/$ITEM/$base/${f#* }".*)"
+ fn="${fn%%${BR}*}"; fn="${fn##*/}"
+ [ -e "$_DATA/$ITEM/$base/${fn}" ] \
+ && printf '%s %s\n' "${f%% *}" "${base}/${fn}"
done
done \
| sort -n \
#!/bin/sh
+. "$_EXEC/cgilite/storage.sh"
+
for select in $(seq 1 $(POST_COUNT select)); do
file="$_DATA/$ITEM/$(POST select $select)"
meta="${file%/*}/.index/meta"
fn="${file##*/}"
- while ! mkdir "${meta}.lock"; do
- sleep 1
- ps -o pid \
- | grep -q "$(cat "${meta}.lock/pid")" \
- || break
- done
- printf '%i\n' >"${meta}.lock/pid"
-
- grep -vF " $fn" "$meta" >"${meta}.lock/mtmp"
- read length width height tags comment x <<-EOF
- $(grep -F " $fn" "$meta")
+ if LOCK "$meta"; then
+ grep -vF " $fn" "$meta" >"${meta}.tmp"
+ read length width height tags comment x <<-EOF
+ $(grep -F " $fn" "$meta")
EOF
- tags="$(printf '%s' "${tags#tags=}" | tr , '\n')"
+ tags="$(printf '%s' "${tags#tags=}" | tr , '\n')"
- for tn in $(seq 1 $(POST_COUNT tag)); do
- tags="$tags${BR}$(POST tag $tn |sed -r 's;\t;\\t;g; s;\r;;g;')"
- done
- tags="$tags${BR}$(POST newtag |sed -r 's;\t;\\t;g;')"
+ for tn in $(seq 1 $(POST_COUNT tag)); do
+ tags="$tags${BR}$(POST tag $tn |sed -r 's;\t;\\t;g; s;\r;;g;')"
+ done
+ tags="$tags${BR}$(POST newtag |sed -r 's;\t;\\t;g; s;\r;;g;')"
- printf '%s\t%s\t%s\ttags=%s\t%s\t%s\n' \
- "$length" "$width" "$height" \
- "$(printf %s "$tags" |sort -u |tr '\n' ,)" \
- "$comment" "$fn" \
- >>"${meta}.lock/mtmp"
- mv "${meta}.lock/mtmp" "$meta"
+ printf '%i\t%i\t%i\ttags=%s\t%s\t%s\n' \
+ "$length" "$width" "$height" \
+ "$(printf %s "$tags" |sort -u |tr '\n' ,)" \
+ "$comment" "$fn" \
+ >>"${meta}.tmp"
+ mv "${meta}.tmp" "$meta"
- rm "${meta}.lock/pid"; rmdir "${meta}.lock"
+ RELEASE "$meta"
+ fi
done
+++ /dev/null
-#!/bin/sh
-
-file_pattern='^.*\.(mov|ts|mpg|mpeg|mp4|m4v|avi|mkv|flv|sfv|wmv|ogm|ogv|webm|iso|rmvb)$'
-meta="${dir}/.index/meta"
-
-meta_line() {
- video="$1"
-
- read l h w <<__EOF
- $(printf '' \
- | mplayer -input nodefault-bindings -nosound -vo null -identify -frames 0 "$video" 2>&- \
- | sort | sed -rn '
- s:ID_LENGTH=(.*)(\..*)$:\1:p;
- s:ID_VIDEO_HEIGHT=(.*):\1:p;
- s:ID_VIDEO_WIDTH=(.*):\1:p;' \
- | tr '\n' ' '
- )
-__EOF
- printf '%i\t%i\t%i\ttags=\tcomment=\t%s\n' \
- "$l" "$w" "$h" "${video##*/}"
-}
-
-
-if [ \! -f "$meta" ]; then
- find "$dir" -type f -mindepth 1 -maxdepth 1 \
- | grep -E "$file_pattern" \
- | while v="$(line)"; do
- meta_line "$v"
- done >"$meta"
-else
- find "$dir" -type f -mindepth 1 -maxdepth 1 \
- | grep -E "$file_pattern" \
- | while v="$(line)"; do
- if [ "$v" -nt "$meta" ]; then
- grep -qF " ${v}" "$meta" \
- || meta_line "$v"
- fi
- done >>"$meta"
-fi