diff --git a/.forgejo/workflows/generate-m3u.yml b/.forgejo/workflows/generate-m3u.yml index 14eef7c..eb8e6ad 100644 --- a/.forgejo/workflows/generate-m3u.yml +++ b/.forgejo/workflows/generate-m3u.yml @@ -12,127 +12,38 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - name: Configure Git run: | git config --local user.email "actions@forgejo.plainrock127.xyz" git config --local user.name "IPTV Playlist Bot" - - name: Run Comprehensive Cleanup + - name: Basic Setup run: | - echo "Running comprehensive cleanup..." - if [ -f comprehensive_cleanup.py ]; then - python comprehensive_cleanup.py - echo "Comprehensive cleanup completed" - else - echo "Cleanup already completed" - fi - - - name: Basic Repository Maintenance - run: | - echo "Running basic maintenance..." - find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true - find . -name "*.pyc" -delete 2>/dev/null || true - find . -name "*.tmp" -delete 2>/dev/null || true - find . -name "*~" -delete 2>/dev/null || true - mkdir -p reports/logs reports/daily backups config templates - find . -maxdepth 1 -name "*.log" -exec mv {} reports/logs/ \; 2>/dev/null || true - if [ ! -f scripts/__init__.py ]; then - echo '# IPTV Scripts Package' > scripts/__init__.py - fi - echo "Basic maintenance completed" - - - name: Check Import File - run: | - echo "Checking import file..." - if [ -f bulk_import.m3u ]; then - LINES=$(wc -l < bulk_import.m3u) - echo "Found bulk_import.m3u with $LINES lines" - if [ "$LINES" -gt 2 ]; then - echo "Contains channels to process" - fi - else - echo "Creating empty bulk_import.m3u" - echo '#EXTM3U' > bulk_import.m3u - fi + # This step previously contained explicit cleanup and Python setup. + # These are now handled by the environment or within generate_playlist.py if needed. + echo "Basic setup complete." - name: Run Playlist Generation run: | echo "Running playlist generation..." - if [ -f scripts/generate_playlist.py ]; then - python scripts/generate_playlist.py - echo "Playlist generation completed" - else - echo "Error: generate_playlist.py not found" - exit 1 - fi - - - name: Check Results - run: | - echo "Checking results..." - if [ -f playlist.m3u ]; then - CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0") - SIZE=$(du -h playlist.m3u | cut -f1) - echo "Generated playlist: $CHANNELS channels ($SIZE)" - - # Create simple report - DATE=$(date +%Y%m%d_%H%M%S) - REPORT="reports/daily/report_$DATE.md" - echo "# Playlist Report - $(date)" > "$REPORT" - echo "- Channels: $CHANNELS" >> "$REPORT" - echo "- Size: $SIZE" >> "$REPORT" - echo "- Generated: $(date)" >> "$REPORT" - echo "Created report: $REPORT" - else - echo "No playlist generated" - fi + python scripts/generate_playlist.py - - name: Clean Import File + - name: Commit and Push if Changes run: | - echo "Cleaning import file..." - if [ -f bulk_import.m3u ]; then - LINES=$(wc -l < bulk_import.m3u) - if [ "$LINES" -gt 2 ]; then - echo '#EXTM3U' > bulk_import.m3u - echo "Cleaned import file for next use" - fi - fi - - - name: Final Cleanup - run: | - echo "Final cleanup..." - find . -name "*.pyc" -delete 2>/dev/null || true - find . -name "*~" -delete 2>/dev/null || true - find . -name "*.swp" -delete 2>/dev/null || true - rm -f comprehensive_cleanup.py 2>/dev/null || true - echo "Final cleanup completed" - - - name: Commit Changes - run: | - echo "Committing changes..." git add . - if ! git diff --staged --quiet; then - CHANNELS="0" - if [ -f playlist.m3u ]; then - CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0") - fi - git commit -m "Updated playlist: $CHANNELS channels - $(date '+%Y-%m-%d %H:%M')" + if ! git diff-index --quiet HEAD; then + echo "Changes detected, committing..." + # Get channel count for commit message + CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0") + git commit -m "📺 Updated playlist with $CHANNELS channels - $(date '+%Y-%m-%d %H:%M')" git push - echo "Changes committed successfully" - else - echo "No changes to commit" + echo "Changes committed" fi - name: Summary run: | - echo "Workflow completed successfully!" - if [ -f playlist.m3u ]; then - CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0") - echo "Playlist: $CHANNELS channels" - fi - echo "Repository is clean and organized" \ No newline at end of file + # Get channel count for summary + CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0") + echo "=== WORKFLOW COMPLETE ===" + echo "✅ Playlist has $CHANNELS channels" \ No newline at end of file