atfzl / obsidian-apple-books-plugin

Sync your Apple Books highlights in Obsidian
MIT License
42 stars 3 forks source link

Ideal Output #7

Open jun6lee opened 1 year ago

jun6lee commented 1 year ago

Will try and figure out some of the gaps and send in PR's

---
title: ZTITLE
author: ZAUTHOR
last_opened: ZLASTOPENDATE
last_highlight: {{latest instance of ZANNOTATIONMODIFICATIONDATE}}
highlight_count: {{number of records per book}}
---

# ZTITLE
---
- Author: ZAUTHOR
- [Apple Books Link](ibooks://assetid/ZANNOTATIONASSETID)

## Highlights
---

<< -- if chapter data exists -->> 
### ZFUTUREPROOFING5 
---
<< -- else skip >>

- ZANNOTATIONSELECTEDTEXT
<< -- if note data exists -->> 
>   Note: ZANNOTATIONNOTE
<< -- else skip >>
---
<sub>Highlighted: ZANNOTATIONMODIFICATIONDATE</sub>

---
// repeat for each chapter / highlight
---
jun6lee commented 1 year ago

Then of course, there's also colours: ZANNOTATIONSTYLE

// The annotation's highlight style.
// Possible values: 
            0 => "underline",
            1 => "green",
            2 => "blue",
            3 => "yellow",
            4 => "pink",
            5 => "purple"

From: https://github.com/57uff3r/ibooks_notes_exporter/pull/6/files
Can be done in css if values are pulled at the very least. https://github.com/57uff3r/ibooks_notes_exporter/pull/6

func styleToColor(style int) string {
    switch style {
    case 1: 
        // green
        return "#a8e196"
    case 2:
        // blue
        return "#a5c3ff" 
    case 3: 
        // yellow
        return "#fde15c"
    case 4: 
        // pink
        return "#ffaabf"    
    case 5: 
        // purple
        return "#cdbbfb"    
    default:
        return ""       
    }
}
jun6lee commented 1 year ago

Date conversion from https://artm.dev/notes/how-to-programmatically-get-highlights-from-apple-books/

const APPLE_EPOCH_START = new Date("2001-01-01").getTime();

function convertAppleTime(appleTime: number): number {
  return new Date(APPLE_EPOCH_START + appleTime * 1000).getTime();
}