(feed_url: str)
| 178 | def fetch_one_feed(feed_url: str) -> List[Dict]: |
| 179 | try: |
| 180 | request = urllib.request.Request(feed_url, headers={"User-Agent": "PaperFlow Desktop"}) |
| 181 | with urllib.request.urlopen(request, timeout=20) as response: |
| 182 | raw = response.read() |
| 183 | root = ET.fromstring(raw) |
| 184 | except Exception as exc: |
| 185 | print(f" Custom RSS fetch error for {feed_url}: {exc}") |
| 186 | return [] |
| 187 | |
| 188 | items = root.findall(".//item") or root.findall(".//atom:entry", namespaces) |
| 189 | feed_papers: List[Dict] = [] |
| 190 | for item in items[:per_feed_limit]: |
| 191 | title = _strip_html(_xml_text(item, "title", "atom:title")) |
| 192 | link = _xml_text(item, "link") |
| 193 | if not link: |
| 194 | atom_link = item.find("atom:link", namespaces) |
| 195 | link = atom_link.get("href", "") if atom_link is not None else "" |
| 196 | abstract = _strip_html(_xml_text(item, "description", "summary", "atom:summary", "atom:content")) |
| 197 | author = _xml_text(item, "dc:creator", "author", "atom:author/atom:name") |
| 198 | published = _parse_feed_date(_xml_text(item, "pubDate", "published", "updated", "atom:published", "atom:updated")) |
| 199 | if not title: |
| 200 | continue |
| 201 | feed_papers.append( |
| 202 | { |
| 203 | "title": title, |
| 204 | "authors": [author] if author else [], |
| 205 | "abstract": abstract, |
| 206 | "url": link, |
| 207 | "paper_url": link, |
| 208 | "source": "custom_rss", |
| 209 | "venue": feed_url, |
| 210 | "publish_date": published, |
| 211 | "categories": ["custom_rss"], |
| 212 | "metadata": {"feed_url": feed_url}, |
| 213 | } |
| 214 | ) |
| 215 | return feed_papers |
| 216 | |
| 217 | papers: List[Dict] = [] |
| 218 | max_workers = min(_env_positive_int("PAPERFLOW_MAX_CONCURRENCY", default=5), len(urls)) |
| 219 | with ThreadPoolExecutor(max_workers=max_workers) as executor: |
| 220 | futures = [executor.submit(fetch_one_feed, feed_url) for feed_url in urls] |
nothing calls this directly
no test coverage detected