diff --git a/.forgejo/workflows/generate-m3u.yml b/.forgejo/workflows/generate-m3u.yml index 653e6b6..f9d949c 100644 --- a/.forgejo/workflows/generate-m3u.yml +++ b/.forgejo/workflows/generate-m3u.yml @@ -23,295 +23,77 @@ jobs: git config --local user.email "actions@forgejo.plainrock127.xyz" git config --local user.name "IPTV Playlist Bot" - - name: đ Create directory structure and initial files - run: | - echo "=== Creating directory structure ===" - mkdir -p logs config templates scripts docs - - 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: đ Check files before processing run: | echo "=== Repository Status ===" - echo "Directory: $(pwd)" - echo "User: $(whoami)" - echo "Files:" ls -la - echo "=== Checking required files ===" - echo "scripts/generate_playlist.py:" + echo "=== Checking key files ===" if [ -f scripts/generate_playlist.py ]; then - echo " â Found" + echo "â scripts/generate_playlist.py 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" + echo "â scripts/generate_playlist.py missing" fi - echo "channels.txt:" if [ -f channels.txt ]; then - echo " â Found ($(wc -l < channels.txt) lines)" + echo "â channels.txt found ($(wc -l < channels.txt) lines)" else - echo " â Missing" + echo "âšī¸ channels.txt not found" fi - echo "bulk_import.m3u:" if [ -f bulk_import.m3u ]; then - echo " â Found ($(wc -l < bulk_import.m3u) lines)" + echo "â bulk_import.m3u found ($(wc -l < bulk_import.m3u) lines)" else - echo " âšī¸ Not found (this is normal if no import needed)" + echo "âšī¸ bulk_import.m3u not found (normal if no import)" fi - name: đ Generate M3U Playlist run: | - 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..." + echo "=== Running playlist generation ===" python scripts/generate_playlist.py - echo "â Playlist generation completed" - - name: đ Post-processing diagnostics + - name: đ Check results run: | - echo "=== Processing Results ===" - echo "Files after processing:" + echo "=== Results ===" ls -la - echo "=== Checking outputs ===" - if [ -f playlist.m3u ]; then - 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 - echo "â playlist.m3u: Not generated" - fi - - if [ -f bulk_import.m3u ]; then - echo "â ī¸ bulk_import.m3u: Still exists (cleanup may have failed)" - else - echo "â bulk_import.m3u: Cleaned up or not present" - fi - - 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 - else - echo "â No logs directory created" - fi - - - name: đ Generate statistics - run: | - echo "=== Playlist Statistics ===" 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") - 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 + echo "â playlist.m3u generated with $CHANNEL_COUNT channels" + echo "First 5 lines:" + head -5 playlist.m3u else - echo "â No playlist generated - cannot show statistics" + echo "â playlist.m3u not generated" + fi + + if [ -f playlist_update.log ]; then + echo "=== Log content ===" + cat playlist_update.log + else + echo "â No log file found" fi - - name: đĻ Prepare deployment + - name: đž Commit changes run: | - echo "=== Preparing deployment files ===" - mkdir -p docs + # Add files + git add channels.txt || true + git add playlist.m3u || true + git add playlist_update.log || true + git add config/ || true + git add docs/ || true - # 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' - - -
-