check-pls - исправлено определение ссылки на канал если перед ней пробелы

This commit is contained in:
2025-03-07 19:45:05 +08:00
parent 2706614751
commit 2ec6b582c4

View File

@@ -21,6 +21,9 @@
################################################# #################################################
awk ' 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 { BEGIN {
total_count=0 total_count=0
success_count=0 success_count=0
@@ -46,13 +49,14 @@ awk '
} }
{ {
sub("\r$", "", $0) # crlf -> lf sub("\r$", "", $0) # crlf -> lf
$0 = trim($0)
if ($0 ~ /^#EXTINF:.+,/) { if ($0 ~ /^#EXTINF:.+,/) {
total_count++ total_count++
channel_name = substr($0, index($0, ",") + 1, length($0)) channel_name = substr($0, index($0, ",") + 1, length($0))
print "\n[" total_count "] " channel_name print "\n[" total_count "] " channel_name
} }
if ($0 ~ /^http(s)?:\/\/.*/) { 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 = "curl -fs --max-time 5 -w \"%{http_code}\" --max-filesize 5000 -o /dev/null " url
cmd | getline http_code cmd | getline http_code
code = close(cmd) code = close(cmd)