polar: move to top level, add page support
This commit is contained in:
parent
e8be20dcb5
commit
2a4bddea79
5 changed files with 19 additions and 17 deletions
|
@ -246,7 +246,7 @@ Here's the (incomplete) list of the modules:
|
||||||
| [[https://github.com/karlicoss/HPI/tree/master/my/photos/main.py][=my.photos.main=]] | Photos and videos on your filesystem, their GPS and timestamps |
|
| [[https://github.com/karlicoss/HPI/tree/master/my/photos/main.py][=my.photos.main=]] | Photos and videos on your filesystem, their GPS and timestamps |
|
||||||
| [[https://github.com/karlicoss/HPI/tree/master/my/pinboard.py][=my.pinboard=]] | [[https://pinboard.in][Pinboard]] bookmarks |
|
| [[https://github.com/karlicoss/HPI/tree/master/my/pinboard.py][=my.pinboard=]] | [[https://pinboard.in][Pinboard]] bookmarks |
|
||||||
| [[https://github.com/karlicoss/HPI/tree/master/my/pocket.py][=my.pocket=]] | [[https://getpocket.com][Pocket]] bookmarks and highlights |
|
| [[https://github.com/karlicoss/HPI/tree/master/my/pocket.py][=my.pocket=]] | [[https://getpocket.com][Pocket]] bookmarks and highlights |
|
||||||
| [[https://github.com/karlicoss/HPI/tree/master/my/reading/polar.py][=my.reading.polar=]] | [[https://github.com/burtonator/polar-bookshelf][Polar]] articles and highlights |
|
| [[https://github.com/karlicoss/HPI/tree/master/my/polar.py][=my.polar=]] | [[https://github.com/burtonator/polar-bookshelf][Polar]] articles and highlights |
|
||||||
| [[https://github.com/karlicoss/HPI/tree/master/my/reddit.py][=my.reddit=]] | Reddit data: saved items/comments/upvotes/etc. |
|
| [[https://github.com/karlicoss/HPI/tree/master/my/reddit.py][=my.reddit=]] | Reddit data: saved items/comments/upvotes/etc. |
|
||||||
| [[https://github.com/karlicoss/HPI/tree/master/my/rescuetime.py][=my.rescuetime=]] | Rescuetime (phone activity tracking) data. |
|
| [[https://github.com/karlicoss/HPI/tree/master/my/rescuetime.py][=my.rescuetime=]] | Rescuetime (phone activity tracking) data. |
|
||||||
| [[https://github.com/karlicoss/HPI/tree/master/my/roamresearch.py][=my.roamresearch=]] | [[https://roamresearch.com][Roam]] data |
|
| [[https://github.com/karlicoss/HPI/tree/master/my/roamresearch.py][=my.roamresearch=]] | [[https://roamresearch.com][Roam]] data |
|
||||||
|
|
|
@ -23,7 +23,7 @@ If you have some issues with the setup, see [[file:SETUP.org::#troubleshooting][
|
||||||
- [[#mytwittertwint][my.twitter.twint]]
|
- [[#mytwittertwint][my.twitter.twint]]
|
||||||
- [[#mytwitterarchive][my.twitter.archive]]
|
- [[#mytwitterarchive][my.twitter.archive]]
|
||||||
- [[#mylastfm][my.lastfm]]
|
- [[#mylastfm][my.lastfm]]
|
||||||
- [[#myreadingpolar][my.reading.polar]]
|
- [[#mypolar][my.polar]]
|
||||||
- [[#myinstapaper][my.instapaper]]
|
- [[#myinstapaper][my.instapaper]]
|
||||||
- [[#mygithubgdpr][my.github.gdpr]]
|
- [[#mygithubgdpr][my.github.gdpr]]
|
||||||
- [[#mygithubghexport][my.github.ghexport]]
|
- [[#mygithubghexport][my.github.ghexport]]
|
||||||
|
@ -79,7 +79,7 @@ modules = [
|
||||||
('twint' , 'my.twitter.twint' ),
|
('twint' , 'my.twitter.twint' ),
|
||||||
('twitter_archive', 'my.twitter.archive' ),
|
('twitter_archive', 'my.twitter.archive' ),
|
||||||
('lastfm' , 'my.lastfm' ),
|
('lastfm' , 'my.lastfm' ),
|
||||||
('polar' , 'my.reading.polar' ),
|
('polar' , 'my.polar' ),
|
||||||
('instapaper' , 'my.instapaper' ),
|
('instapaper' , 'my.instapaper' ),
|
||||||
('github' , 'my.github.gdpr' ),
|
('github' , 'my.github.gdpr' ),
|
||||||
('github' , 'my.github.ghexport' ),
|
('github' , 'my.github.ghexport' ),
|
||||||
|
@ -197,7 +197,7 @@ for cls, p in modules:
|
||||||
"""
|
"""
|
||||||
export_path: Paths
|
export_path: Paths
|
||||||
#+end_src
|
#+end_src
|
||||||
** [[file:../my/reading/polar.py][my.reading.polar]]
|
** [[file:../my/polar.py][my.polar]]
|
||||||
|
|
||||||
[[https://github.com/burtonator/polar-bookshelf][Polar]] articles and highlights
|
[[https://github.com/burtonator/polar-bookshelf][Polar]] articles and highlights
|
||||||
|
|
||||||
|
|
|
@ -229,7 +229,7 @@ Polar doesn't require any setup as it accesses the highlights on your filesystem
|
||||||
|
|
||||||
You can try if it works with:
|
You can try if it works with:
|
||||||
|
|
||||||
: python3 -c 'import my.reading.polar as polar; print(polar.get_entries())'
|
: python3 -c 'import my.polar as polar; print(polar.get_entries())'
|
||||||
|
|
||||||
** Google Takeout
|
** Google Takeout
|
||||||
If you have zip Google Takeout archives, you can use HPI to access it:
|
If you have zip Google Takeout archives, you can use HPI to access it:
|
||||||
|
@ -307,11 +307,11 @@ It's understandable from the app developer's perspective, but it makes things fr
|
||||||
|
|
||||||
# todo hmm what if I could share deserialization with Polar app?
|
# todo hmm what if I could share deserialization with Polar app?
|
||||||
|
|
||||||
Here comes the HPI [[file:../my/reading/polar.py][polar module]]!
|
Here comes the HPI [[file:../my/polar.py][polar module]]!
|
||||||
|
|
||||||
: |💾 ~/.polar (raw JSON data) |
|
: |💾 ~/.polar (raw JSON data) |
|
||||||
: ⇓⇓⇓
|
: ⇓⇓⇓
|
||||||
: HPI (my.reading.polar)
|
: HPI (my.polar)
|
||||||
: ⇓⇓⇓
|
: ⇓⇓⇓
|
||||||
: < python interface >
|
: < python interface >
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ if user_config is None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
from ..core import PathIsh
|
from .core import PathIsh
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
@dataclass
|
@dataclass
|
||||||
class polar(user_config):
|
class polar(user_config):
|
||||||
|
@ -30,7 +30,7 @@ class polar(user_config):
|
||||||
defensive: bool = True # pass False if you want it to fail faster on errors (useful for debugging)
|
defensive: bool = True # pass False if you want it to fail faster on errors (useful for debugging)
|
||||||
|
|
||||||
|
|
||||||
from ..core import make_config
|
from .core import make_config
|
||||||
config = make_config(polar)
|
config = make_config(polar)
|
||||||
|
|
||||||
# todo not sure where it keeps stuff on Windows?
|
# todo not sure where it keeps stuff on Windows?
|
||||||
|
@ -40,10 +40,10 @@ from datetime import datetime
|
||||||
from typing import List, Dict, Iterable, NamedTuple, Sequence, Optional
|
from typing import List, Dict, Iterable, NamedTuple, Sequence, Optional
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from ..core import LazyLogger, Json
|
from .core import LazyLogger, Json
|
||||||
from ..core.common import isoparse
|
from .core.common import isoparse
|
||||||
from ..error import Res, echain, sort_res_by
|
from .error import Res, echain, sort_res_by
|
||||||
from ..core.konsume import wrap, Zoomable, Wdict
|
from .core.konsume import wrap, Zoomable, Wdict
|
||||||
|
|
||||||
|
|
||||||
logger = LazyLogger(__name__)
|
logger = LazyLogger(__name__)
|
||||||
|
@ -63,6 +63,7 @@ class Highlight(NamedTuple):
|
||||||
selection: str
|
selection: str
|
||||||
comments: Sequence[Comment]
|
comments: Sequence[Comment]
|
||||||
tags: Sequence[str]
|
tags: Sequence[str]
|
||||||
|
page: int # 1-indexed
|
||||||
color: Optional[str] = None
|
color: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,7 +123,7 @@ class Loader:
|
||||||
|
|
||||||
# TODO want to ignore the whole subtree..
|
# TODO want to ignore the whole subtree..
|
||||||
pi = meta['pageInfo'].zoom()
|
pi = meta['pageInfo'].zoom()
|
||||||
pi['num'].zoom()
|
page = pi['num'].zoom().value
|
||||||
if 'dimensions' in pi:
|
if 'dimensions' in pi:
|
||||||
pi['dimensions'].consume_all()
|
pi['dimensions'].consume_all()
|
||||||
|
|
||||||
|
@ -185,6 +186,7 @@ class Loader:
|
||||||
selection=text,
|
selection=text,
|
||||||
comments=tuple(comments),
|
comments=tuple(comments),
|
||||||
tags=tuple(htags),
|
tags=tuple(htags),
|
||||||
|
page=page,
|
||||||
color=color,
|
color=color,
|
||||||
)
|
)
|
||||||
h.consume()
|
h.consume()
|
||||||
|
@ -228,7 +230,7 @@ class Loader:
|
||||||
|
|
||||||
|
|
||||||
def iter_entries() -> Iterable[Result]:
|
def iter_entries() -> Iterable[Result]:
|
||||||
from ..core import get_files
|
from .core import get_files
|
||||||
for d in get_files(config.polar_dir, glob='*/state.json'):
|
for d in get_files(config.polar_dir, glob='*/state.json'):
|
||||||
loader = Loader(d)
|
loader = Loader(d)
|
||||||
try:
|
try:
|
|
@ -11,7 +11,7 @@ import pytest # type: ignore
|
||||||
|
|
||||||
|
|
||||||
def test_hpi(prepare: str) -> None:
|
def test_hpi(prepare: str) -> None:
|
||||||
from my.reading.polar import get_entries
|
from my.polar import get_entries
|
||||||
assert len(list(get_entries())) > 1
|
assert len(list(get_entries())) > 1
|
||||||
|
|
||||||
def test_orger(prepare: str, tmp_path: Path) -> None:
|
def test_orger(prepare: str, tmp_path: Path) -> None:
|
||||||
|
@ -45,7 +45,7 @@ def prepare(request):
|
||||||
import my.config
|
import my.config
|
||||||
setattr(my.config, 'polar', user_config)
|
setattr(my.config, 'polar', user_config)
|
||||||
|
|
||||||
import my.reading.polar as polar
|
import my.polar as polar
|
||||||
reload(polar)
|
reload(polar)
|
||||||
# TODO hmm... ok, need to document reload()
|
# TODO hmm... ok, need to document reload()
|
||||||
yield dotpolar
|
yield dotpolar
|
||||||
|
|
Loading…
Add table
Reference in a new issue