diff --git a/.forgejo/workflows/generate-m3u.yml b/.forgejo/workflows/generate-m3u.yml index 53278ed..87bc418 100644 --- a/.forgejo/workflows/generate-m3u.yml +++ b/.forgejo/workflows/generate-m3u.yml @@ -1,4 +1,4 @@ -name: Generate M3U Playlist +name: 📺 Generate M3U Playlist on: push: @@ -10,73 +10,163 @@ jobs: build: runs-on: ubuntu-22.04 steps: - - name: Checkout Repository + - name: 📥 Checkout Repository uses: actions/checkout@v4 - - name: Set up Python + - name: 🐍 Set up Python uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.11' - - name: Configure Git + - name: ⚙️ Configure Git run: | git config --local user.email "actions@forgejo.plainrock127.xyz" - git config --local user.name "Gitea Actions Bot" + git config --local user.name "IPTV Playlist Bot" - - name: Set file permissions and debug + - name: 📁 Create directory structure run: | - echo "=== Current user and permissions ===" - whoami - pwd - ls -la - echo "=== Setting file permissions ===" - chmod 664 channels.txt || echo "Could not chmod channels.txt" - chmod 664 bulk_import.m3u || echo "Could not chmod bulk_import.m3u (might not exist)" - chmod 775 . || echo "Could not chmod directory" - echo "=== Files before processing ===" - echo "channels.txt line count:" - wc -l channels.txt || echo "channels.txt not found" - echo "bulk_import.m3u exists:" - ls -la bulk_import.m3u || echo "bulk_import.m3u not found" - - - name: Generate M3U - run: python generate_playlist.py + 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" - - name: Debug after processing + - name: 🔍 Pre-processing diagnostics run: | - echo "=== Files after processing ===" + 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 ===" ls -la - echo "=== channels.txt line count after ===" - wc -l channels.txt || echo "channels.txt not found" - echo "=== bulk_import.m3u still exists? ===" - ls -la bulk_import.m3u || echo "bulk_import.m3u not found (good!)" - echo "=== Log content ===" - cat playlist_update.log || echo "No log file" - echo "=== playlist.m3u line count ===" - wc -l playlist.m3u || echo "playlist.m3u not found" - - - name: Prepare for Pages + 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 run: | mkdir -p docs - cp playlist.m3u docs/playlist.m3u - cp playlist_update.log docs/playlist_update.log || true - - - name: Commit and Push - run: | - git add channels.txt || echo "No channels.txt to add" - git add playlist.m3u || echo "No playlist.m3u to add" - git add playlist_update.log || echo "No playlist_update.log to add" - git add docs/playlist.m3u || echo "No docs/playlist.m3u to add" - git add docs/playlist_update.log || echo "No docs/playlist_update.log to add" + [ -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' + + + + 📺 IPTV Playlist + + + + +
+

📺 IPTV Playlist Manager

+ +
+

📊 Quick Access

+ 📺 Download Playlist + 📋 View Channels +
+ +

📁 Available Files

+
+ 📺 playlist.m3u - Main IPTV playlist + 📋 channels.txt - Channel database + 📊 logs/ - Processing logs +
+ +

Last Updated:

+ +
+ + + EOF + + - name: 💾 Commit and push changes + run: | + 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/ - echo "=== Git status ===" git status if git diff --staged --quiet; then echo "No changes to commit" + exit 0 else - git commit -m "Update M3U playlist via Gitea Actions - $(date)" + 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" git push + echo "Changes committed successfully!" fi env: - GITEA_TOKEN \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file