]> git.plutz.net Git - serve0/blobdiff - db_meta.sh
Merge commit 'b931bbd0c30907b9cc956d3707b26b449bf41f76'
[serve0] / db_meta.sh
index 9dfbe4c2460a422a23ac1a956a1d0839b4ce3579..572ebbd30b4bfc0411b736dc5cffd395dc797852 100755 (executable)
@@ -155,32 +155,32 @@ list_meta(){
     pfx="$(STRING "${pfx#/}")"
     [ "$pfx" = '\' ] && pfx='' || pfx="${pfx}/"
 
-    dbmeta_autogroup "$meta" \
-    | while read -r LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP; do
-      printf '%i       %i      %i      %s      %s      %s%s    %s\n' \
-             $LENGTH $WIDTH $HEIGHT "${TAGS}" "${COMMENT}" \
-             "${pfx}" "${NAME}" "${GROUP}"
-    done
+    { printf '%s\n' "$pfx"
+      dbmeta_autogroup "$meta"
+    } | sed -E '
+      1{ h; d; }
+      G;
+      s;^([^\t]+       [^\t]+  [^\t]+  [^\t]+  [^\t]+  )([^\n]+)\n(.*)$;\1\3\2;
+    '
   done
 }
 
 dbmeta_autogroup(){
   sed -E '
+    # strip empty group field
+    s;\r       \\$;\r;;
     h;  # save original dataset
 
     # strip common suffixes of web video sites
     s;-([0-9a-zA-Z_-]{11}|ph[0-9a-f]{13}|xh[0-9a-zA-Z]{5}|[0-9]{6,})\r;-\r;;
 
-    # clear branching status
-    tBRANCH; :BRANCH
-
     # perform auto grouping if group id is missing or empty
-    /\r$/bAUTOGROUP; s;\r      \\$;\r;; tAUTOGROUP;
+    /\r$/bAUTOGROUP;
   
     # only perform ordering if manual group id is present
     /\r        .+$/bAUTOORDER;
 
-    b;
+    b;  # pass invalid records without processing
 
     :AUTOORDER
     # strip all fields but the name