mirror of
https://github.com/Free-TV/IPTV.git
synced 2026-09-24 19:17:14 +02:00
Add channel checker, scheduled health checks, and a status dashboard
Builds on the idea in #1145 (a checker that maps failures back to a channel and list, and tells a geo-blocked channel from a dead one) with a few additions: check_channels.py - Standard library only, same as #1145's version. - Adds a `disputed` state: an optional --confirm-dead pass gives ffprobe a second opinion on anything that looks dead over HTTP, before it gets reported as dead. This is one-directional (can only pull a verdict out of `dead`, never push one into it) because ffprobe itself is not reliable enough to trust in the other direction - a known-good DASH channel needed longer than any sane per-channel budget to open while testing this, and a header check alone had already been fooled by an isolated media fragment sitting at a URL that looked like a live channel (a mistake made and caught while triaging #1149/#1151 - see the docstring for the details). - Restructured to share one worker pool across every list in a run instead of a fresh pool per list, which stopped small lists from paying the same wall-clock floor as large ones; a full run across all lists dropped from not finishing in 15 minutes to about 10. - --json writes one record per channel per run, for building a history. generate_dashboard.py - Turns that history into a single self-contained docs/index.html: current state breakdown, an alive-share trend across every run kept, a per-list breakdown, and a searchable/filterable table of everything that is not currently alive. Two new scheduled workflows - check_channels_fast.yml: every 6 hours, HTTP checks only. - check_channels_deep.yml: every 2 days, with --confirm-dead (needs ffmpeg). Both append to .github/checker-history/history.jsonl (pruned to 90 days), then build and deploy the dashboard to GitHub Pages.
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
name: Channel check (deep)
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 6 */2 * *' # every 2 days at 06:00 UTC
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
check-deep:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install ffmpeg (for the ffprobe second opinion on dead channels)
|
||||
run: sudo apt-get update && sudo apt-get install -y ffmpeg
|
||||
|
||||
- name: Run the deep check (HTTP probes + ffprobe confirmation on dead channels)
|
||||
run: |
|
||||
python3 check_channels.py --attempts 3 --timeout 12 --pause 5 --workers 40 --confirm-dead --json run.jsonl | tee check_summary.txt
|
||||
|
||||
- name: Append to history and prune entries older than 90 days
|
||||
run: |
|
||||
mkdir -p .github/checker-history
|
||||
history=".github/checker-history/history.jsonl"
|
||||
touch "$history"
|
||||
cat run.jsonl >> "$history"
|
||||
cutoff=$(date -u -d '90 days ago' +%Y-%m-%dT%H:%M:%SZ)
|
||||
python3 - "$history" "$cutoff" <<'PYEOF'
|
||||
import json, sys
|
||||
path, cutoff = sys.argv[1], sys.argv[2]
|
||||
kept = []
|
||||
with open(path, encoding="utf-8") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line and json.loads(line)["checked_at"] >= cutoff:
|
||||
kept.append(line)
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write("\n".join(kept) + ("\n" if kept else ""))
|
||||
PYEOF
|
||||
|
||||
- name: Commit history
|
||||
run: |
|
||||
git config user.name "ChannelCheckerBot" || true
|
||||
git config user.email "[email protected]" || true
|
||||
git add .github/checker-history/history.jsonl
|
||||
git diff --staged --quiet || git commit --quiet -m "Channel check (deep) - $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
git pull --rebase origin master || true
|
||||
git diff --quiet HEAD @{u} || git push origin HEAD
|
||||
|
||||
- name: Build the status dashboard
|
||||
run: python3 generate_dashboard.py --history .github/checker-history/history.jsonl --out docs/index.html
|
||||
|
||||
- name: Upload dashboard for Pages
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: docs
|
||||
|
||||
- name: Summarize
|
||||
if: always()
|
||||
run: |
|
||||
{
|
||||
echo "## Deep channel check - $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
echo ""
|
||||
echo "Channels that looked \`dead\` over HTTP were given a second opinion by \`ffprobe\`. A channel still reported \`dead\` here survived both checks and is safe to act on; one reported \`disputed\` looked dead over HTTP but ffprobe found a real stream behind it - needs a human look, not an automatic edit."
|
||||
echo ""
|
||||
echo '```'
|
||||
cat check_summary.txt
|
||||
echo '```'
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
deploy-pages:
|
||||
needs: check-deep
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
steps:
|
||||
- id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
@@ -0,0 +1,88 @@
|
||||
name: Channel check (fast)
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 */6 * * *' # every 6 hours
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
check-fast:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Run the fast check (HTTP probes only, no ffprobe)
|
||||
run: |
|
||||
python3 check_channels.py --attempts 3 --timeout 12 --pause 5 --workers 40 --json run.jsonl | tee check_summary.txt
|
||||
|
||||
- name: Append to history and prune entries older than 90 days
|
||||
run: |
|
||||
mkdir -p .github/checker-history
|
||||
history=".github/checker-history/history.jsonl"
|
||||
touch "$history"
|
||||
cat run.jsonl >> "$history"
|
||||
cutoff=$(date -u -d '90 days ago' +%Y-%m-%dT%H:%M:%SZ)
|
||||
python3 - "$history" "$cutoff" <<'PYEOF'
|
||||
import json, sys
|
||||
path, cutoff = sys.argv[1], sys.argv[2]
|
||||
kept = []
|
||||
with open(path, encoding="utf-8") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line and json.loads(line)["checked_at"] >= cutoff:
|
||||
kept.append(line)
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write("\n".join(kept) + ("\n" if kept else ""))
|
||||
PYEOF
|
||||
|
||||
- name: Commit history
|
||||
run: |
|
||||
git config user.name "ChannelCheckerBot" || true
|
||||
git config user.email "[email protected]" || true
|
||||
git add .github/checker-history/history.jsonl
|
||||
git diff --staged --quiet || git commit --quiet -m "Channel check (fast) - $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
git pull --rebase origin master || true
|
||||
git diff --quiet HEAD @{u} || git push origin HEAD
|
||||
|
||||
- name: Build the status dashboard
|
||||
run: python3 generate_dashboard.py --history .github/checker-history/history.jsonl --out docs/index.html
|
||||
|
||||
- name: Upload dashboard for Pages
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: docs
|
||||
|
||||
- name: Summarize
|
||||
if: always()
|
||||
run: |
|
||||
{
|
||||
echo "## Fast channel check - $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
echo ""
|
||||
echo "Every channel probed 3x over HTTP; no ffprobe confirmation (see the *Channel check (deep)* workflow for that). \`blocked\` means geo-restricted, not broken - see \`check_channels.py\` for what each state means."
|
||||
echo ""
|
||||
echo '```'
|
||||
cat check_summary.txt
|
||||
echo '```'
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
deploy-pages:
|
||||
needs: check-fast
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
steps:
|
||||
- id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
Reference in New Issue
Block a user