From ef803be19a7f5912f3121a276e2a63dff5df8795 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Sun, 5 Feb 2023 15:20:20 +0000 Subject: [PATCH] sources.browser_new: initial work on using HPI + seanbreckenridge/browserexport later will rename to browser, and implement defensive fallback onto browser_old adapted from https://github.com/seanbreckenridge/promnesia/blob/master/promnesia_sean/sources/browsing.py related: https://github.com/karlicoss/promnesia/issues/339 Old vs new modules produce almost identical results (tested on various chrome & firefox databases) There are some minor differences vs the old module: - old database timestamps end with +00:00 UTC, new ones with +00:00 -- likely because browserexport is using timezone.utc instead of pytz - previously locator was pointing at the database file, now it's pointing at the URL I guess it's not necessarily in the 'spirit' of locator field, but on the other hand, not that it's very useful to point to an sqlite file either. Perhaps later it could be in some sort of extra debug field instead. --- src/promnesia/sources/browser_new.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/promnesia/sources/browser_new.py diff --git a/src/promnesia/sources/browser_new.py b/src/promnesia/sources/browser_new.py new file mode 100644 index 00000000..76fd6dd7 --- /dev/null +++ b/src/promnesia/sources/browser_new.py @@ -0,0 +1,22 @@ +from typing import Optional + +from promnesia.common import Results, Visit, Loc, Second + + +def index() -> Results: + from . import hpi + from my.browser.all import history + + for v in history(): + desc: Optional[str] = None + duration: Optional[Second] = None + metadata = v.metadata + if metadata is not None: + desc = metadata.title + duration = metadata.duration + yield Visit( + url=v.url, + dt=v.dt, + locator=Loc(title=desc or v.url, href=v.url), + duration=duration, + )