diff --git a/.forgejo/workflows/generate-m3u.yml b/.forgejo/workflows/generate-m3u.yml index 795e649..1983088 100644 --- a/.forgejo/workflows/generate-m3u.yml +++ b/.forgejo/workflows/generate-m3u.yml @@ -31,12 +31,7 @@ jobs: echo "Checking import file..." if [ -f bulk_import.m3u ]; then LINES=$(wc -l < bulk_import.m3u) - SIZE=$(du -h bulk_import.m3u | cut -f1) - echo "Found bulk_import.m3u with $LINES lines ($SIZE)" - - # Show first few lines to verify content - echo "First 5 lines:" - head -n 5 bulk_import.m3u || echo "Could not read file" + echo "Found bulk_import.m3u with $LINES lines" else echo "Creating empty bulk_import.m3u" echo '#EXTM3U' > bulk_import.m3u @@ -49,7 +44,7 @@ jobs: echo "Scripts directory exists" ls -la scripts/ else - echo "❌ Scripts directory not found!" + echo "Scripts directory not found!" exit 1 fi @@ -60,75 +55,29 @@ jobs: if [ -f generate_playlist.py ]; then echo "Found generate_playlist.py, executing..." python3 generate_playlist.py - echo "Playlist generation completed with exit code: $?" + echo "Playlist generation completed" else - echo "❌ Error: generate_playlist.py not found in scripts/" + echo "Error: generate_playlist.py not found" exit 1 fi - - name: Verify Generated Files - run: | - echo "Verifying generated files..." - if [ -f playlist.m3u ]; then - CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0") - SIZE=$(du -h playlist.m3u | cut -f1) - echo "✅ Generated playlist.m3u with $CHANNELS channels ($SIZE)" - else - echo "⚠️ No playlist.m3u generated" - fi - - if [ -f channels.txt ]; then - SIZE=$(du -h channels.txt | cut -f1) - echo "✅ Updated channels.txt ($SIZE)" - else - echo "⚠️ No channels.txt found" - fi - - name: Create Simple Report run: | echo "Creating report..." - DATE=$(date +%Y%m%d_%H%M%S) - REPORT="reports/daily/report_$DATE.md" - - echo "# IPTV Playlist Report" > "$REPORT" - echo "Generated: $(date)" >> "$REPORT" - echo "" >> "$REPORT" - if [ -f playlist.m3u ]; then CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0") - echo "## Summary" >> "$REPORT" - echo "- **Channels:** $CHANNELS" >> "$REPORT" - echo "- **Generated:** $(date)" >> "$REPORT" - echo "- **File size:** $(du -h playlist.m3u | cut -f1)" >> "$REPORT" + echo "Found $CHANNELS channels in playlist" - # Add top 10 groups - echo "" >> "$REPORT" - echo "## Top Channel Groups" >> "$REPORT" - if command -v python3 >/dev/null 2>&1; then - python3 -c " -import re -try: - with open('playlist.m3u', 'r') as f: - content = f.read() - groups = {} - for line in content.split('\n'): - if 'group-title=' in line: - match = re.search(r'group-title=\"([^\"]*)', line) - if match: - group = match.group(1) - groups[group] = groups.get(group, 0) + 1 - - for group, count in sorted(groups.items(), key=lambda x: x[1], reverse=True)[:10]: - print(f'- **{group}:** {count} channels') -except Exception as e: - print(f'- Error analyzing groups: {e}') - " >> "$REPORT" - fi + DATE=$(date +%Y%m%d_%H%M%S) + REPORT="reports/daily/report_$DATE.md" + + echo "# Playlist Report" > "$REPORT" + echo "Generated: $(date)" >> "$REPORT" + echo "Channels: $CHANNELS" >> "$REPORT" echo "Report created: $REPORT" else - echo "**Status:** No playlist generated" >> "$REPORT" - echo "⚠️ No playlist found for report" + echo "No playlist found" fi - name: Clean Old Reports @@ -138,9 +87,9 @@ except Exception as e: if ls *.md >/dev/null 2>&1; then COUNT=$(ls *.md | wc -l) echo "Found $COUNT reports" - if [ "$COUNT" -gt 5 ]; then - echo "Removing excess reports (keeping 5 most recent)..." - ls -t *.md | tail -n +6 | xargs rm -f + if [ "$COUNT" -gt 3 ]; then + echo "Removing excess reports..." + ls -t *.md | tail -n +4 | xargs rm -f echo "Cleanup done" fi else @@ -152,9 +101,7 @@ except Exception as e: run: | echo "Resetting import file..." echo '#EXTM3U' > bulk_import.m3u - echo "# Import file cleared after processing" >> bulk_import.m3u - echo "# Add your M3U content here for next run" >> bulk_import.m3u - echo "Import file reset and ready for next import" + echo "Import file reset" - name: Commit Changes run: | @@ -167,23 +114,9 @@ except Exception as e: if [ -f playlist.m3u ]; then CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0") fi - - # Create detailed commit message - COMMIT_MSG="📺 Updated playlist with $CHANNELS channels - $(date '+%Y-%m-%d %H:%M')" - - if [ -f reports/daily/report_*.md ]; then - LATEST_REPORT=$(ls -t reports/daily/report_*.md | head -n 1) - if [ -f "$LATEST_REPORT" ]; then - COMMIT_MSG="$COMMIT_MSG - -📊 Latest Report: $(basename "$LATEST_REPORT") -🔄 Auto-processed via workflow" - fi - fi - - git commit -m "$COMMIT_MSG" + git commit -m "📺 Updated playlist with $CHANNELS channels - $(date '+%Y-%m-%d %H:%M')" git push - echo "✅ Changes committed and pushed" + echo "Changes committed" fi - name: Summary @@ -192,15 +125,6 @@ except Exception as e: if [ -f playlist.m3u ]; then CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0") echo "✅ Playlist has $CHANNELS channels" - - # Show file sizes - echo "📊 File sizes:" - [ -f playlist.m3u ] && echo " - playlist.m3u: $(du -h playlist.m3u | cut -f1)" - [ -f channels.txt ] && echo " - channels.txt: $(du -h channels.txt | cut -f1)" - else - echo "⚠️ No playlist generated" fi - echo "✅ Reports updated" - echo "✅ Repository cleaned" - echo "✅ Ready for next import" \ No newline at end of file + echo "✅ Repository cleaned" \ No newline at end of file