Update .forgejo/workflows/generate-m3u.yml
Some checks failed
Generate M3U Playlist / build (push) Failing after 1m48s
Some checks failed
Generate M3U Playlist / build (push) Failing after 1m48s
This commit is contained in:
parent
c7dcd2a6a5
commit
e8a792a46b
1 changed files with 26 additions and 189 deletions
|
@ -1,4 +1,4 @@
|
||||||
name: Generate M3U Playlist with Auto-Cleanup
|
name: Generate M3U Playlist
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
@ -7,14 +7,12 @@ on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-cleanup:
|
build:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.11'
|
||||||
|
|
||||||
|
@ -23,193 +21,32 @@ 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: Pre-Cleanup Repository
|
- name: Clean Repository
|
||||||
run: |
|
run: |
|
||||||
echo "=== Pre-Cleanup Phase ==="
|
find . -name "__pycache__" -type d -exec rm -rf {} + || true
|
||||||
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
|
find . -name "*.pyc" -delete || true
|
||||||
find . -name "*.pyc" -delete 2>/dev/null || true
|
mkdir -p reports/logs
|
||||||
find . -name "*.pyo" -delete 2>/dev/null || true
|
mv *.log reports/logs/ 2>/dev/null || true
|
||||||
find . -name "*_temp*" -type f -delete 2>/dev/null || true
|
|
||||||
find . -name "*.tmp" -delete 2>/dev/null || true
|
- name: Setup
|
||||||
find . -name "*~" -delete 2>/dev/null || true
|
|
||||||
find . -name "*.swp" -delete 2>/dev/null || true
|
|
||||||
mkdir -p reports/logs reports/archive
|
|
||||||
find . -maxdepth 1 -name "*.log" -exec mv {} reports/logs/ \; 2>/dev/null || true
|
|
||||||
find backups -name "*.txt" -type f -mtime +30 -delete 2>/dev/null || true
|
|
||||||
find backups -name "*.txt" -type f -mtime +7 -exec gzip {} \; 2>/dev/null || true
|
|
||||||
echo "Pre-cleanup completed"
|
|
||||||
|
|
||||||
- name: Setup Directories
|
|
||||||
run: |
|
run: |
|
||||||
echo "=== Directory Setup ==="
|
mkdir -p config backups templates
|
||||||
mkdir -p config backups reports/logs reports/archive templates
|
echo '# Scripts package' > scripts/__init__.py
|
||||||
if [ ! -f scripts/__init__.py ]; then
|
|
||||||
echo '# Scripts package' > scripts/__init__.py
|
- name: Generate Playlist
|
||||||
fi
|
run: python scripts/generate_playlist.py
|
||||||
|
|
||||||
- name: Debug File Structure
|
- name: Check Results
|
||||||
run: |
|
run: |
|
||||||
echo "=== File Structure Debug ==="
|
|
||||||
ls -la
|
|
||||||
echo "Scripts directory:"
|
|
||||||
ls -la scripts/ 2>/dev/null || echo "Scripts directory not found"
|
|
||||||
echo "Import file status:"
|
|
||||||
if [ -f bulk_import.m3u ]; then
|
|
||||||
LINES=$(wc -l < bulk_import.m3u)
|
|
||||||
SIZE=$(du -h bulk_import.m3u | cut -f1)
|
|
||||||
echo "bulk_import.m3u found: $LINES lines ($SIZE)"
|
|
||||||
if [ "$LINES" -gt 2 ]; then
|
|
||||||
echo "Contains channels to process"
|
|
||||||
head -3 bulk_import.m3u
|
|
||||||
else
|
|
||||||
echo "Empty - ready for import"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "bulk_import.m3u not found"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Run Playlist Generation
|
|
||||||
run: |
|
|
||||||
echo "=== Playlist Generation ==="
|
|
||||||
if [ ! -f scripts/generate_playlist.py ]; then
|
|
||||||
echo "Error: scripts/generate_playlist.py not found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Starting playlist generation..."
|
|
||||||
python scripts/generate_playlist.py
|
|
||||||
echo "Playlist generation completed"
|
|
||||||
|
|
||||||
- name: Post-Generation Analysis
|
|
||||||
run: |
|
|
||||||
echo "=== Post-Generation Analysis ==="
|
|
||||||
if [ -f playlist.m3u ]; then
|
if [ -f playlist.m3u ]; then
|
||||||
CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u 2>/dev/null || echo "0")
|
CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
|
||||||
FILE_SIZE=$(du -h playlist.m3u | cut -f1)
|
echo "Generated $CHANNELS channels"
|
||||||
echo "Generated playlist.m3u:"
|
|
||||||
echo " Channels: $CHANNEL_COUNT"
|
|
||||||
echo " Size: $FILE_SIZE"
|
|
||||||
echo "Top countries:"
|
|
||||||
if grep -q 'group-title=' playlist.m3u; then
|
|
||||||
grep 'group-title=' playlist.m3u | sed 's/.*group-title="//; s/".*//' | sort | uniq -c | sort -nr | head -5 | while read count country; do
|
|
||||||
echo " $country: $count channels"
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo " No country grouping found"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "playlist.m3u not generated"
|
|
||||||
if [ -f reports/logs/playlist_update.log ]; then
|
|
||||||
echo "Last few log entries:"
|
|
||||||
tail -10 reports/logs/playlist_update.log
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
if [ -f channels.txt ]; then
|
|
||||||
CHANNELS_SIZE=$(du -h channels.txt | cut -f1)
|
- name: Commit
|
||||||
CHANNELS_LINES=$(wc -l < channels.txt)
|
|
||||||
echo "channels.txt: $CHANNELS_SIZE ($CHANNELS_LINES lines)"
|
|
||||||
else
|
|
||||||
echo "channels.txt: Not found"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Final Cleanup and Organization
|
|
||||||
run: |
|
run: |
|
||||||
echo "=== Final Organization ==="
|
git add .
|
||||||
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
|
|
||||||
find . -name "*.pyc" -delete 2>/dev/null || true
|
|
||||||
find . -name "*.swp" -delete 2>/dev/null || true
|
|
||||||
find . -name ".DS_Store" -delete 2>/dev/null || true
|
|
||||||
find . -name "*~" -delete 2>/dev/null || true
|
|
||||||
find . -maxdepth 1 -name "*.log" -exec mv {} reports/logs/ \; 2>/dev/null || true
|
|
||||||
if [ -f bulk_import.m3u ]; then
|
|
||||||
LINE_COUNT=$(wc -l < bulk_import.m3u)
|
|
||||||
if [ "$LINE_COUNT" -gt 2 ]; then
|
|
||||||
echo "Cleaning bulk_import.m3u for next import..."
|
|
||||||
echo '#EXTM3U' > bulk_import.m3u
|
|
||||||
echo '' >> bulk_import.m3u
|
|
||||||
echo "bulk_import.m3u cleared and ready"
|
|
||||||
else
|
|
||||||
echo "bulk_import.m3u already clean"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo "Final cleanup completed"
|
|
||||||
|
|
||||||
- name: Repository Health Check
|
|
||||||
run: |
|
|
||||||
echo "=== Repository Health Check ==="
|
|
||||||
TOTAL_FILES=$(find . -type f | grep -v '.git' | wc -l)
|
|
||||||
REPO_SIZE=$(du -sh . 2>/dev/null | cut -f1 || echo "unknown")
|
|
||||||
echo "Repository Statistics:"
|
|
||||||
echo " Total files: $TOTAL_FILES"
|
|
||||||
echo " Repository size: $REPO_SIZE"
|
|
||||||
CACHE_DIRS=$(find . -type d -name "__pycache__" | wc -l)
|
|
||||||
TEMP_FILES=$(find . -name "*.tmp" -o -name "*_temp*" | wc -l)
|
|
||||||
LOG_FILES_ROOT=$(find . -maxdepth 1 -name "*.log" | wc -l)
|
|
||||||
echo "Cleanliness Check:"
|
|
||||||
echo " Python cache dirs: $CACHE_DIRS"
|
|
||||||
echo " Temporary files: $TEMP_FILES"
|
|
||||||
echo " Root log files: $LOG_FILES_ROOT"
|
|
||||||
if [ "$CACHE_DIRS" -eq 0 ] && [ "$TEMP_FILES" -eq 0 ] && [ "$LOG_FILES_ROOT" -eq 0 ]; then
|
|
||||||
echo "Repository is clean!"
|
|
||||||
else
|
|
||||||
echo "Some cleanup items remain"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Commit Changes
|
|
||||||
run: |
|
|
||||||
echo "=== Committing Changes ==="
|
|
||||||
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/*.gz || true
|
|
||||||
git add templates/ || true
|
|
||||||
git add .forgejo/ || true
|
|
||||||
git add README.md || true
|
|
||||||
git add .gitignore || true
|
|
||||||
git rm --cached *.log 2>/dev/null || true
|
|
||||||
git rm --cached **/__pycache__/** 2>/dev/null || true
|
|
||||||
git rm --cached **/*.pyc 2>/dev/null || true
|
|
||||||
echo "Files staged for commit:"
|
|
||||||
git diff --staged --name-only | head -10 || echo "No staged changes"
|
|
||||||
if ! git diff --staged --quiet; then
|
if ! git diff --staged --quiet; then
|
||||||
CHANNEL_COUNT="0"
|
git commit -m "📺 Updated playlist - $(date '+%Y-%m-%d %H:%M')"
|
||||||
if [ -f playlist.m3u ]; then
|
|
||||||
CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u 2>/dev/null || echo "0")
|
|
||||||
fi
|
|
||||||
REPO_SIZE=$(du -sh . 2>/dev/null | cut -f1 || echo "unknown")
|
|
||||||
COMMIT_MSG="📺 Updated playlist: $CHANNEL_COUNT channels ($(date '+%Y-%m-%d %H:%M'))
|
|
||||||
|
|
||||||
🧹 Repository Status:
|
|
||||||
- Channels: $CHANNEL_COUNT
|
|
||||||
- Size: $REPO_SIZE
|
|
||||||
- Auto-cleaned and organized
|
|
||||||
- $(date '+%Y-%m-%d %H:%M:%S UTC')"
|
|
||||||
git commit -m "$COMMIT_MSG"
|
|
||||||
git push
|
git push
|
||||||
echo "Repository updated successfully"
|
fi
|
||||||
echo "Channels: $CHANNEL_COUNT"
|
|
||||||
echo "Size: $REPO_SIZE"
|
|
||||||
else
|
|
||||||
echo "No changes to commit"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Workflow Summary
|
|
||||||
run: |
|
|
||||||
echo "=== Workflow Summary ==="
|
|
||||||
echo "IPTV Playlist workflow completed!"
|
|
||||||
if [ -f playlist.m3u ]; then
|
|
||||||
CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u 2>/dev/null || echo "0")
|
|
||||||
echo "Success Summary:"
|
|
||||||
echo " Playlist generated with $CHANNEL_COUNT channels"
|
|
||||||
echo " Repository cleaned and organized"
|
|
||||||
echo " Files properly structured"
|
|
||||||
echo " Ready for next import"
|
|
||||||
else
|
|
||||||
echo "Playlist not generated - check logs"
|
|
||||||
fi
|
|
||||||
echo "Next Steps:"
|
|
||||||
echo " 1. Add channels to bulk_import.m3u"
|
|
||||||
echo " 2. Push changes to trigger workflow"
|
|
||||||
echo " 3. Playlist will be automatically updated"
|
|
Loading…
Add table
Add a link
Reference in a new issue