CSV export

This commit is contained in:
Dhananjay Balan 2023-04-13 23:04:39 +02:00
parent e2f7ebe6de
commit 11c4e92cc7
2 changed files with 10 additions and 7 deletions

View File

@ -6,7 +6,8 @@ Personal, bare bones [readwise] alternative.
Have Have
- Parsers - Parsers
- [ ] Read from kindle - [-] Read from kindle
- [ ] Read from readwise
- [x] Read from KOReader - [x] Read from KOReader
- [x] Minimal API - [x] Minimal API
- Expose random-quote API - Expose random-quote API

View File

@ -34,16 +34,18 @@ instance FromNamedRecord RwHighlight where
<*> m .: "Highlighted at" <*> m .: "Highlighted at"
<*> m .: "Document tags" <*> m .: "Document tags"
parseDocument :: ByteString -> [RwHighlight] parseDocument :: ByteString -> Either String [RwHighlight]
parseDocument d = case decodeByName d of parseDocument d = case decodeByName d of
Left _ -> [] Left err -> Left err
Right (_, va) -> toList va Right (_, va) -> Right $ toList va
parse :: ByteString -> [Quote] parse :: ByteString -> Either String [Quote]
parse d = fmap (\r -> Quote { qQuote = rhHightlight r parse d = case parseDocument d of
Left err -> Left err
Right rw -> Right $ fmap (\r -> Quote { qQuote = rhHightlight r
, qAuthor = rhAuthor r , qAuthor = rhAuthor r
, qTitle = rhTitle r , qTitle = rhTitle r
, qPage = rhLocation r , qPage = rhLocation r
, qChapter = Nothing , qChapter = Nothing
, qCreatedOn = Nothing , qCreatedOn = Nothing
}) (parseDocument d) }) rw