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"
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