Update .forgejo/workflows/generate-m3u.yml
Some checks are pending
Generate M3U Playlist with Auto-Organization / build-and-organize (push) Waiting to run

This commit is contained in:
stoney420 2025-06-29 06:00:33 +02:00
parent daf9b9e8d6
commit 8adb6e51c9

View file

@ -1,141 +1,63 @@
name: IPTV Channel Country Detection
name: Generate M3U Playlist with Auto-Organization
on:
push:
branches: [ main, master ]
paths:
- 'bulk_import.m3u'
- 'iptv_country_script.py'
pull_request:
branches: [ main, master ]
branches:
- main
workflow_dispatch:
inputs:
run_processing:
description: 'Run IPTV processing'
required: false
default: 'true'
jobs:
process-iptv-channels:
runs-on: ubuntu-latest
build-and-organize:
runs-on: ubuntu-22.04
steps:
- name: 📦 Checkout Repository
- name: Checkout Repository
uses: actions/checkout@v4
- name: 🐍 Set up Python
uses: actions/setup-python@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: 📋 Install Dependencies
python-version: '3.11' # Ensure Python 3.11 is available
- name: Configure Git
run: |
python -m pip install --upgrade pip
# Add any additional dependencies if needed
# pip install requests beautifulsoup4
- name: 🔍 Check for Input File
git config --local user.email "actions@forgejo.plainrock127.xyz"
git config --local user.name "IPTV Playlist Bot"
- name: Basic Setup
run: |
if [ -f "bulk_import.m3u" ]; then
echo "✅ Found bulk_import.m3u file"
echo "📊 File size: $(stat -f%z bulk_import.m3u 2>/dev/null || stat -c%s bulk_import.m3u) bytes"
echo "📝 First 5 lines:"
head -5 bulk_import.m3u
else
echo "⚠️ No bulk_import.m3u file found"
echo "📝 Creating sample file for testing..."
cat > bulk_import.m3u << 'EOF'
#EXTM3U
#EXTINF:-1 tvg-id="TSN1.ca" tvg-logo="https://raw.githubusercontent.com/tv-logo/tv-logos/main/countries/canada/tsn-1-ca.png" group-title="🇬🇧 United Kingdom",TSN 1
https://ott.udptv.net/stream/iptv/tsn1/master.m3u8
#EXTINF:-1 tvg-id="CBC.ca" tvg-logo="https://raw.githubusercontent.com/tv-logo/tv-logos/main/countries/canada/cbc-ca.png" group-title="🇺🇸 United States",CBC News
https://tvnow.best/api/stream/cbc/news.m3u8
#EXTINF:-1 tvg-id="" tvg-logo="" group-title="DaddyLive USA",DaddyLive Channel
https://daddylive.com/stream123.m3u8
#EXTINF:-1 tvg-id="bbc.one.uk" tvg-logo="https://raw.githubusercontent.com/tv-logo/tv-logos/main/countries/uk/bbc-one-uk.png" group-title="🇬🇧 United Kingdom",BBC One
https://bbc.co.uk/live/bbcone.m3u8
EOF
echo "✅ Sample file created for testing"
fi
- name: 🎯 Run IPTV Channel Processing
echo "Basic setup complete."
- name: Run Playlist Generation
run: |
echo "🚀 Starting IPTV channel processing..."
cd scripts
python generate_playlist.py
- name: 📊 Show Results
echo "Running playlist generation..."
python scripts/generate_playlist.py
- name: Commit and Push if Changes
run: |
if [ -f "playlist.m3u" ]; then
echo "✅ Processing completed successfully!"
echo "📊 Output file size: $(stat -f%z playlist.m3u 2>/dev/null || stat -c%s playlist.m3u) bytes"
echo ""
echo "📝 First 20 lines of processed playlist:"
head -20 playlist.m3u
echo ""
echo "🏁 Last 10 lines of processed playlist:"
tail -10 playlist.m3u
echo ""
echo "📈 Group distribution:"
grep -o 'group-title="[^"]*"' playlist.m3u | sort | uniq -c | sort -nr
else
echo "❌ Processing failed - no output file generated"
exit 1
fi
- name: 📦 Upload Processed Playlist
uses: actions/upload-artifact@v4
if: always()
with:
name: processed-playlist
path: |
playlist.m3u
*.backup_*
retention-days: 30
- name: 💾 Commit Changes (if any)
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
if [ -f "playlist.m3u" ]; then
git add playlist.m3u
git add .
if ! git diff-index --quiet HEAD; then
echo "Changes detected, committing..."
if git diff --staged --quiet; then
echo "📝 No changes to commit"
else
git commit -m "🎯 Auto-processed IPTV playlist - $(date '+%Y-%m-%d %H:%M:%S')"
echo "✅ Changes committed"
# Only push if running on main/master branch and not a PR
if [[ "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == "refs/heads/master" ]] && [[ "${GITHUB_EVENT_NAME}" != "pull_request" ]]; then
echo "🚀 Pushing changes..."
git push
else
echo "📝 Skipping push (not on main branch or is PR)"
fi
fi
fi
- name: 📊 Summary Report
if: always()
run: |
echo "🎯 IPTV Processing Summary"
echo "========================="
echo "📅 Date: $(date)"
echo "🌿 Branch: ${GITHUB_REF##*/}"
echo "📝 Event: ${GITHUB_EVENT_NAME}"
if [ -f "bulk_import.m3u" ]; then
echo "📊 Input channels: $(grep -c '^#EXTINF:' bulk_import.m3u || echo '0')"
fi
if [ -f "playlist.m3u" ]; then
echo "📊 Output channels: $(grep -c '^#EXTINF:' playlist.m3u || echo '0')"
echo "✅ Status: Success"
# --- NEW STEPS ---
# 1. Commit the changes made by this workflow locally first.
# This puts the local repository in a clean state for git pull --rebase.
CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
git commit -m "📺 Workflow generated files: $CHANNELS channels (temp commit for rebase)"
# 2. Pull the latest changes from remote and rebase our local commit on top.
git pull --rebase origin main
# --- END NEW STEPS ---
# Now, push the rebased commit.
git push
echo "Changes committed successfully"
else
echo "❌ Status: Failed"
echo "No changes to commit"
fi
echo ""
echo "🔗 Download processed playlist from artifacts above ⬆️"
- name: Summary
run: |
CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
echo "=== WORKFLOW COMPLETE ==="
echo "✅ Playlist has $CHANNELS channels"