xcz/.github/workflows/live.yml
2025-04-11 15:58:35 +08:00

70 lines
2.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: 电视直播汇总M3U下载
on:
schedule:
- cron: '55 0 */2 * *' # 每2天凌晨00点55分执行任务上海时区的UTC时间
workflow_dispatch: # 允许手动触发
env:
TZ: Asia/Shanghai # 设置时区为上海
jobs:
download-and-process:
runs-on: ubuntu-latest
permissions:
contents: write # 确保 GITHUB_TOKEN 有写入权限
steps:
- name: 检出仓库
uses: actions/checkout@v2
- name: 设置Python环境
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: 安装依赖
run: |
python -m pip install --upgrade pip
pip install requests
- name: 运行Python脚本
run: python app.py
- name: 检查文件是否生成
run: |
if [ -f "live/live.m3u" ]; then
echo "live.m3u 文件已生成"
else
echo "警告: live.m3u 文件未生成"
fi
if [ -f "live/live.txt" ]; then
echo "live.txt 文件已生成"
else
echo "警告: live.txt 文件未生成"
fi
- name: 插入指定说明文字
run: |
DATE=$(date +"%m/%d")
if [ -f "live/live.m3u" ]; then
sed -i '1i #EXTM3U x-tvg-url="https://epg.v1.mk/fy.xml"' live/live.m3u
sed -i '2i #EXTINF:-1 tvg-logo="https://codeberg.org/alantang/photo/raw/branch/main/photo_2025-03-16_10-57-18.jpg" group-title="收藏频道",更新'"$DATE"'' live/live.m3u
sed -i '3i http://tencentplaygzrb01.gztv.com/live/zonghes.m3u8' live/live.m3u
fi
- name: 提交更改
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
DATE=$(date +"%Y-%m-%d %H:%M:%S")
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git add live/*
if git diff-index --quiet HEAD --; then
echo "没有更改需要提交更新: $DATE"
else
git commit -m "自动更新 M3U 播放列表: $DATE"
git push https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}
fi