From: Paul Hänsch Date: Tue, 16 Nov 2021 03:27:11 +0000 (+0100) Subject: simplified meta_name function X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;ds=sidebyside;h=a502f8dc64730e7827a57e0071f14d92372bd16d;p=serve0 simplified meta_name function --- diff --git a/indexmeta.sh b/indexmeta.sh old mode 100644 new mode 100755 index 7b37209..87fbd12 --- a/indexmeta.sh +++ b/indexmeta.sh @@ -7,9 +7,8 @@ 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' + local fn="${1##*/}" + STRING "${fn%.*}" } meta_line() { @@ -22,7 +21,7 @@ meta_line() { w="${probe#*width=}" w="${w%%${BR}*}" h="${probe#*height=}" h="${h%%${BR}*}" - printf '%i %i %i tags= comment= %s\n' \ + printf '%i %i %i tags= comment= %s\r\n' \ "${l:-0}" "${w:-0}" "${h:-0}" "$(meta_name "$video")" } @@ -33,7 +32,7 @@ meta_file(){ name="$(meta_name "$file")" if [ -d "${meta%/meta}" ] && LOCK "$meta"; then - grep -avF " ${name}" "$meta" >"$meta.tmp" + grep -avF " ${name}${CR}" "$meta" >"$meta.tmp" meta_line "$file" \ | tee -a "$meta.tmp" mv "$meta.tmp" "$meta" @@ -48,8 +47,8 @@ meta_purge(){ name="$(meta_name "$file")" if [ -d "${meta%/meta}" ] && LOCK "$meta"; then - grep -avF " ${name}" "$meta" >"${meta}.tmp" - grep -aF " ${name}" "$meta" >>"${meta}.trash" + grep -avF " ${name}${CR}" "$meta" >"${meta}.tmp" + grep -aF " ${name}${CR}" "$meta" >>"${meta}.trash" mv "${meta}.tmp" "$meta" RELEASE "$meta" fi @@ -60,11 +59,11 @@ meta_info(){ file="$1"; meta="${file%/*}/.index/meta" if [ -d "${meta%/meta}" ]; then - grep -aF " $(meta_name "$file")" "$meta" \ + grep -aF " $(meta_name "$file")${CR}" "$meta" \ | grep -m1 -axE '[0-9]+ [0-9]+ [0-9]+ tags=[^ ]* comment=[^ ]* .+' \ || meta_file "$file" else - printf '0\t0\t0\ttags=\tcomment=\t%s\r' "$(meta_name "$file")" + printf '0\t0\t0\ttags=\tcomment=\t%s\r\n' "$(meta_name "$file")" fi } @@ -92,7 +91,7 @@ meta_dir(){ -mindepth 1 -maxdepth 1 \ | grep -aE "$file_pattern" \ | while read -r v; do - grep -qF " $(meta_name "$v")" "$meta" \ + grep -qF " $(meta_name "$v")${CR}" "$meta" \ || meta_line "$v" done >>"$meta" touch "$metat"