MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / _parse_rss_items

Function _parse_rss_items

Scripts/ButSystem.py:10432–10498  ·  view source on GitHub ↗

Parse RSS/Atom bytes into a list of items: {title,url,source,topic_key,topic,published}.

(xml_bytes: bytes, source: str, topic_key: str, topic_label: str, is_google: bool)

Source from the content-addressed store, hash-verified

10430
10431This docstring was expanded to make future maintenance easier.
10432
10433Args:
10434 rel: Parameter.
10435 name: Parameter.
10436
10437Returns:
10438 Varies.
10439"""
10440 rel = (rel or "").strip("/")
10441 return f"{rel}/{name}" if rel else name
10442 u = current_user()
10443 prefs = get_user_prefs(u) if u else dict(DEFAULT_PREFS)
10444 but_css = BUT_CSS + prefs_css(prefs)
10445 try:
10446 story_users = _story_active_usernames() if u else set()
10447 except Exception:
10448 story_users = set()
10449 def has_active_story(username):
10450 try:
10451 return bool(username and (username in story_users))
10452 except Exception:
10453 return False
10454 return dict(
10455 but_css=but_css,
10456 user=u,
10457 user_prefs=prefs,
10458 my_profile=getattr(g, "my_profile", None),
10459 child_path=child_path,
10460 request=request,
10461 is_admin=user_is_admin(current_user()),
10462 has_active_story=has_active_story,
10463 story_active_users=story_users,
10464 log_path=LOG_PATH,
10465 app_data_dir=BASE_DIR,
10466 watermark=WATERMARK,
10467 notifications=getattr(g, "notifs", None),
10468 )
10469
10470@app.before_request
10471def _attach_profile_and_presence():
10472 # Presence is scoped by the host used to reach the app (local vs cloudflared vs tor).
10473 """_attach_profile_and_presence.
10474
10475Internal helper function.
10476
10477This docstring was expanded to make future maintenance easier.
10478
10479Returns:
10480 Varies.
10481"""
10482 # Presence is scoped by the host used to reach the app (local vs cloudflared vs tor).
10483 g.scope = current_scope()
10484 u = current_user()
10485 if u:
10486 g.my_profile = type("Obj", (), get_profile(u))()
10487 mark_online(u, g.scope)
10488
10489 # Notifications (numbered indicators)

Callers 1

_fetch_news_uncachedFunction · 0.70

Calls 2

txtFunction · 0.70
push_itemFunction · 0.70

Tested by

no test coverage detected