X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=db_meta.sh;h=572ebbd30b4bfc0411b736dc5cffd395dc797852;hb=HEAD;hp=d2d6999c0778fa2b19d211d7c9ca8b3cc7ab7dac;hpb=dad9cd471358d165f1de2ce8d5806703ac85f5bb;p=serve0 diff --git a/db_meta.sh b/db_meta.sh index d2d6999..572ebbd 100755 --- a/db_meta.sh +++ b/db_meta.sh @@ -155,36 +155,52 @@ 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 tags=%s comment=%s %s%s\r %s\n' \ - $LENGTH $WIDTH $HEIGHT "${TAGS#tags=}" \ - "${COMMENT#comment=}" "${pfx}" "${NAME%${CR}}" "${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;; + # perform auto grouping if group id is missing or empty - /\r$/bAUTOGROUP; s;\r \\$;\r;; tAUTOGROUP; + /\r$/bAUTOGROUP; - # skip auto grouping if manual group id is present - /\r .+$/b; + # only perform ordering if manual group id is present + /\r .+$/bAUTOORDER; + + b; # pass invalid records without processing + + :AUTOORDER + # strip all fields but the name + s;^([^\t]+ [^\t]+ [^\t]+ [^\t]+ [^\t]+ )([^\r]+)\r (.+)$;\2; + + # reduce to numerals + s;[^0-9]+;;g; + + # append ordering field to dataset + H; g; s;\n;\t;; + b; :AUTOGROUP - # save original dataset - h; - # strip all fields but the name s;^[^\t]+ [^\t]+ [^\t]+ [^\t]+ [^\t]+ ;; - # strip common suffixes of web video sites - s;-([0-9a-zA-Z_-]{11}|ph[0-9a-f]{13}|[0-9]{6,})\r$;-\r;; # replace all numeric parts and append numerals to an ordering field # the group id will be made up of only the non-numeric character frame # the ordering field will hold all numbers from the name - :X s;^([^\r0-9]*)([0-9]+)([^\r0-9]*)\r\t?([0-9]*)$;\1\r\3\r \4\2;; tX; + :X s;^([^0-9]*)([0-9]+)([^\r]*)\r\t?([0-9]*)$;\1\r\3\r \4\2;; tX; # append group id and ordering field to dataset H; g; s;\n;\t;;