def index() -> Results: from my.facebook import events from my.facebook import ( Post, Conversation, ) for e in events(): if isinstance(e, Exception): yield e continue elif isinstance(e, Post): for url in iter_urls(e.content): yield Visit( url=url, dt=e.dt, locator=Loc(title=e.action or ""), context=e.content, ) elif isinstance(e, Conversation): for msg in e.messages: for url in iter_urls(msg.content): yield Visit( url=url, dt=msg.dt, context=msg.content, locator=Loc(title=msg.author), ) else: # ignore other events continue
def index(*, render_markdown: bool = False) -> Results: from my.discord import messages # TODO: optionally import? this would break if someone # hasnt installed promnesia like pip3 install '.[all]' to # to install the markdown module for promnesia from promnesia.sources.markdown import TextParser for m in messages(): # hmm - extract URLs from attachments? # Probably not very useful unless I extract info from them with url_metadata or something context: str = m.content # if render_markdown flag is enabled, render the text as markdown (HTML) if render_markdown: context = TextParser(m.content)._doc_ashtml() # permalink back to this discord message loc = Loc.make(title=m.channel.description, href=m.link) for u in iter_urls(m.content): yield Visit( url=u, dt=m.timestamp, context=context, locator=loc, )
def index() -> Results: from my.ttt import history for e in history(): for u in iter_urls(e.command): yield Visit( url=u, dt=e.dt, context=e.command, locator=Loc(title=e.command, href=u), )
def index() -> Results: from my.coding.commits import commits for c in commits(): for url in iter_urls(c.message): desc = f"{c.repo}\n{c.message}" yield Visit( url=url, dt=c.committed_dt, context=desc, locator=Loc(title=f"{c.repo} {c.sha}", href=c.repo), )
def index() -> Results: from my.ipython import history for e in history(): if isinstance(e, Exception): logger.exception(e) continue for u in iter_urls(e.command): yield Visit( url=u, dt=e.dt, context=e.command, locator=Loc(title=e.command, href=u), )
def index() -> Results: from my.todotxt import events emitted: Set[Tuple[str, str]] = set() for e in events(): for u in iter_urls(e.todo.text): key = (e.todo.text, u) if key in emitted: continue yield Visit( url=u, dt=e.dt, context=e.todo.text, locator=Loc(title=e.todo.text, href=u), ) emitted.add(key)
def index() -> Results: from my.old_forums import history for p in history(): desc = f"{p.forum_name} - {p.post_title}" loc = Loc(title=desc, href=p.post_url) # visit directly to this link yield Visit(url=p.post_url, dt=p.dt, locator=loc, context=p.post_contents) # visit to any links I mentioned in the contents for url in iter_urls(p.post_contents): yield Visit( url=url, dt=p.dt, locator=loc, context=p.post_contents, )