From f2fd2eb798fa6db408114881bae04b8cd38ca799 Mon Sep 17 00:00:00 2001 From: jcorporation Date: Mon, 29 Jan 2024 23:48:52 +0100 Subject: [PATCH] Upd: normalize language field --- build.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 09ad63d6..c0e6fe8a 100755 --- a/build.sh +++ b/build.sh @@ -218,12 +218,19 @@ normalize_fields() { sed -i -e "s/^#STATE:.*/#STATE:$STATE_UPPER/" "$F" fi # language + local LANGUAGE_LINE="" + LANGUAGE_LINE=$(get_m3u_field "$F" "LANGUAGE") + local NEW_LANGUAGE="" local LANGUAGE="" - LANGUAGE=$(get_m3u_field "$F" "LANGUAGE") - local LANGUAGE_UPPER - LANGUAGE_UPPER=$(ucwords "$LANGUAGE") - LANGUAGE_UPPER=$(trim "$LANGUAGE_UPPER") - if [ "$LANGUAGE" != "$LANGUAGE_UPPER" ] + while read -r -d, LANGUAGE + do + [ "$LANGUAGE" = "" ] && continue + [ "$LANGUAGE" = "&" ] && continue + LANGUAGE=$(ucwords "$LANGUAGE") + NEW_LANGUAGE="$NEW_LANGUAGE, $LANGUAGE" + done < <(sed 's/, /,/g' <<< "$LANGUAGE_LINE,") + NEW_LANGUAGE="${NEW_LANGUAGE:2}" + if [ "$LANGUAGE_LINE" != "$NEW_LANGUAGE" ] then echo "$F: $LANGUAGE -> $LANGUAGE_UPPER" sed -i -e "s/^#LANGUAGE:.*/#LANGUAGE:$LANGUAGE_UPPER/" "$F"