summaryrefslogtreecommitdiff
path: root/.config/nushell/remarkable.nu
blob: 8a5522c25819565258d1d181e7bec3c6a6697ba8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export def upload [file: path] {
    let filename = ($file | path parse | get stem)
    let extension = ($file | path parse | get extension)
    curl $"http://($env.REMARKABLE_IP)/upload" -H "Origin: http://192.168.178.24" -H "Referer: http://192.168.178.24" -H 'Connection: keep-alive' -F $"file=@($file);filename=($filename);type=application/($extension)"
}

export def download [collection_id?: string] {
        curl $"http://($env.REMARKABLE_IP)/documents/($collection_id)"        
        | from json 
        | select VissibleName ID Type 
        | input list 
        | if $in.Type == 'DocumentType' { 
            let name = $in.VissibleName; 
            curl $"http://($env.REMARKABLE_IP)/download/($in.ID)/pdf" | save -f $"($name | str snake-case).pdf" 
          } else  {
            download $in.ID
          }
}