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:51:10 +02:00
|
|
|
|
- name: 📁 Create directory structure and initial files
|
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
|
2025-06-27 17:51:10 +02:00
|
|
|
|
|
|
|
|
|
echo "=== Creating initial config files if they don't exist ==="
|
|
|
|
|
if [ ! -f config/settings.json ]; then
|
|
|
|
|
cat > config/settings.json << 'EOF'
|
|
|
|
|
{
|
|
|
|
|
"remove_duplicates": true,
|
|
|
|
|
"sort_channels": true,
|
|
|
|
|
"validate_urls": false,
|
|
|
|
|
"backup_before_import": true,
|
|
|
|
|
"auto_cleanup_import": true
|
|
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
echo "Created config/settings.json"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ ! -f config/group_overrides.json ]; then
|
|
|
|
|
cat > config/group_overrides.json << 'EOF'
|
|
|
|
|
{
|
|
|
|
|
"ESPN": "Sports",
|
|
|
|
|
"Fox Sports": "Sports",
|
|
|
|
|
"CNN": "News",
|
|
|
|
|
"BBC": "News",
|
|
|
|
|
"Discovery": "Documentary",
|
|
|
|
|
"HBO": "Movies",
|
|
|
|
|
"Disney": "Kids",
|
|
|
|
|
"MTV": "Music"
|
|
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
echo "Created config/group_overrides.json"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "=== Creating initial channels.txt if it doesn't exist ==="
|
|
|
|
|
if [ ! -f channels.txt ]; then
|
|
|
|
|
cat > channels.txt << 'EOF'
|
|
|
|
|
Group = Example
|
|
|
|
|
Stream name = Test Channel
|
|
|
|
|
Logo = https://example.com/logo.png
|
|
|
|
|
EPG id = test.example
|
|
|
|
|
Stream URL = http://example.com/stream
|
|
|
|
|
EOF
|
|
|
|
|
echo "Created initial channels.txt with example channel"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "=== Setting permissions ==="
|
|
|
|
|
chmod 664 channels.txt 2>/dev/null || true
|
|
|
|
|
chmod 664 bulk_import.m3u 2>/dev/null || true
|
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 ==="
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo "Directory: $(pwd)"
|
|
|
|
|
echo "User: $(whoami)"
|
|
|
|
|
echo "Files:"
|
|
|
|
|
ls -la
|
|
|
|
|
|
|
|
|
|
echo "=== Checking required files ==="
|
|
|
|
|
echo "scripts/generate_playlist.py:"
|
|
|
|
|
if [ -f scripts/generate_playlist.py ]; then
|
|
|
|
|
echo " ✅ Found"
|
|
|
|
|
else
|
|
|
|
|
echo " ❌ Missing - this will cause the workflow to fail"
|
|
|
|
|
echo " Please ensure you created the file with the exact path: scripts/generate_playlist.py"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "channels.txt:"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
if [ -f channels.txt ]; then
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo " ✅ Found ($(wc -l < channels.txt) lines)"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
else
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo " ❌ Missing"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
fi
|
2025-06-27 17:51:10 +02:00
|
|
|
|
|
|
|
|
|
echo "bulk_import.m3u:"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
if [ -f bulk_import.m3u ]; then
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo " ✅ Found ($(wc -l < bulk_import.m3u) lines)"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
else
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo " ℹ️ Not found (this is normal if no import needed)"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
- name: 🚀 Generate M3U Playlist
|
|
|
|
|
run: |
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo "=== Starting playlist generation ==="
|
|
|
|
|
if [ ! -f scripts/generate_playlist.py ]; then
|
|
|
|
|
echo "❌ ERROR: scripts/generate_playlist.py not found!"
|
|
|
|
|
echo "Please create this file with the Python script content."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "Running playlist generation..."
|
2025-06-27 17:36:55 +02:00
|
|
|
|
python scripts/generate_playlist.py
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo "✅ Playlist generation completed"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
|
|
|
|
|
- name: 📊 Post-processing diagnostics
|
|
|
|
|
run: |
|
|
|
|
|
echo "=== Processing Results ==="
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo "Files after processing:"
|
2025-06-27 16:30:39 +02:00
|
|
|
|
ls -la
|
2025-06-27 17:51:10 +02:00
|
|
|
|
|
|
|
|
|
echo "=== Checking outputs ==="
|
2025-06-27 17:36:55 +02:00
|
|
|
|
if [ -f playlist.m3u ]; then
|
2025-06-27 17:51:10 +02:00
|
|
|
|
LINES=$(wc -l < playlist.m3u)
|
|
|
|
|
CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
|
|
|
|
|
echo "✅ playlist.m3u: Generated successfully"
|
|
|
|
|
echo " 📊 $LINES total lines, $CHANNELS channels"
|
|
|
|
|
echo " 📄 First few lines:"
|
|
|
|
|
head -5 playlist.m3u | sed 's/^/ /'
|
2025-06-27 17:36:55 +02:00
|
|
|
|
else
|
2025-06-27 17:51: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 17:36:55 +02:00
|
|
|
|
if [ -f bulk_import.m3u ]; then
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo "⚠️ bulk_import.m3u: Still exists (cleanup may have failed)"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
else
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo "✅ bulk_import.m3u: Cleaned up or not present"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
fi
|
2025-06-27 17:51:10 +02:00
|
|
|
|
|
|
|
|
|
echo "=== Checking logs ==="
|
|
|
|
|
if [ -d logs ]; then
|
|
|
|
|
echo "📁 Log files:"
|
|
|
|
|
ls -la logs/ || echo "No log files yet"
|
|
|
|
|
|
|
|
|
|
if [ -f logs/playlist_update.log ]; then
|
|
|
|
|
echo "📋 Main log (last 10 lines):"
|
|
|
|
|
tail -10 logs/playlist_update.log | sed 's/^/ /'
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -f logs/error.log ]; then
|
|
|
|
|
echo "❌ Errors found:"
|
|
|
|
|
cat logs/error.log | sed 's/^/ /'
|
|
|
|
|
else
|
|
|
|
|
echo "✅ No errors logged"
|
|
|
|
|
fi
|
2025-06-27 17:36:55 +02:00
|
|
|
|
else
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo "❌ No logs directory created"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
- name: 📊 Generate statistics
|
|
|
|
|
run: |
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo "=== Playlist Statistics ==="
|
2025-06-27 17:36:55 +02:00
|
|
|
|
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")
|
2025-06-27 17:51:10 +02:00
|
|
|
|
TOTAL_LINES=$(wc -l < playlist.m3u)
|
|
|
|
|
|
|
|
|
|
echo "📺 Total channels: $CHANNEL_COUNT"
|
|
|
|
|
echo "📁 Number of groups: $GROUPS"
|
|
|
|
|
echo "📄 Total lines in M3U: $TOTAL_LINES"
|
|
|
|
|
|
|
|
|
|
if [ "$GROUPS" -gt 0 ]; then
|
|
|
|
|
echo "🏷️ Channel groups:"
|
|
|
|
|
grep -o 'group-title="[^"]*"' playlist.m3u | sed 's/group-title="//;s/"//' | sort | uniq -c | sort -nr | head -10 | sed 's/^/ /'
|
|
|
|
|
fi
|
2025-06-27 17:36:55 +02:00
|
|
|
|
else
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo "❌ No playlist generated - cannot show statistics"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
- name: 📦 Prepare deployment
|
2025-06-27 16:30:39 +02:00
|
|
|
|
run: |
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo "=== Preparing deployment files ==="
|
2025-06-27 16:30:39 +02:00
|
|
|
|
mkdir -p docs
|
2025-06-27 17:36:55 +02:00
|
|
|
|
|
2025-06-27 17:51:10 +02:00
|
|
|
|
# Copy main files
|
|
|
|
|
[ -f playlist.m3u ] && cp playlist.m3u docs/ && echo "✅ Copied playlist.m3u"
|
|
|
|
|
[ -f channels.txt ] && cp channels.txt docs/ && echo "✅ Copied channels.txt"
|
|
|
|
|
[ -d logs ] && cp -r logs docs/ && echo "✅ Copied logs directory"
|
|
|
|
|
|
|
|
|
|
# Create web interface
|
2025-06-27 17:36:55 +02:00
|
|
|
|
cat > docs/index.html << 'EOF'
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html>
|
|
|
|
|
<head>
|
2025-06-27 17:51:10 +02:00
|
|
|
|
<title>📺 IPTV Playlist Manager</title>
|
2025-06-27 17:36:55 +02:00
|
|
|
|
<meta charset="UTF-8">
|
2025-06-27 17:51:10 +02:00
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
2025-06-27 17:36:55 +02:00
|
|
|
|
<style>
|
2025-06-27 17:51:10 +02:00
|
|
|
|
body {
|
|
|
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
|
|
|
margin: 0; padding: 20px; background: #f5f7fa;
|
|
|
|
|
}
|
|
|
|
|
.container {
|
|
|
|
|
max-width: 900px; margin: 0 auto; background: white;
|
|
|
|
|
padding: 30px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.1);
|
|
|
|
|
}
|
|
|
|
|
h1 {
|
|
|
|
|
color: #2c3e50; border-bottom: 3px solid #3498db;
|
|
|
|
|
padding-bottom: 15px; margin-bottom: 30px;
|
|
|
|
|
}
|
2025-06-27 17:36:55 +02:00
|
|
|
|
.download-btn {
|
2025-06-27 17:51:10 +02:00
|
|
|
|
display: inline-block; padding: 14px 28px; background: #3498db;
|
|
|
|
|
color: white; text-decoration: none; border-radius: 8px;
|
|
|
|
|
margin: 8px; font-weight: 600; transition: all 0.3s;
|
2025-06-27 17:36:55 +02:00
|
|
|
|
}
|
2025-06-27 17:51:10 +02:00
|
|
|
|
.download-btn:hover { background: #2980b9; transform: translateY(-2px); }
|
|
|
|
|
.stats {
|
|
|
|
|
background: #ecf0f1; padding: 20px; border-radius: 8px;
|
|
|
|
|
margin: 25px 0; border-left: 4px solid #3498db;
|
|
|
|
|
}
|
|
|
|
|
.file-list { background: #fff; border: 1px solid #bdc3c7; border-radius: 8px; overflow: hidden; }
|
2025-06-27 17:36:55 +02:00
|
|
|
|
.file-list a {
|
2025-06-27 17:51:10 +02:00
|
|
|
|
display: block; padding: 15px 20px; color: #2980b9;
|
|
|
|
|
text-decoration: none; border-bottom: 1px solid #ecf0f1;
|
|
|
|
|
transition: background 0.2s;
|
2025-06-27 17:36:55 +02:00
|
|
|
|
}
|
2025-06-27 17:51:10 +02:00
|
|
|
|
.file-list a:hover { background: #f8f9fa; }
|
|
|
|
|
.file-list a:last-child { border-bottom: none; }
|
|
|
|
|
.emoji { font-size: 1.3em; margin-right: 10px; }
|
|
|
|
|
.timestamp { color: #7f8c8d; font-size: 0.9em; }
|
2025-06-27 17:36:55 +02:00
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<div class="container">
|
2025-06-27 17:51:10 +02:00
|
|
|
|
<h1><span class="emoji">📺</span>IPTV Playlist Manager</h1>
|
2025-06-27 17:36:55 +02:00
|
|
|
|
|
2025-06-27 17:51:10 +02:00
|
|
|
|
<div class="stats">
|
|
|
|
|
<h3><span class="emoji">🚀</span>Quick Access</h3>
|
|
|
|
|
<a href="playlist.m3u" class="download-btn" download>
|
|
|
|
|
<span class="emoji">📺</span>Download Playlist
|
|
|
|
|
</a>
|
|
|
|
|
<a href="channels.txt" class="download-btn">
|
|
|
|
|
<span class="emoji">📋</span>View Channel Database
|
|
|
|
|
</a>
|
2025-06-27 17:36:55 +02:00
|
|
|
|
</div>
|
|
|
|
|
|
2025-06-27 17:51:10 +02:00
|
|
|
|
<h3><span class="emoji">📁</span>Available Files</h3>
|
2025-06-27 17:36:55 +02:00
|
|
|
|
<div class="file-list">
|
2025-06-27 17:51:10 +02:00
|
|
|
|
<a href="playlist.m3u">
|
|
|
|
|
<span class="emoji">📺</span>playlist.m3u - Main IPTV playlist file
|
|
|
|
|
</a>
|
|
|
|
|
<a href="channels.txt">
|
|
|
|
|
<span class="emoji">📝</span>channels.txt - Channel database (editable)
|
|
|
|
|
</a>
|
|
|
|
|
<a href="logs/">
|
|
|
|
|
<span class="emoji">📊</span>logs/ - Processing logs and history
|
|
|
|
|
</a>
|
2025-06-27 17:36:55 +02:00
|
|
|
|
</div>
|
|
|
|
|
|
2025-06-27 17:51:10 +02:00
|
|
|
|
<div class="stats">
|
|
|
|
|
<p class="timestamp">
|
|
|
|
|
<strong>🕒 Last Updated:</strong>
|
|
|
|
|
<span id="timestamp"></span>
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2025-06-27 17:36:55 +02:00
|
|
|
|
</div>
|
2025-06-27 17:51:10 +02:00
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
document.getElementById('timestamp').textContent = new Date().toLocaleString();
|
|
|
|
|
</script>
|
2025-06-27 17:36:55 +02:00
|
|
|
|
</body>
|
|
|
|
|
</html>
|
|
|
|
|
EOF
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo "✅ Created docs/index.html"
|
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:51:10 +02:00
|
|
|
|
echo "=== Preparing to commit ==="
|
|
|
|
|
|
|
|
|
|
# Clean up backup files
|
2025-06-27 17:36:55 +02:00
|
|
|
|
rm -f *.backup* || true
|
|
|
|
|
|
2025-06-27 17:51:10 +02:00
|
|
|
|
# Stage files for commit
|
|
|
|
|
git add channels.txt && echo "✅ Staged channels.txt" || echo "⚠️ channels.txt not changed"
|
|
|
|
|
git add playlist.m3u && echo "✅ Staged playlist.m3u" || echo "⚠️ playlist.m3u not found"
|
|
|
|
|
git add logs/ && echo "✅ Staged logs/" || echo "⚠️ logs/ not found"
|
|
|
|
|
git add config/ && echo "✅ Staged config/" || echo "⚠️ config/ not changed"
|
|
|
|
|
git add docs/ && echo "✅ Staged docs/" || echo "⚠️ docs/ not found"
|
2025-06-27 16:30:39 +02:00
|
|
|
|
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo "=== Git status ==="
|
2025-06-27 16:30:39 +02:00
|
|
|
|
git status
|
|
|
|
|
|
2025-06-27 17:51:10 +02:00
|
|
|
|
# Check if there are changes to commit
|
2025-06-27 16:30:39 +02:00
|
|
|
|
if git diff --staged --quiet; then
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo "ℹ️ No changes to commit"
|
2025-06-27 16:30:39 +02:00
|
|
|
|
else
|
2025-06-27 17:51:10 +02:00
|
|
|
|
# Generate commit statistics
|
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 17:51:10 +02:00
|
|
|
|
TIMESTAMP=$(date '+%Y-%m-%d %H:%M')
|
|
|
|
|
COMMIT_MSG="🎬 Updated IPTV playlist: $CHANNEL_COUNT channels ($TIMESTAMP)"
|
|
|
|
|
|
|
|
|
|
echo "📝 Committing with message: $COMMIT_MSG"
|
2025-06-27 17:36:55 +02:00
|
|
|
|
git commit -m "$COMMIT_MSG"
|
2025-06-27 16:30:39 +02:00
|
|
|
|
git push
|
2025-06-27 17:51:10 +02:00
|
|
|
|
echo "✅ Changes committed and pushed successfully!"
|
2025-06-27 16:30:39 +02:00
|
|
|
|
fi
|
|
|
|
|
env:
|
2025-06-27 17:36:55 +02:00
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|