Files
telegram-rss-bot/check_feeds.py
T

72 lines
2.3 KiB
Python
Raw Normal View History

2026-03-08 17:32:52 +00:00
#!/usr/bin/env python3
"""
Quick script to check all RSS feeds status
"""
import asyncio
from rss_manager import RSSFeedManager
from bot_config import CATEGORY_FEEDS
2026-03-08 17:32:52 +00:00
async def check_all_feeds():
totals = {}
offline_by_category = {}
for category, feeds_file in CATEGORY_FEEDS.items():
print("\n" + "=" * 80)
print(f"CHECKING {category.upper()} FEEDS")
print("=" * 80)
async with RSSFeedManager(feeds_file=feeds_file, feed_type=category) as manager:
status_data = await manager.check_feed_status()
total = 0
online = 0
offline = []
for status_category, feeds in status_data.items():
print(f"\n📡 {status_category.replace('_', ' ').title()}:")
for feed_name, feed_info in feeds.items():
total += 1
status_icon = feed_info['status']
entries = feed_info['entries']
if '✅' in status_icon:
online += 1
print(f" ✅ {feed_name}: {entries} articles")
else:
offline.append(feed_name)
error = feed_info.get('error', 'Unknown error')
print(f" ❌ {feed_name}: {error[:80]}")
totals[category] = {"total": total, "online": online, "offline": len(offline)}
offline_by_category[category] = offline
print("\n" + "=" * 80)
print("SUMMARY")
print("=" * 80)
grand_total = 0
grand_online = 0
grand_offline = 0
for category in CATEGORY_FEEDS:
stats = totals.get(category, {"total": 0, "online": 0, "offline": 0})
grand_total += stats["total"]
grand_online += stats["online"]
grand_offline += stats["offline"]
print(f"\n{category}: total={stats['total']} online={stats['online']} offline={stats['offline']}")
print(f"\n🌍 OVERALL:")
print(f" Total: {grand_total}")
print(f" Online: {grand_online} ✅")
print(f" Offline: {grand_offline} ❌")
if grand_offline:
print(f"\n⚠️ OFFLINE FEEDS:")
for category, feeds in offline_by_category.items():
for feed in feeds:
print(f" [{category}] {feed}")
print("\n" + "=" * 80)
if __name__ == "__main__":
asyncio.run(check_all_feeds())