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
- Parsers
- [ ] Read from kindle
- [-] Read from kindle
- [ ] Read from readwise
- [x] Read from KOReader
- [x] Minimal API
- Expose random-quote API

View File

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