Update .forgejo/workflows/generate-m3u.yml
Some checks failed
📺 Generate M3U Playlist / build (push) Failing after 1m8s

This commit is contained in:
stoney420 2025-06-27 17:51:10 +02:00
parent aae167acf0
commit 901e2618c6

View file

@ -23,150 +23,295 @@ jobs:
git config --local user.email "actions@forgejo.plainrock127.xyz" git config --local user.email "actions@forgejo.plainrock127.xyz"
git config --local user.name "IPTV Playlist Bot" git config --local user.name "IPTV Playlist Bot"
- name: 📁 Create directory structure - name: 📁 Create directory structure and initial files
run: | run: |
echo "=== Creating directory structure ===" echo "=== Creating directory structure ==="
mkdir -p logs config templates scripts docs 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" 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
- name: 🔍 Pre-processing diagnostics - name: 🔍 Pre-processing diagnostics
run: | run: |
echo "=== Repository Status ===" echo "=== Repository Status ==="
pwd && whoami && ls -la echo "Directory: $(pwd)"
echo "=== File Status ===" echo "User: $(whoami)"
if [ -f channels.txt ]; then echo "Files:"
echo "channels.txt: $(wc -l < channels.txt) lines" ls -la
echo "=== Checking required files ==="
echo "scripts/generate_playlist.py:"
if [ -f scripts/generate_playlist.py ]; then
echo " ✅ Found"
else else
echo "channels.txt: Not found" 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 fi
if [ -f bulk_import.m3u ]; then
echo "bulk_import.m3u: $(wc -l < bulk_import.m3u) lines" echo "channels.txt:"
if [ -f channels.txt ]; then
echo " ✅ Found ($(wc -l < channels.txt) lines)"
else else
echo "bulk_import.m3u: Not found" echo " ❌ Missing"
fi
echo "bulk_import.m3u:"
if [ -f bulk_import.m3u ]; then
echo " ✅ Found ($(wc -l < bulk_import.m3u) lines)"
else
echo " Not found (this is normal if no import needed)"
fi fi
- name: 🚀 Generate M3U Playlist - name: 🚀 Generate M3U Playlist
run: | run: |
echo "Starting playlist generation..." 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..."
python scripts/generate_playlist.py python scripts/generate_playlist.py
echo "✅ Playlist generation completed"
- name: 📊 Post-processing diagnostics - name: 📊 Post-processing diagnostics
run: | run: |
echo "=== Processing Results ===" echo "=== Processing Results ==="
echo "Files after processing:"
ls -la ls -la
echo "=== Checking outputs ==="
if [ -f playlist.m3u ]; then if [ -f playlist.m3u ]; then
echo "playlist.m3u: Generated ($(wc -l < playlist.m3u) lines)" 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/^/ /'
else else
echo "playlist.m3u: Not generated" echo "playlist.m3u: Not generated"
fi fi
if [ -f bulk_import.m3u ]; then if [ -f bulk_import.m3u ]; then
echo "bulk_import.m3u: Still exists" echo "⚠️ bulk_import.m3u: Still exists (cleanup may have failed)"
else else
echo "bulk_import.m3u: Cleaned up" echo "bulk_import.m3u: Cleaned up or not present"
fi fi
echo "=== Logs ==="
if [ -f logs/playlist_update.log ]; then echo "=== Checking logs ==="
echo "Main log (last 10 lines):" if [ -d logs ]; then
tail -10 logs/playlist_update.log echo "📁 Log files:"
fi ls -la logs/ || echo "No log files yet"
if [ -f logs/error.log ]; then
echo "Errors found:" if [ -f logs/playlist_update.log ]; then
cat logs/error.log 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
else else
echo "No errors logged" echo "❌ No logs directory created"
fi fi
- name: 📊 Generate statistics - name: 📊 Generate statistics
run: | run: |
echo "=== Playlist Statistics ==="
if [ -f playlist.m3u ]; then if [ -f playlist.m3u ]; then
CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u || echo "0") CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
GROUPS=$(grep -o 'group-title="[^"]*"' playlist.m3u | sort -u | wc -l || echo "0") GROUPS=$(grep -o 'group-title="[^"]*"' playlist.m3u | sort -u | wc -l || echo "0")
echo "Total channels: $CHANNEL_COUNT" TOTAL_LINES=$(wc -l < playlist.m3u)
echo "Number of groups: $GROUPS"
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
else else
echo "No playlist generated" echo "No playlist generated - cannot show statistics"
fi fi
- name: 📦 Prepare deployment - name: 📦 Prepare deployment
run: | run: |
echo "=== Preparing deployment files ==="
mkdir -p docs mkdir -p docs
[ -f playlist.m3u ] && cp playlist.m3u docs/
[ -f channels.txt ] && cp channels.txt docs/
[ -d logs ] && cp -r logs docs/
# 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
cat > docs/index.html << 'EOF' cat > docs/index.html << 'EOF'
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>📺 IPTV Playlist</title> <title>📺 IPTV Playlist Manager</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style> <style>
body { font-family: Arial, sans-serif; margin: 40px; background: #f5f5f5; } body {
.container { max-width: 800px; background: white; padding: 30px; border-radius: 10px; } font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
h1 { color: #333; border-bottom: 3px solid #007acc; padding-bottom: 10px; } 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;
}
.download-btn { .download-btn {
display: inline-block; padding: 12px 24px; background: #007acc; display: inline-block; padding: 14px 28px; background: #3498db;
color: white; text-decoration: none; border-radius: 5px; margin: 10px 5px; color: white; text-decoration: none; border-radius: 8px;
margin: 8px; font-weight: 600; transition: all 0.3s;
} }
.download-btn:hover { background: #005a99; } .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; }
.file-list a { .file-list a {
display: block; padding: 10px 15px; color: #007acc; display: block; padding: 15px 20px; color: #2980b9;
text-decoration: none; border-bottom: 1px solid #eee; text-decoration: none; border-bottom: 1px solid #ecf0f1;
transition: background 0.2s;
} }
.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; }
</style> </style>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<h1>📺 IPTV Playlist Manager</h1> <h1><span class="emoji">📺</span>IPTV Playlist Manager</h1>
<div> <div class="stats">
<h3>📊 Quick Access</h3> <h3><span class="emoji">🚀</span>Quick Access</h3>
<a href="playlist.m3u" class="download-btn" download>📺 Download Playlist</a> <a href="playlist.m3u" class="download-btn" download>
<a href="channels.txt" class="download-btn">📋 View Channels</a> <span class="emoji">📺</span>Download Playlist
</a>
<a href="channels.txt" class="download-btn">
<span class="emoji">📋</span>View Channel Database
</a>
</div> </div>
<h3>📁 Available Files</h3> <h3><span class="emoji">📁</span>Available Files</h3>
<div class="file-list"> <div class="file-list">
<a href="playlist.m3u">📺 playlist.m3u - Main IPTV playlist</a> <a href="playlist.m3u">
<a href="channels.txt">📋 channels.txt - Channel database</a> <span class="emoji">📺</span>playlist.m3u - Main IPTV playlist file
<a href="logs/">📊 logs/ - Processing logs</a> </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>
</div> </div>
<p><strong>Last Updated:</strong> <span id="timestamp"></span></p> <div class="stats">
<script> <p class="timestamp">
document.getElementById('timestamp').textContent = new Date().toLocaleString(); <strong>🕒 Last Updated:</strong>
</script> <span id="timestamp"></span>
</p>
</div>
</div> </div>
<script>
document.getElementById('timestamp').textContent = new Date().toLocaleString();
</script>
</body> </body>
</html> </html>
EOF EOF
echo "✅ Created docs/index.html"
- name: 💾 Commit and push changes - name: 💾 Commit and push changes
run: | run: |
echo "=== Preparing to commit ==="
# Clean up backup files
rm -f *.backup* || true rm -f *.backup* || true
[ -f channels.txt ] && git add channels.txt # Stage files for commit
[ -f playlist.m3u ] && git add playlist.m3u git add channels.txt && echo "✅ Staged channels.txt" || echo "⚠️ channels.txt not changed"
[ -d logs ] && git add logs/ git add playlist.m3u && echo "✅ Staged playlist.m3u" || echo "⚠️ playlist.m3u not found"
[ -d config ] && git add config/ git add logs/ && echo "✅ Staged logs/" || echo "⚠️ logs/ not found"
[ -d docs ] && git add docs/ git add config/ && echo "✅ Staged config/" || echo "⚠️ config/ not changed"
git add docs/ && echo "✅ Staged docs/" || echo "⚠️ docs/ not found"
echo "=== Git status ==="
git status git status
# Check if there are changes to commit
if git diff --staged --quiet; then if git diff --staged --quiet; then
echo "No changes to commit" echo " No changes to commit"
exit 0
else else
# Generate commit statistics
CHANNEL_COUNT="0" CHANNEL_COUNT="0"
if [ -f playlist.m3u ]; then if [ -f playlist.m3u ]; then
CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u || echo "0") CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
fi fi
COMMIT_MSG="🎬 Updated IPTV playlist: $CHANNEL_COUNT channels ($(date '+%Y-%m-%d %H:%M'))" TIMESTAMP=$(date '+%Y-%m-%d %H:%M')
COMMIT_MSG="🎬 Updated IPTV playlist: $CHANNEL_COUNT channels ($TIMESTAMP)"
echo "📝 Committing with message: $COMMIT_MSG"
git commit -m "$COMMIT_MSG" git commit -m "$COMMIT_MSG"
git push git push
echo "Changes committed successfully!" echo "Changes committed and pushed successfully!"
fi fi
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}