name: 📺 Generate M3U Playlist on: push: branches: - main workflow_dispatch: jobs: build: runs-on: ubuntu-22.04 steps: - name: 📥 Checkout Repository uses: actions/checkout@v4 - name: 🐍 Set up Python uses: actions/setup-python@v5 with: python-version: '3.11' - name: ⚙️ Configure Git run: | git config --local user.email "actions@forgejo.plainrock127.xyz" git config --local user.name "IPTV Playlist Bot" - name: 📁 Create directory structure run: | echo "=== Creating directory structure ===" mkdir -p logs config templates scripts docs chmod 664 channels.txt 2>/dev/null || echo "channels.txt not found" chmod 664 bulk_import.m3u 2>/dev/null || echo "bulk_import.m3u not found" - name: 🔍 Pre-processing diagnostics run: | echo "=== Repository Status ===" pwd && whoami && ls -la echo "=== File Status ===" if [ -f channels.txt ]; then echo "channels.txt: $(wc -l < channels.txt) lines" else echo "channels.txt: Not found" fi if [ -f bulk_import.m3u ]; then echo "bulk_import.m3u: $(wc -l < bulk_import.m3u) lines" else echo "bulk_import.m3u: Not found" fi - name: 🚀 Generate M3U Playlist run: | echo "Starting playlist generation..." python scripts/generate_playlist.py - name: 📊 Post-processing diagnostics run: | echo "=== Processing Results ===" ls -la if [ -f playlist.m3u ]; then echo "playlist.m3u: Generated ($(wc -l < playlist.m3u) lines)" else echo "playlist.m3u: Not generated" fi if [ -f bulk_import.m3u ]; then echo "bulk_import.m3u: Still exists" else echo "bulk_import.m3u: Cleaned up" fi echo "=== Logs ===" if [ -f logs/playlist_update.log ]; then echo "Main log (last 10 lines):" tail -10 logs/playlist_update.log fi if [ -f logs/error.log ]; then echo "Errors found:" cat logs/error.log else echo "No errors logged" fi - name: 📊 Generate statistics run: | if [ -f playlist.m3u ]; then CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u || echo "0") GROUPS=$(grep -o 'group-title="[^"]*"' playlist.m3u | sort -u | wc -l || echo "0") echo "Total channels: $CHANNEL_COUNT" echo "Number of groups: $GROUPS" else echo "No playlist generated" fi - name: 📦 Prepare deployment run: | mkdir -p docs [ -f playlist.m3u ] && cp playlist.m3u docs/ [ -f channels.txt ] && cp channels.txt docs/ [ -d logs ] && cp -r logs docs/ cat > docs/index.html << 'EOF' 📺 IPTV Playlist

📺 IPTV Playlist Manager

📊 Quick Access

📺 Download Playlist 📋 View Channels

📁 Available Files

📺 playlist.m3u - Main IPTV playlist 📋 channels.txt - Channel database 📊 logs/ - Processing logs

Last Updated:

EOF - name: 💾 Commit and push changes run: | rm -f *.backup* || true [ -f channels.txt ] && git add channels.txt [ -f playlist.m3u ] && git add playlist.m3u [ -d logs ] && git add logs/ [ -d config ] && git add config/ [ -d docs ] && git add docs/ git status if git diff --staged --quiet; then echo "No changes to commit" exit 0 else CHANNEL_COUNT="0" if [ -f playlist.m3u ]; then CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u || echo "0") fi COMMIT_MSG="🎬 Updated IPTV playlist: $CHANNEL_COUNT channels ($(date '+%Y-%m-%d %H:%M'))" git commit -m "$COMMIT_MSG" git push echo "Changes committed successfully!" fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}