Update .forgejo/workflows/generate-m3u.yml
This commit is contained in:
parent
dc1ea7ec13
commit
dca7d082bd
1 changed files with 97 additions and 117 deletions
|
@ -2,129 +2,109 @@ name: Generate M3U Playlist with Auto-Organization
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-organize:
|
build-and-organize:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest # Changed to ubuntu-latest for broader Forgejo compatibility
|
||||||
steps:
|
|
||||||
- name: Checkout Repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Configure Git
|
|
||||||
run: |
|
|
||||||
git config --local user.email "actions@forgejo.plainrock127.xyz"
|
|
||||||
git config --local user.name "IPTV Playlist Bot"
|
|
||||||
|
|
||||||
- name: Setup Python Environment
|
|
||||||
run: |
|
|
||||||
echo "Setting up Python environment..."
|
|
||||||
python3 --version
|
|
||||||
echo "Setting up directories..."
|
|
||||||
mkdir -p reports/daily reports/logs backups config
|
|
||||||
echo "Setup completed"
|
|
||||||
|
|
||||||
- name: Check Import File
|
steps:
|
||||||
run: |
|
- name: Checkout Repository
|
||||||
echo "Checking import file..."
|
uses: actions/checkout@v4
|
||||||
if [ -f bulk_import.m3u ]; then
|
|
||||||
LINES=$(wc -l < bulk_import.m3u)
|
- name: Configure Git
|
||||||
echo "Found bulk_import.m3u with $LINES lines"
|
run: |
|
||||||
else
|
git config --local user.email "actions@forgejo.plainrock127.xyz"
|
||||||
echo "Creating empty bulk_import.m3u"
|
git config --local user.name "IPTV Playlist Bot"
|
||||||
echo '#EXTM3U' > bulk_import.m3u
|
|
||||||
fi
|
- name: Setup Python Environment
|
||||||
|
run: |
|
||||||
|
echo "Setting up Python environment..."
|
||||||
|
python3 --version
|
||||||
|
echo "Setting up directories..."
|
||||||
|
mkdir -p reports/daily reports/logs backups config
|
||||||
|
echo "Setup completed"
|
||||||
|
|
||||||
- name: Verify Scripts Directory
|
- name: Check Import File
|
||||||
run: |
|
run: |
|
||||||
echo "Checking scripts directory..."
|
echo "Checking import file..."
|
||||||
if [ -d scripts ]; then
|
if [ -f bulk_import.m3u ]; then
|
||||||
echo "Scripts directory exists"
|
LINES=$(wc -l < bulk_import.m3u)
|
||||||
ls -la scripts/
|
echo "Found bulk_import.m3u with $LINES lines"
|
||||||
else
|
else
|
||||||
echo "Scripts directory not found!"
|
echo "Creating empty bulk_import.m3u"
|
||||||
exit 1
|
echo '#EXTM3U' > bulk_import.m3u
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Run Playlist Generation
|
- name: Verify Scripts Directory
|
||||||
run: |
|
run: |
|
||||||
echo "Running playlist generation..."
|
echo "Checking scripts directory..."
|
||||||
cd scripts
|
if [ -d scripts ]; then
|
||||||
if [ -f generate_playlist.py ]; then
|
echo "Scripts directory exists"
|
||||||
echo "Found generate_playlist.py, executing..."
|
ls -la scripts/
|
||||||
python3 generate_playlist.py
|
else
|
||||||
echo "Playlist generation completed"
|
echo "Scripts directory not found!"
|
||||||
else
|
exit 1
|
||||||
echo "Error: generate_playlist.py not found"
|
fi
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Create Simple Report
|
- name: Run Playlist Generation
|
||||||
run: |
|
run: |
|
||||||
echo "Creating report..."
|
echo "Running playlist generation..."
|
||||||
if [ -f playlist.m3u ]; then
|
python3 scripts/generate_playlist.py
|
||||||
CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
|
|
||||||
echo "Found $CHANNELS channels in playlist"
|
|
||||||
|
|
||||||
DATE=$(date +%Y%m%d_%H%M%S)
|
|
||||||
REPORT="reports/daily/report_$DATE.md"
|
|
||||||
|
|
||||||
echo "# Playlist Report" > "$REPORT"
|
|
||||||
echo "Generated: $(date)" >> "$REPORT"
|
|
||||||
echo "Channels: $CHANNELS" >> "$REPORT"
|
|
||||||
|
|
||||||
echo "Report created: $REPORT"
|
|
||||||
else
|
|
||||||
echo "No playlist found"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Clean Old Reports
|
- name: Clean Old Reports
|
||||||
run: |
|
run: |
|
||||||
echo "Cleaning old reports..."
|
echo "Cleaning old reports..."
|
||||||
cd reports/daily
|
# Ensure we are in the correct directory before listing files
|
||||||
if ls *.md >/dev/null 2>&1; then
|
if [ -d reports/daily ]; then
|
||||||
COUNT=$(ls *.md | wc -l)
|
cd reports/daily || exit 1 # Exit if directory change fails
|
||||||
echo "Found $COUNT reports"
|
if ls *.md >/dev/null 2>&1; then
|
||||||
if [ "$COUNT" -gt 3 ]; then
|
COUNT=$(ls *.md | wc -l)
|
||||||
echo "Removing excess reports..."
|
echo "Found $COUNT reports"
|
||||||
ls -t *.md | tail -n +4 | xargs rm -f
|
if [ "$COUNT" -gt 3 ]; then
|
||||||
echo "Cleanup done"
|
echo "Removing excess reports..."
|
||||||
fi
|
ls -t *.md | tail -n +4 | xargs rm -f
|
||||||
else
|
echo "Cleanup done"
|
||||||
echo "No reports to clean"
|
fi
|
||||||
fi
|
else
|
||||||
cd ../..
|
echo "No reports to clean"
|
||||||
|
fi
|
||||||
|
cd ../.. # Go back to root
|
||||||
|
else
|
||||||
|
echo "Reports daily directory not found, skipping cleanup."
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Reset Import File
|
- name: Reset Import File
|
||||||
run: |
|
run: |
|
||||||
echo "Resetting import file..."
|
echo "Resetting import file..."
|
||||||
echo '#EXTM3U' > bulk_import.m3u
|
echo '#EXTM3U' > bulk_import.m3u
|
||||||
echo "Import file reset"
|
echo "Import file reset"
|
||||||
|
|
||||||
- name: Commit Changes
|
- name: Commit Changes
|
||||||
run: |
|
run: |
|
||||||
echo "Committing changes..."
|
echo "Committing changes..."
|
||||||
git add .
|
git add .
|
||||||
if git diff --staged --quiet; then
|
if git diff --staged --quiet; then
|
||||||
echo "No changes to commit"
|
echo "No changes to commit"
|
||||||
else
|
else
|
||||||
CHANNELS="0"
|
CHANNELS="0"
|
||||||
if [ -f playlist.m3u ]; then
|
if [ -f playlist.m3u ]; then
|
||||||
CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
|
CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
|
||||||
fi
|
fi
|
||||||
git commit -m "📺 Updated playlist with $CHANNELS channels - $(date '+%Y-%m-%d %H:%M')"
|
git commit -m "📺 Updated playlist with $CHANNELS channels - $(date '+%Y-%m-%d %H:%M')"
|
||||||
git push
|
git push
|
||||||
echo "Changes committed"
|
echo "Changes committed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Summary
|
- name: Summary
|
||||||
run: |
|
run: |
|
||||||
echo "=== WORKFLOW COMPLETE ==="
|
echo "=== WORKFLOW COMPLETE ==="
|
||||||
if [ -f playlist.m3u ]; then
|
if [ -f playlist.m3u ]; then
|
||||||
CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
|
CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
|
||||||
echo "✅ Playlist has $CHANNELS channels"
|
echo "Final playlist.m3u has $CHANNELS channels."
|
||||||
fi
|
else
|
||||||
echo "✅ Reports updated"
|
echo "No playlist.m3u file found."
|
||||||
echo "✅ Repository cleaned"
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue