2025-06-27 23:41:32 +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 23:41:32 +02:00
|
|
|
|
- name: Checkout Repository
|
2025-06-27 16:30:39 +02:00
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
2025-06-27 23:41:32 +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 23:41:32 +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-28 00:11:35 +02:00
|
|
|
|
- name: Debug File Structure
|
2025-06-27 17:36:55 +02:00
|
|
|
|
run: |
|
2025-06-28 00:11:35 +02:00
|
|
|
|
echo "=== Root Directory ==="
|
|
|
|
|
ls -la
|
|
|
|
|
echo ""
|
|
|
|
|
echo "=== Scripts Directory ==="
|
|
|
|
|
ls -la scripts/
|
|
|
|
|
echo ""
|
|
|
|
|
echo "=== Check for Import File ==="
|
|
|
|
|
if [ -f bulk_import.m3u ]; then
|
|
|
|
|
echo "✅ bulk_import.m3u found in root ($(wc -l < bulk_import.m3u) lines)"
|
|
|
|
|
else
|
|
|
|
|
echo "❌ bulk_import.m3u not found in root"
|
2025-06-27 23:38:39 +02:00
|
|
|
|
fi
|
2025-06-28 00:11:35 +02:00
|
|
|
|
|
|
|
|
|
- name: Setup Directories
|
|
|
|
|
run: |
|
|
|
|
|
mkdir -p config
|
|
|
|
|
mkdir -p backups
|
2025-06-28 00:57:29 +02:00
|
|
|
|
mkdir -p reports/logs
|
|
|
|
|
mkdir -p templates
|
2025-06-28 00:11:35 +02:00
|
|
|
|
|
|
|
|
|
# Create scripts/__init__.py if missing
|
|
|
|
|
if [ ! -f scripts/__init__.py ]; then
|
|
|
|
|
echo '# Scripts package' > scripts/__init__.py
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
- name: Run Playlist Generation
|
|
|
|
|
run: |
|
|
|
|
|
echo "=== Running playlist generation ==="
|
|
|
|
|
python scripts/generate_playlist.py
|
2025-06-27 17:36:55 +02:00
|
|
|
|
|
2025-06-27 23:42:36 +02:00
|
|
|
|
- name: Check Results
|
2025-06-27 17:36:55 +02:00
|
|
|
|
run: |
|
2025-06-28 00:11:35 +02:00
|
|
|
|
echo "=== Final Results ==="
|
|
|
|
|
ls -la
|
|
|
|
|
|
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")
|
2025-06-28 00:11:35 +02:00
|
|
|
|
echo "✅ playlist.m3u generated with $CHANNEL_COUNT channels"
|
|
|
|
|
echo "File size: $(du -h playlist.m3u | cut -f1)"
|
|
|
|
|
else
|
|
|
|
|
echo "❌ playlist.m3u not generated"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -f channels.txt ]; then
|
|
|
|
|
echo "=== channels.txt status ==="
|
|
|
|
|
echo "Size: $(du -h channels.txt | cut -f1)"
|
|
|
|
|
echo "Lines: $(wc -l < channels.txt)"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
fi
|
2025-06-27 17:51:10 +02:00
|
|
|
|
|
2025-06-28 00:57:29 +02:00
|
|
|
|
# Check logs
|
|
|
|
|
if [ -d reports/logs ]; then
|
|
|
|
|
echo "=== Logs directory ==="
|
|
|
|
|
ls -la reports/logs/
|
|
|
|
|
fi
|
|
|
|
|
|
2025-06-27 23:42:36 +02:00
|
|
|
|
- name: Commit Changes
|
2025-06-27 16:30:39 +02:00
|
|
|
|
run: |
|
2025-06-28 00:57:29 +02:00
|
|
|
|
echo "=== Preparing to commit (excluding docs) ==="
|
|
|
|
|
|
|
|
|
|
# Remove docs folder from tracking if it exists
|
|
|
|
|
if [ -d docs ]; then
|
|
|
|
|
echo "Removing docs folder from repository"
|
|
|
|
|
git rm -rf docs/ || true
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Remove old playlist_update.log from root if it exists
|
|
|
|
|
if [ -f playlist_update.log ]; then
|
|
|
|
|
echo "Removing old playlist_update.log from root"
|
|
|
|
|
git rm playlist_update.log || true
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Add specific files/directories only
|
|
|
|
|
git add bulk_import.m3u || true
|
|
|
|
|
git add channels.txt || true
|
|
|
|
|
git add playlist.m3u || true
|
|
|
|
|
git add scripts/ || true
|
|
|
|
|
git add config/ || true
|
|
|
|
|
git add reports/ || true
|
|
|
|
|
git add backups/ || true
|
|
|
|
|
git add templates/ || true
|
|
|
|
|
git add .forgejo/ || true
|
|
|
|
|
git add README.md || true
|
|
|
|
|
|
|
|
|
|
# Explicitly do NOT add docs folder or old logs
|
|
|
|
|
echo "Skipping docs/ folder and old logs"
|
|
|
|
|
|
2025-06-27 23:42:36 +02:00
|
|
|
|
if ! git diff --staged --quiet; then
|
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-28 00:57:29 +02:00
|
|
|
|
|
|
|
|
|
git commit -m "📺 Updated playlist: $CHANNEL_COUNT channels ($(date '+%Y-%m-%d %H:%M')) - Clean repo"
|
2025-06-27 23:42:36 +02:00
|
|
|
|
git push
|
2025-06-28 00:57:29 +02:00
|
|
|
|
|
|
|
|
|
echo "✅ Repository updated (docs excluded)"
|
|
|
|
|
else
|
|
|
|
|
echo "ℹ️ No changes to commit"
|
2025-06-27 18:21:57 +02:00
|
|
|
|
fi
|