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 }