Create live.yml

This commit is contained in:
alantang 2025-03-16 14:07:16 +08:00 committed by GitHub
parent 2dc50f1992
commit ebdfefc3c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

64
.github/workflows/live.yml vendored Normal file
View File

@ -0,0 +1,64 @@
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.m3u" ]; then
echo "文件已生成"
else
echo "文件未生成"
exit 1
fi
# 使用 curl 下载内容,并在第 1 到第 3 行插入指定说明文字
- name: Insert lines on line 1 和 2 和 3
run: |
DATE=$(date +"%m/%d")
sed -i '1i #EXTM3U x-tvg-url="https://epg.v1.mk/fy.xml"' 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.m3u
sed -i '3i http://tencentplaygzrb01.gztv.com/live/zonghes.m3u8' live.m3u
- 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.m3u
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