blob: 2383ba683fffa3edf64e3291f0101c86b57250e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
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
}
}
export def backup [] {
let old_backup_path = $"($env.REMARKABLE_BACKUP_PATH)/RemarkableDocumentData/Old"
let current_backup_path = $"($env.REMARKABLE_BACKUP_PATH)/RemarkableDocumentData/CurrentBackup"
if (ls $current_backup_path | length) > 0 {
if (ls $old_backup_path | length) > 0 {
print "Deleting old backup..."
rm -r $"($old_backup_path)/*"
}
print "Moving current backup to old backup directory..."
mv $"($current_backup_path)/*" $old_backup_path
}
print "Backing up Remarkable document data..."
scp -r $"($env.REMARKABLE_SSH):/home/root/.local/share/remarkable/xochitl/*" $current_backup_path
}
|