Skip to content

EPG

EPG #1438

Workflow file for this run

name: EPG
on:
schedule:
- cron: '0 */2 * * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install jq (for parsing JSON)
run: sudo apt-get install -y jq
- name: Download files from files.json
env:
PROXY_URL: ${{ secrets.PROXY_URL }}
run: |
mkdir -p epg
cat files.json | jq -r 'to_entries[] | "\(.key) \(.value)"' | while read -r filename url; do
echo "Downloading $filename from $url"
xml_file="epg/$filename"
xml_file_tmp="$xml_file.tmp"
if [[ "$url" == "https://assets.livednow.com/epg.xml" ]]; then
curl --retry 5 -x "$PROXY_URL" -o "$xml_file_tmp" "$url"
else
curl --retry 5 -o "$xml_file_tmp" "$url"
fi
if grep -iq "404 Not Found" "$xml_file_tmp"; then
echo "文件包含404错误"
elif [ ! -f "$xml_file" ] || ! cmp -s "$xml_file_tmp" "$xml_file"; then
mv "$xml_file_tmp" "$xml_file"
gzip -kf "$xml_file"
fi
rm -f "$xml_file_tmp"
done
cat files.json | jq -r 'keys[]' | while read -r filename; do
echo "FILENAME_$filename=epg/$filename" >> $GITHUB_ENV
echo "FILENAME_${filename%.xml}.gz=epg/${filename%.xml}.gz" >> $GITHUB_ENV
done
- name: Commit and push changes
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add epg/*
if ! git diff --cached --quiet; then
now_time=$(TZ='Asia/Shanghai' date '+%Y-%m-%d %H:%M:%S')
git commit -m "更新时间:$now_time"
git push origin main || echo "推送到GitHub失败"
else
echo "没有文件可提交"
fi
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.ACCESS_TOKEN }}
repository: taksssss/tv
event-type: sync