Documentation
¶
Overview ¶
Package archive is used to parse a .zip file retrieved by the API.
Here is the content of an archive retried on the tablet as example: 384327f5-133e-49c8-82ff-30aa19f3cfa4.content 384327f5-133e-49c8-82ff-30aa19f3cfa4//0-metadata.json 384327f5-133e-49c8-82ff-30aa19f3cfa4//0.rm 384327f5-133e-49c8-82ff-30aa19f3cfa4.pagedata 384327f5-133e-49c8-82ff-30aa19f3cfa4.thumbnails/0.jpg
As the .zip file from remarkable is simply a normal .zip file containing specific file formats, this package is a helper to read and write zip files with the correct format expected by the tablet.
At the core of this archive package, we have the Zip struct that is defined and that represents a Remarkable zip file. Then it provides a Zip.Read() method to unmarshal data from an io.Reader into a Zip struct and a Zip.Write() method to marshal a Zip struct into a io.Writer.
In order to correctly use this package, you will have to understand the format of a Remarkable zip file, and the format of the files that it contains.
You can find some help about the format at the following URL: https://remarkablewiki.com/tech/filesystem
You can also display the go documentation of public structs of this package to have more information. This will be completed in the future hopefully to have a precise overall documentation directly held in this Golang package.
Note that the binary format ".rm" holding the drawing contained in a zip has a dedicated golang package and is not decoded/encoded from the archive package. See encoding/rm in this repository.
To have a more concrete example, see the test files of this package.
Index ¶
- func CreateContent(id, ext, fpath string, pageIds []string) (fileName, filePath string, err error)
- func CreateMetadata(id, name, parent, colType, fpath string) (fileName string, filePath string, err error)
- func CreateZipDirectory(id string) (string, error)
- func CreateZipDocument(id, srcPath string) (zipPath string, err error)
- func FixMetadata(parentId, name, path string) error
- func GetIdFromZip(srcPath string) (id string, err error)
- func UnixTimestamp() string
- type Content
- type DocumentFiles
- type ExtraMetadata
- type Layer
- type Metadata
- type MetadataFile
- type NamePath
- type Page
- type Transform
- type Zip
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateContent ¶ added in v0.0.16
func CreateMetadata ¶ added in v0.0.16
func CreateZipDirectory ¶ added in v0.0.11
func CreateZipDocument ¶ added in v0.0.11
func FixMetadata ¶ added in v0.0.16
FixMetadata fixes the metadata with the new parent and filename
func GetIdFromZip ¶ added in v0.0.11
GetIdFromZip tries to get the Document UUID from an archive
func UnixTimestamp ¶ added in v0.0.21
func UnixTimestamp() string
Types ¶
type Content ¶ added in v0.0.6
type Content struct { DummyDocument bool `json:"dummyDocument"` ExtraMetadata ExtraMetadata `json:"extraMetadata"` // FileType is "pdf", "epub" or empty for a simple note FileType string `json:"fileType"` FontName string `json:"fontName"` LastOpenedPage int `json:"lastOpenedPage"` LineHeight int `json:"lineHeight"` Margins int `json:"margins"` // Orientation can take "portrait" or "landscape". Orientation string `json:"orientation"` PageCount int `json:"pageCount"` // Pages is a list of page IDs Pages []string `json:"pages"` Tags []string `json:"pageTags"` RedirectionMap []int `json:"redirectionPageMap"` TextScale int `json:"textScale"` Transform Transform `json:"transform"` }
Content represents the structure of a .content json file.
type DocumentFiles ¶ added in v0.0.18
type DocumentFiles struct {
Files []NamePath
}
func Prepare ¶ added in v0.0.16
func Prepare(name, parentId, sourceDocPath, ext, tmpDir string) (files *DocumentFiles, id string, err error)
Prepare prepares a file for uploading (creates needed temp files or unpacks a zip)
func Unpack ¶ added in v0.0.16
func Unpack(src, dest string) (id string, files *DocumentFiles, metadataPath string, err error)
Unpack unpacks a rmapi .zip file
func (*DocumentFiles) AddMap ¶ added in v0.0.18
func (d *DocumentFiles) AddMap(name, filepath string)
type ExtraMetadata ¶ added in v0.0.6
type ExtraMetadata struct { LastBrushColor string `json:"LastBrushColor"` LastBrushThicknessScale string `json:"LastBrushThicknessScale"` LastColor string `json:"LastColor"` LastEraserThicknessScale string `json:"LastEraserThicknessScale"` LastEraserTool string `json:"LastEraserTool"` LastPen string `json:"LastPen"` LastPenColor string `json:"LastPenColor"` LastPenThicknessScale string `json:"LastPenThicknessScale"` LastPencil string `json:"LastPencil"` LastPencilColor string `json:"LastPencilColor"` LastPencilThicknessScale string `json:"LastPencilThicknessScale"` LastTool string `json:"LastTool"` ThicknessScale string `json:"ThicknessScale"` LastFinelinerv2Size string `json:"LastFinelinerv2Size"` }
ExtraMetadata is a struct contained into a Content struct.
type Layer ¶ added in v0.0.6
type Layer struct {
Name string `json:"name"`
}
Layers is a struct contained into a Metadata struct.
type Metadata ¶ added in v0.0.6
type Metadata struct {
Layers []Layer `json:"layers"`
}
Metadata represents the structure of a .metadata json file associated to a page.
type MetadataFile ¶ added in v0.0.16
type MetadataFile struct { DocName string `json:"visibleName"` CollectionType string `json:"type"` Parent string `json:"parent"` //LastModified in milliseconds LastModified string `json:"lastModified"` LastOpened string `json:"lastOpened"` LastOpenedPage int `json:"lastOpenedPage"` Version int `json:"version"` Pinned bool `json:"pinned"` Synced bool `json:"synced"` Modified bool `json:"modified"` Deleted bool `json:"deleted"` MetadataModified bool `json:"metadatamodified"` }
MetadataFile content
type Page ¶
type Page struct { // Data is the rm binary encoded file representing the drawn content Data *rm.Rm // Metadata is a json file containing information about layers Metadata Metadata // Thumbnail is a small image of the overall page Thumbnail []byte // Pagedata contains the name of the selected background template Pagedata string // page number of the underlying document DocPage int }
A Page represents a note page.
type Transform ¶ added in v0.0.6
type Transform struct { M11 float32 `json:"m11"` M12 float32 `json:"m12"` M13 float32 `json:"m13"` M21 float32 `json:"m21"` M22 float32 `json:"m22"` M23 float32 `json:"m23"` M31 float32 `json:"m31"` M32 float32 `json:"m32"` M33 float32 `json:"m33"` }
Transform is a struct contained into a Content struct.