From: Paul Hänsch Date: Wed, 29 Jan 2020 23:36:03 +0000 (+0100) Subject: massively improved grouping X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=10ea76be79908484f2b93368c3a908bc6df9709d;p=serve0 massively improved grouping --- diff --git a/list.sh b/list.sh index a4bdbc7..8e46ab3 100644 --- a/list.sh +++ b/list.sh @@ -87,38 +87,23 @@ list_filter(){ fi } -groupmatch(){ - a="${1%$CR}" b="${2%$CR}" -# if [ ${#a} -gt ${#b} ]; then -# long="$a" short="$b" -# else -# long="$b" short="$a" -# fi - # com="$(expr substr "$long" 1 $((${#long} * 3 / 4)))" - # com="$(expr substr "$long" 1 $((${#long} - 3)))" - ## Cut off youtube- and other site suffixes. Cut of last three characters - com="$(printf %s "$a" |sed -E 's;-([0-9a-zA-Z_-]{11}|ph[0-9a-f]{13}|[0-9]{8})$;;; s;...$;;;')" - cut="${b#$com}" - if [ "${cut}" != "${b}" ]; then - return 0 - else - return 1 - fi -} - list_order(){ local fm fn fn al length ln h w t c name buffer l if [ $ORDER = Name ]; then sort -k6 |sed 's;^;metashort\t;;' elif [ $ORDER = Group ]; then - { sort -k6; echo '0 0 0 tags= comment= _'; } \ + sed -E ' + :X + s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^ 0-9]*)(-[0-9a-zA-Z_-]{11}\r|-ph[0-9a-f]{13}\r|-[0-9]{8}\r|[0-9]+\+?)(.*)$;\1\r\3 \2;; + tX;' \ + | { sort -n -k7 |sort -s -k6,6; echo '0 0 0 tags= comment= _'; } \ | while read -r length h w t c name; do - if groupmatch "$ln" "$name"; then + if [ "${ln%% *}" = "${name%% *}" ]; then al=$((al + length)) buffer="${buffer}${BR}$length $h $w $t $c $name" else - printf %s\\n "$buffer" |while read -r l; do + printf '%s\n' "$buffer" |while read -r l; do [ "$l" ] && printf '%s %s\n' "$al" "$l" done al="$length" @@ -126,7 +111,8 @@ list_order(){ fi ln="$name" done \ - | sort -sn -k1 |sed -r 's;^[0-9]+\t;metashort\t;;' + | sort -s -n -k1 |sed -r 's;^[0-9]+\t;metashort\t;;' \ + | sed -E ':X s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\r]*)\r([^ ]*) ([^ ]+)( .*)?$;\1\3\2\4;; tX' elif [ $ORDER = Length ]; then sort -sn -k1 |sed 's;^;metashort\t;;' elif [ $ORDER = Date ]; then