Created
February 16, 2022 21:32
-
-
Save Utopiah/1c748c68adc016993b3c95f83dca603e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for X in $(ls -d *highlights); do | |
TITLE=$(cat $(echo $X|sed "s/.highlights//").metadata | jq -r .visibleName) | |
HIGHLIGHTS=$(cat $X/*json | jq '.highlights[][] | {text} | add' -r) | |
DATA="" | |
IFS=$'\n' | |
for h in $HIGHLIGHTS; do | |
if [ $(echo $h|wc -c) -gt 2 ]; then | |
NEWDATA="{\"text\": \"$h\",\"title\": \"$TITLE\",\"author\": \"Fabien Benetou\"}" | |
if [ -z "$DATA" ]; then | |
DATA=$NEWDATA | |
else | |
DATA="$DATA,$NEWDATA" | |
fi | |
fi | |
done | |
curl --request POST --url https://readwise.io/api/v2/highlights/ \ | |
-H "Authorization: Token $RWIO_TOKEN" \ | |
-H 'Content-Type: application/json' \ | |
--data '{"highlights":['"$NEWDATA"']}' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment