Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -199,18 +199,32 @@ def fetch_rss(feed_dict, source_type):
|
|
| 199 |
r = scraper.get(url, timeout=15)
|
| 200 |
if r.status_code != 200: continue
|
| 201 |
feed = feedparser.parse(r.content)
|
|
|
|
| 202 |
for entry in feed.entries[:15]:
|
| 203 |
title = entry.get("title", "")
|
| 204 |
summary = entry.get("description", "")
|
|
|
|
| 205 |
if not is_relevant(title, summary): continue
|
| 206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
results.append({
|
| 208 |
"source": name, "type": source_type, "event_date": fmt_date,
|
| 209 |
"time": "Published", "title": title, "latest_action": "Published",
|
| 210 |
"link": entry.get("link", url), "summary": summary[:300]
|
| 211 |
})
|
| 212 |
time.sleep(1)
|
| 213 |
-
except Exception as e:
|
|
|
|
|
|
|
| 214 |
return results
|
| 215 |
|
| 216 |
# --- RESTORED UN-NERFED APIS ---
|
|
|
|
| 199 |
r = scraper.get(url, timeout=15)
|
| 200 |
if r.status_code != 200: continue
|
| 201 |
feed = feedparser.parse(r.content)
|
| 202 |
+
|
| 203 |
for entry in feed.entries[:15]:
|
| 204 |
title = entry.get("title", "")
|
| 205 |
summary = entry.get("description", "")
|
| 206 |
+
|
| 207 |
if not is_relevant(title, summary): continue
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
# Check for standard RSS/Atom timestamps first
|
| 211 |
+
if hasattr(entry, 'published_parsed') and entry.published_parsed:
|
| 212 |
+
fmt_date = datetime(*entry.published_parsed[:6]).replace(tzinfo=None)
|
| 213 |
+
elif hasattr(entry, 'updated_parsed') and entry.updated_parsed:
|
| 214 |
+
fmt_date = datetime(*entry.updated_parsed[:6]).replace(tzinfo=None)
|
| 215 |
+
else:
|
| 216 |
+
# Fallback to text scanning only if metadata is missing entirely
|
| 217 |
+
fmt_date = extract_robust_date([title, summary]) or datetime.now()
|
| 218 |
+
|
| 219 |
results.append({
|
| 220 |
"source": name, "type": source_type, "event_date": fmt_date,
|
| 221 |
"time": "Published", "title": title, "latest_action": "Published",
|
| 222 |
"link": entry.get("link", url), "summary": summary[:300]
|
| 223 |
})
|
| 224 |
time.sleep(1)
|
| 225 |
+
except Exception as e:
|
| 226 |
+
print(f"Error {name}: {e}")
|
| 227 |
+
|
| 228 |
return results
|
| 229 |
|
| 230 |
# --- RESTORED UN-NERFED APIS ---
|