import httpx import feedparser from typing import List, Dict, Any import logging logger = logging.getLogger("rss-client") class RSSClient: RSS_URL = "https://www.eveonline.com/rss/patch-notes" def __init__(self, user_agent: str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"): self.client = httpx.AsyncClient( headers={"User-Agent": user_agent}, follow_redirects=True, timeout=30.0 ) async def close(self): await self.client.aclose() async def get_latest_patch_notes(self) -> List[Dict[str, Any]]: """Fetch and parse the latest patch notes.""" try: response = await self.client.get(self.RSS_URL) response.raise_for_status() feed = feedparser.parse(response.text) entries = [] for entry in feed.entries: entries.append({ "title": entry.title, "link": entry.link, "published": entry.published if hasattr(entry, "published") else None, "summary": entry.description if hasattr(entry, "summary") else entry.get("description", "") }) return entries except Exception as e: logger.error(f"RSS Fetch Failed: {str(e)}") return [] if __name__ == "__main__": import asyncio async def test(): rss = RSSClient() notes = await rss.get_latest_patch_notes() print(f"Found {len(notes)} patch note entries.") if notes: print(f"Latest: {notes[0]['title']} ({notes[0]['link']})") await rss.close() asyncio.run(test())