This commit is contained in:
doms9 2025-10-06 13:14:05 -04:00
parent a464341f16
commit 00000d9795

View file

@ -17,8 +17,21 @@ get_status() {
[[ "$url" != http* ]] && return
for attempt in $(seq 1 "$RETRY_COUNT"); do
response=$(curl -sL -A "$UA" -o /dev/null --max-time 10 -w "%{http_code}" "$url" 2>&1)
response=$(
curl -skL \
-A "$UA" \
-H "Accept: */*" \
-H "Accept-Language: en-US,en;q=0.9" \
-H "Accept-Encoding: gzip, deflate, br" \
-H "Connection: keep-alive" \
-o /dev/null \
--max-time 15 \
-w "%{http_code}" \
"$url" 2>&1
)
[[ "$response" =~ ^[0-9]+$ ]] && break
sleep 1
done
@ -28,7 +41,9 @@ get_status() {
else
echo "| $channel | Curl error | \`$url\` |" >>"$STATUSLOG"
fi
echo "FAIL" >>"$STATUSLOG"
return
fi
@ -36,25 +51,29 @@ get_status() {
case "$status_code" in
200)
if ! curl -sL -A "$UA" --max-time 5 "$url" | head -c 1 | grep -q '.'; then
if ! curl -skL -A "$UA" --max-time 5 "$url" | head -c 1 | grep -q '.'; then
echo "| $channel | Empty body (404) | \`$url\` |" >>"$STATUSLOG"
echo "EMPTY" >>"$STATUSLOG"
else
echo "PASS" >>"$STATUSLOG"
fi
;;
4* | 5*)
echo "| $channel | HTTP Error ($status_code) | \`$url\` |" >>"$STATUSLOG"
echo "FAIL" >>"$STATUSLOG"
;;
*)
if [[ "$status_code" == "000" ]]; then
echo "| $channel | Connection timed out (000) | \`$url\` |" >>"$STATUSLOG"
else
echo "| $channel | Unknown status ($status_code) | \`$url\` |" >>"$STATUSLOG"
fi
echo "FAIL" >>"$STATUSLOG"
;;
esac
}
@ -72,11 +91,13 @@ check_links() {
if [[ "$line" == \#EXTINF* ]]; then
name=$(echo "$line" | sed -n 's/.*tvg-name="\([^"]*\)".*/\1/p')
[[ -z "$name" ]] && name="Channel $channel_num"
elif [[ "$line" =~ ^https?:// ]]; then
while (($(jobs -r | wc -l) >= MAX_JOBS)); do sleep 0.2; done
get_status "$line" "$name" &
((channel_num++))
fi
done < <(cat "$base_file")
wait
@ -85,6 +106,7 @@ check_links() {
write_readme() {
local passed redirected empty failed
passed=$(grep -c '^PASS$' "$STATUSLOG")
empty=$(grep -c '^EMPTY$' "$STATUSLOG")
failed=$(grep -c '^FAIL$' "$STATUSLOG")