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 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 17:36:55 +02:00
|
|
|
- name: 📁 Create directory structure
|
2025-06-27 16:30:39 +02:00
|
|
|
run: |
|
2025-06-27 17:36:55 +02:00
|
|
|
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"
|
2025-06-27 16:30:39 +02:00
|
|
|
|
2025-06-27 17:36:55 +02:00
|
|
|
- name: 🔍 Pre-processing diagnostics
|
2025-06-27 16:30:39 +02:00
|
|
|
run: |
|
2025-06-27 17:36:55 +02:00
|
|
|
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 ==="
|
2025-06-27 16:30:39 +02:00
|
|
|
ls -la
|
2025-06-27 17:36:55 +02:00
|
|
|
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
|
2025-06-27 16:30:39 +02:00
|
|
|
run: |
|
|
|
|
mkdir -p docs
|
2025-06-27 17:36:55 +02:00
|
|
|
[ -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'
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>📺 IPTV Playlist</title>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<style>
|
|
|
|
body { font-family: Arial, sans-serif; margin: 40px; background: #f5f5f5; }
|
|
|
|
.container { max-width: 800px; background: white; padding: 30px; border-radius: 10px; }
|
|
|
|
h1 { color: #333; border-bottom: 3px solid #007acc; padding-bottom: 10px; }
|
|
|
|
.download-btn {
|
|
|
|
display: inline-block; padding: 12px 24px; background: #007acc;
|
|
|
|
color: white; text-decoration: none; border-radius: 5px; margin: 10px 5px;
|
|
|
|
}
|
|
|
|
.download-btn:hover { background: #005a99; }
|
|
|
|
.file-list a {
|
|
|
|
display: block; padding: 10px 15px; color: #007acc;
|
|
|
|
text-decoration: none; border-bottom: 1px solid #eee;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="container">
|
|
|
|
<h1>📺 IPTV Playlist Manager</h1>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<h3>📊 Quick Access</h3>
|
|
|
|
<a href="playlist.m3u" class="download-btn" download>📺 Download Playlist</a>
|
|
|
|
<a href="channels.txt" class="download-btn">📋 View Channels</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<h3>📁 Available Files</h3>
|
|
|
|
<div class="file-list">
|
|
|
|
<a href="playlist.m3u">📺 playlist.m3u - Main IPTV playlist</a>
|
|
|
|
<a href="channels.txt">📋 channels.txt - Channel database</a>
|
|
|
|
<a href="logs/">📊 logs/ - Processing logs</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<p><strong>Last Updated:</strong> <span id="timestamp"></span></p>
|
|
|
|
<script>
|
|
|
|
document.getElementById('timestamp').textContent = new Date().toLocaleString();
|
|
|
|
</script>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF
|
2025-06-27 16:30:39 +02:00
|
|
|
|
2025-06-27 17:36:55 +02:00
|
|
|
- name: 💾 Commit and push changes
|
2025-06-27 16:30:39 +02:00
|
|
|
run: |
|
2025-06-27 17:36:55 +02:00
|
|
|
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/
|
2025-06-27 16:30:39 +02:00
|
|
|
|
|
|
|
git status
|
|
|
|
|
|
|
|
if git diff --staged --quiet; then
|
|
|
|
echo "No changes to commit"
|
2025-06-27 17:36:55 +02:00
|
|
|
exit 0
|
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
|
|
|
|
|
|
|
|
COMMIT_MSG="🎬 Updated IPTV playlist: $CHANNEL_COUNT channels ($(date '+%Y-%m-%d %H:%M'))"
|
|
|
|
git commit -m "$COMMIT_MSG"
|
2025-06-27 16:30:39 +02:00
|
|
|
git push
|
2025-06-27 17:36:55 +02:00
|
|
|
echo "Changes committed successfully!"
|
2025-06-27 16:30:39 +02:00
|
|
|
fi
|
|
|
|
env:
|
2025-06-27 17:36:55 +02:00
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|