mirror of
https://github.com/doms9/iptv.git
synced 2026-04-20 19:37:00 +02:00
e
- switch back to curl for health checks
This commit is contained in:
parent
6e2908535f
commit
00000d9ab6
2 changed files with 41 additions and 30 deletions
5
.github/workflows/health.yml
vendored
5
.github/workflows/health.yml
vendored
|
|
@ -14,11 +14,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Install FFmpeg
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install ffmpeg -y
|
|
||||||
|
|
||||||
- name: Run health.sh
|
- name: Run health.sh
|
||||||
run: bash health.sh
|
run: bash health.sh
|
||||||
|
|
||||||
|
|
|
||||||
66
health.sh
66
health.sh
|
|
@ -8,45 +8,58 @@ STATUSLOG=$(mktemp)
|
||||||
get_status() {
|
get_status() {
|
||||||
local url="$1"
|
local url="$1"
|
||||||
local channel="$2"
|
local channel="$2"
|
||||||
|
local index="$3"
|
||||||
|
local total="$4"
|
||||||
local attempt response status_code
|
local attempt response status_code
|
||||||
|
|
||||||
[[ "$url" != http* ]] && return
|
[[ "$url" != http* ]] && return
|
||||||
|
|
||||||
output=$(
|
printf -v chnl_info "%s (%s)\n" "$channel" "$url"
|
||||||
timeout 10s ffprobe \
|
|
||||||
-v error \
|
response=$(
|
||||||
-rw_timeout 15000000 \
|
curl -skL \
|
||||||
-timeout 15000000 \
|
-A "$UA" \
|
||||||
-select_streams v:0 \
|
-H "Accept: */*" \
|
||||||
-show_entries stream=codec_name \
|
-H "Accept-Language: en-US,en;q=0.9" \
|
||||||
-of csv=p=0 \
|
-H "Connection: keep-alive" \
|
||||||
-headers "User-Agent: $UA" \
|
-o /dev/null \
|
||||||
-analyzeduration 5M \
|
--compressed \
|
||||||
-probesize 5M \
|
--max-time 10 \
|
||||||
-http_persistent 0 \
|
-w "%{http_code}" \
|
||||||
"$url" 2>&1
|
"$url" 2>&1
|
||||||
)
|
)
|
||||||
|
|
||||||
rc=$?
|
case "$response" in
|
||||||
|
|
||||||
if ((rc == 0)); then
|
2* | 3*)
|
||||||
printf '✔️ %s (%s)\n' "$channel" "$url"
|
printf '[%d/%d] ✔️ %s' "$((index + 1))" "$total" "$chnl_info"
|
||||||
|
|
||||||
echo "PASS" >>"$STATUSLOG"
|
echo "PASS" >>"$STATUSLOG"
|
||||||
else
|
;;
|
||||||
printf '❌ %s (%s)\n' "$channel" "$url"
|
|
||||||
|
|
||||||
if [[ "$output" =~ Server\ returned\ ([0-9]{3})\ (.+) ]]; then
|
4* | 5*)
|
||||||
code="${BASH_REMATCH[1]}"
|
printf '[%d/%d] ❌ %s' "$((index + 1))" "$total" "$chnl_info"
|
||||||
echo "| $channel | HTTP Error ($code) | \`$url\` |" >>"$STATUSLOG"
|
|
||||||
elif ((rc == 124)); then
|
echo "| $channel | HTTP Error ($response) | \`$url\` |" >>"$STATUSLOG"
|
||||||
|
|
||||||
|
echo "FAIL" >>"$STATUSLOG"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
printf '[%d/%d] ❌ %s' "$((index + 1))" "$total" "$chnl_info"
|
||||||
|
|
||||||
|
if [[ "$response" == "000" ]]; then
|
||||||
echo "| $channel | HTTP Timeout (408) | \`$url\` |" >>"$STATUSLOG"
|
echo "| $channel | HTTP Timeout (408) | \`$url\` |" >>"$STATUSLOG"
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "| $channel | HTTP Error (000) | \`$url\` |" >>"$STATUSLOG"
|
echo "| $channel | Unknown status ($status_code) | \`$url\` |" >>"$STATUSLOG"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "FAIL" >>"$STATUSLOG"
|
echo "FAIL" >>"$STATUSLOG"
|
||||||
fi
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
check_links() {
|
check_links() {
|
||||||
|
|
@ -54,7 +67,7 @@ check_links() {
|
||||||
channel_num=0
|
channel_num=0
|
||||||
name=""
|
name=""
|
||||||
|
|
||||||
echo -e "Checking $total_urls links from: $base_file\n"
|
printf "Checking %d links from %s\n" "$total_urls" "$base_file"
|
||||||
|
|
||||||
echo "| Channel | Error (Code) | Link |" >"$STATUSLOG"
|
echo "| Channel | Error (Code) | Link |" >"$STATUSLOG"
|
||||||
echo "| ------- | ------------ | ---- |" >>"$STATUSLOG"
|
echo "| ------- | ------------ | ---- |" >>"$STATUSLOG"
|
||||||
|
|
@ -64,11 +77,14 @@ check_links() {
|
||||||
|
|
||||||
if [[ "$line" == \#EXTINF* ]]; then
|
if [[ "$line" == \#EXTINF* ]]; then
|
||||||
name=$(echo "$line" | sed -n 's/.*tvg-name="\([^"]*\)".*/\1/p')
|
name=$(echo "$line" | sed -n 's/.*tvg-name="\([^"]*\)".*/\1/p')
|
||||||
|
|
||||||
[[ -z "$name" ]] && name="Channel $channel_num"
|
[[ -z "$name" ]] && name="Channel $channel_num"
|
||||||
|
|
||||||
elif [[ "$line" =~ ^https?:// ]]; then
|
elif [[ "$line" =~ ^https?:// ]]; then
|
||||||
while (($(jobs -rp | wc -l) >= MAX_JOBS)); do sleep 0.2; done
|
while (($(jobs -rp | wc -l) >= MAX_JOBS)); do sleep 0.2; done
|
||||||
get_status "$line" "$name" &
|
|
||||||
|
get_status "$line" "$name" "$channel_num" "$total_urls" &
|
||||||
|
|
||||||
((channel_num++))
|
((channel_num++))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue