2025-06-27 17:36:55 +02:00
|
|
|
|
name: 📺 Generate M3U Playlist
|
2025-06-27 16:30:39 +02:00
|
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches:
|
|
|
|
|
- main
|
|
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
build:
|
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
|
steps:
|
2025-06-27 17:36:55 +02:00
|
|
|
|
- name: 📥 Checkout Repository
|
2025-06-27 16:30:39 +02:00
|
|
|
|
uses: actions/checkout@v4
|
2025-06-27 18:21:57 +02:00
|
|
|
|
with:
|
|
|
|
|
fetch-depth: 0
|
2025-06-27 16:30:39 +02:00
|
|
|
|
|
2025-06-27 17:36:55 +02:00
|
|
|
|
- name: 🐍 Set up Python
|
2025-06-27 16:30:39 +02:00
|
|
|
|
uses: actions/setup-python@v5
|
|
|
|
|
with:
|
2025-06-27 17:36:55 +02:00
|
|
|
|
python-version: '3.11'
|
2025-06-27 16:30:39 +02:00
|
|
|
|
|
2025-06-27 17:36:55 +02:00
|
|
|
|
- name: ⚙️ Configure Git
|
2025-06-27 16:30:39 +02:00
|
|
|
|
run: |
|
|
|
|
|
git config --local user.email "actions@forgejo.plainrock127.xyz"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
git config --local user.name "IPTV Playlist Bot"
|
2025-06-27 16:30:39 +02:00
|
|
|
|
|
2025-06-27 18:01:10 +02:00
|
|
|
|
- name: 🔍 Check files before processing
|
2025-06-27 16:30:39 +02:00
|
|
|
|
run: |
|
2025-06-27 17:36:55 +02:00
|
|
|
|
echo "=== Repository Status ==="
|
2025-06-27 17:51:10 +02:00
|
|
|
|
ls -la
|
|
|
|
|
|
2025-06-27 18:01:10 +02:00
|
|
|
|
echo "=== Checking key files ==="
|
2025-06-27 17:51:10 +02:00
|
|
|
|
if [ -f scripts/generate_playlist.py ]; then
|
2025-06-27 18:01:10 +02:00
|
|
|
|
echo "✅ scripts/generate_playlist.py found"
|
2025-06-27 17:51:10 +02:00
|
|
|
|
else
|
2025-06-27 18:01:10 +02:00
|
|
|
|
echo "❌ scripts/generate_playlist.py missing"
|
2025-06-27 17:51:10 +02:00
|
|
|
|
fi
|
|
|
|
|
|
2025-06-27 23:38:39 +02:00
|
|
|
|
if [ -d scripts ]; then
|
|
|
|
|
echo "✅ scripts/ directory found"
|
|
|
|
|
echo " Scripts directory contents:"
|
|
|
|
|
ls -la scripts/
|
|
|
|
|
else
|
|
|
|
|
echo "❌ scripts/ directory missing"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -f scripts/__init__.py ]; then
|
|
|
|
|
echo "✅ scripts/__init__.py found (Python package)"
|
|
|
|
|
else
|
|
|
|
|
echo "⚠️ scripts/__init__.py missing - will create"
|
|
|
|
|
fi
|
|
|
|
|
|
2025-06-27 17:36:55 +02:00
|
|
|
|
if [ -f channels.txt ]; then
|
2025-06-27 18:01:10 +02:00
|
|
|
|
echo "✅ channels.txt found ($(wc -l < channels.txt) lines)"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
else
|
2025-06-27 18:01:10 +02:00
|
|
|
|
echo "ℹ️ channels.txt not found"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
fi
|
2025-06-27 17:51:10 +02:00
|
|
|
|
|
2025-06-27 17:36:55 +02:00
|
|
|
|
if [ -f bulk_import.m3u ]; then
|
2025-06-27 18:01:10 +02:00
|
|
|
|
echo "✅ bulk_import.m3u found ($(wc -l < bulk_import.m3u) lines)"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
else
|
2025-06-27 18:01:10 +02:00
|
|
|
|
echo "ℹ️ bulk_import.m3u not found (normal if no import)"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
fi
|
|
|
|
|
|
2025-06-27 23:38:39 +02:00
|
|
|
|
- name: 🔧 Setup Python package structure
|
|
|
|
|
run: |
|
|
|
|
|
echo "=== Setting up Python package structure ==="
|
|
|
|
|
|
|
|
|
|
# Create __init__.py if it doesn't exist
|
|
|
|
|
if [ ! -f scripts/__init__.py ]; then
|
|
|
|
|
echo "Creating scripts/__init__.py..."
|
|
|
|
|
cat > scripts/__init__.py << 'EOF'
|
|
|
|
|
"""
|
|
|
|
|
IPTV Playlist Generator Scripts Package
|
|
|
|
|
Modular components for playlist generation and management.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
__version__ = "2.0.0"
|
|
|
|
|
__author__ = "IPTV Playlist Generator"
|
|
|
|
|
EOF
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Create config directory
|
|
|
|
|
mkdir -p config
|
|
|
|
|
mkdir -p backups
|
|
|
|
|
mkdir -p reports
|
|
|
|
|
|
|
|
|
|
echo "✅ Package structure ready"
|
|
|
|
|
|
2025-06-27 17:36:55 +02:00
|
|
|
|
- name: 🚀 Generate M3U Playlist
|
|
|
|
|
run: |
|
2025-06-27 18:01:10 +02:00
|
|
|
|
echo "=== Running playlist generation ==="
|
2025-06-27 23:38:39 +02:00
|
|
|
|
|
|
|
|
|
# Change to scripts directory and run
|
|
|
|
|
cd scripts
|
|
|
|
|
python generate_playlist.py
|
|
|
|
|
|
|
|
|
|
# Move generated files back to root if needed
|
|
|
|
|
if [ -f playlist.m3u ]; then
|
|
|
|
|
mv playlist.m3u ../
|
|
|
|
|
fi
|
|
|
|
|
if [ -f playlist_update.log ]; then
|
|
|
|
|
mv playlist_update.log ../
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Go back to root
|
|
|
|
|
cd ..
|
2025-06-27 17:36:55 +02:00
|
|
|
|
|
2025-06-27 18:01:10 +02:00
|
|
|
|
- name: 📊 Check results
|
2025-06-27 17:36:55 +02:00
|
|
|
|
run: |
|
2025-06-27 18:01:10 +02:00
|
|
|
|
echo "=== Results ==="
|
2025-06-27 16:30:39 +02:00
|
|
|
|
ls -la
|
2025-06-27 17:51:10 +02:00
|
|
|
|
|
2025-06-27 17:36:55 +02:00
|
|
|
|
if [ -f playlist.m3u ]; then
|
2025-06-27 18:01:10 +02:00
|
|
|
|
CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
|
|
|
|
|
echo "✅ playlist.m3u generated with $CHANNEL_COUNT channels"
|
2025-06-27 23:38:39 +02:00
|
|
|
|
echo "File size: $(du -h playlist.m3u | cut -f1)"
|
2025-06-27 18:01:10 +02:00
|
|
|
|
echo "First 5 lines:"
|
|
|
|
|
head -5 playlist.m3u
|
2025-06-27 17:36:55 +02:00
|
|
|
|
else
|
2025-06-27 18:01:10 +02:00
|
|
|
|
echo "❌ playlist.m3u not generated"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
fi
|
2025-06-27 17:51:10 +02:00
|
|
|
|
|
2025-06-27 18:01:10 +02:00
|
|
|
|
if [ -f playlist_update.log ]; then
|
2025-06-27 23:38:39 +02:00
|
|
|
|
echo "=== Log content (last 50 lines) ==="
|
|
|
|
|
tail -50 playlist_update.log
|
2025-06-27 17:36:55 +02:00
|
|
|
|
else
|
2025-06-27 18:01:10 +02:00
|
|
|
|
echo "❌ No log file found"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
fi
|
2025-06-27 23:38:39 +02:00
|
|
|
|
|
|
|
|
|
# Check for generated reports
|
|
|
|
|
if [ -d reports ] && [ "$(ls -A reports)" ]; then
|
|
|
|
|
echo "=== Generated Reports ==="
|
|
|
|
|
ls -la reports/
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Check for config files
|
|
|
|
|
if [ -d config ] && [ "$(ls -A config)" ]; then
|
|
|
|
|
echo "=== Config Files ==="
|
|
|
|
|
ls -la config/
|
|
|
|
|
fi
|
2025-06-27 17:36:55 +02:00
|
|
|
|
|
2025-06-27 18:21:57 +02:00
|
|
|
|
- name: 💾 Commit and push changes
|
2025-06-27 16:30:39 +02:00
|
|
|
|
run: |
|
2025-06-27 18:21:57 +02:00
|
|
|
|
echo "=== Preparing to commit ==="
|
|
|
|
|
|
|
|
|
|
# Pull latest changes first to avoid conflicts
|
|
|
|
|
git pull origin main || echo "Pull failed, continuing anyway"
|
|
|
|
|
|
2025-06-27 23:38:39 +02:00
|
|
|
|
# Add files (including new modular structure)
|
|
|
|
|
git add scripts/ || true
|
2025-06-27 18:01:10 +02:00
|
|
|
|
git add channels.txt || true
|
|
|
|
|
git add playlist.m3u || true
|
|
|
|
|
git add playlist_update.log || true
|
|
|
|
|
git add config/ || true
|
2025-06-27 23:38:39 +02:00
|
|
|
|
git add reports/ || true
|
|
|
|
|
git add backups/ || true
|
2025-06-27 18:01:10 +02:00
|
|
|
|
git add docs/ || true
|
|
|
|
|
|
|
|
|
|
# Check if anything to commit
|
2025-06-27 16:30:39 +02:00
|
|
|
|
if git diff --staged --quiet; then
|
2025-06-27 18:21:57 +02:00
|
|
|
|
echo "ℹ️ No changes to commit"
|
2025-06-27 16:30:39 +02:00
|
|
|
|
else
|
2025-06-27 17:36:55 +02:00
|
|
|
|
CHANNEL_COUNT="0"
|
|
|
|
|
if [ -f playlist.m3u ]; then
|
|
|
|
|
CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
|
|
|
|
|
fi
|
|
|
|
|
|
2025-06-27 18:21:57 +02:00
|
|
|
|
echo "📝 Committing changes..."
|
2025-06-27 23:38:39 +02:00
|
|
|
|
git commit -m "📺 Updated playlist: $CHANNEL_COUNT channels ($(date '+%Y-%m-%d %H:%M')) [Modular v2.0]"
|
2025-06-27 18:21:57 +02:00
|
|
|
|
|
|
|
|
|
# Try to push, with retry if needed
|
|
|
|
|
echo "🚀 Pushing changes..."
|
|
|
|
|
if ! git push origin main; then
|
|
|
|
|
echo "⚠️ Push failed, trying to pull and push again..."
|
|
|
|
|
git pull origin main --rebase || true
|
|
|
|
|
git push origin main || echo "❌ Push failed again - manual intervention may be needed"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "✅ Changes committed and pushed"
|
|
|
|
|
fi
|