diff --git a/check-pls.sh b/check-pls.sh index 51ed0eb..3eae46b 100755 --- a/check-pls.sh +++ b/check-pls.sh @@ -21,6 +21,9 @@ ################################################# awk ' + function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s } + function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s } + function trim(s) { return rtrim(ltrim(s)); } BEGIN { total_count=0 success_count=0 @@ -46,13 +49,14 @@ awk ' } { sub("\r$", "", $0) # crlf -> lf + $0 = trim($0) if ($0 ~ /^#EXTINF:.+,/) { total_count++ channel_name = substr($0, index($0, ",") + 1, length($0)) print "\n[" total_count "] " channel_name } if ($0 ~ /^http(s)?:\/\/.*/) { - url = sprintf("%c%s%c", 34, $0, 34) # 34 is " + url = sprintf("%c%s%c", 34, $0, 34) # code 34 is double-qoute char (") cmd = "curl -fs --max-time 5 -w \"%{http_code}\" --max-filesize 5000 -o /dev/null " url cmd | getline http_code code = close(cmd)