]> git.plutz.net Git - serve0/blobdiff - indexmeta.sh
great speed improvement, particularly while casting tag selectors
[serve0] / indexmeta.sh
index 84dd26a2d5b02c4ed1e11989d8b3b78a86f73609..2e4e74f16494305ce92f77578208447096e1b192 100644 (file)
@@ -7,13 +7,16 @@ include_indexmeta="$0"
 file_pattern='^.*\.(mov|ts|mpg|mpeg|mp4|m4v|avi|mkv|flv|sfv|wmv|ogm|ogv|webm|iso|rmvb)$'
 
 meta_name() {
+  local fn
   fn="$1"
   fn="${fn##*/}"
   fn="${fn%.*}"
   STRING "$fn"
+  printf '\r'
 }
 
 meta_line() {
+  local video l w h
   video="$1"
 
   read l h w <<__EOF
@@ -30,7 +33,37 @@ __EOF
          "${l-0}" "${w-0}" "${h-0}" "$(meta_name "$video")"
 }
 
+meta_file(){
+  local file meta name
+  file="$1"
+  meta="${file%/*}/.index/meta"
+  name="$(meta_name "$file")"
+
+  if [ -d "${meta%/meta}" ] && LOCK "$meta"; then
+    grep -vF " ${name}" "$meta" >"$meta.tmp"
+    meta_line "$file" \
+    | tee -a "$meta.tmp"
+    mv "$meta.tmp" "$meta"
+    RELEASE "$meta"
+  fi
+}
+
+meta_info(){
+  local file meta
+  file="$1"
+  meta="${file%/*}/.index/meta"
+
+  if [ -d "${meta%/meta}" ]; then
+    grep -m1 -F "      $(meta_name "$file")" "$meta" \
+    | grep -xE '[0-9]+ [0-9]+  [0-9]+  tags=[^ ]*      comment=[^      ]*      .+' \
+    || meta_file "$file"
+  else
+    printf '0\t0\t0\ttags=\tcomment=\t\r'
+  fi
+}
+
 meta_dir(){
+  local dir meta v
   dir="${1}"
   meta="${dir}/.index/meta"