backend

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HIGHLIGHT_REQUEST_BATCH_MAX = 2000
)

Variables

View Source
var (
	AuthEndpoint  = "https://readwise.io/api/v2/auth/"
	BooksEndpoint = "https://readwise.io/api/v2/books?page_size=1000&category=books&source=OctoberForKobo"

	CoverEndpoint      = "https://readwise.io/api/v2/books/%d"
	HighlightsEndpoint = "https://readwise.io/api/v2/highlights/"
	MaxHighlightLen    = 8096 // It's actually 8191 but we'll go under the limit anyway
	SourceCategory     = "books"
	SourceType         = "OctoberForKobo"
	UserAgent          = "october/2.0.0 <https://github.com/marcus-crane/october>"
)
View Source
var Conn *gorm.DB

Functions

func CloseLogFile added in v1.3.0

func CloseLogFile()

func LocateConfigFile added in v1.6.0

func LocateConfigFile(configFilename string, portable bool) (string, error)

func LocateDataFile added in v1.6.0

func LocateDataFile(configFilename string, portable bool) (string, error)

func NormaliseText

func NormaliseText(s string) string

func OpenConnection

func OpenConnection(filepath string) error

func StartLogger added in v1.3.0

func StartLogger(portable bool)

Types

type Backend

type Backend struct {
	SelectedKobo   Kobo
	ConnectedKobos map[string]Kobo
	RuntimeContext *context.Context
	Settings       *Settings
	Readwise       *Readwise
	Kobo           *Kobo
	Content        *Content
	Bookmark       *Bookmark
	// contains filtered or unexported fields
}

func StartBackend

func StartBackend(ctx *context.Context, version string, portable bool) *Backend

func (*Backend) DetectKobos

func (b *Backend) DetectKobos() []Kobo

func (*Backend) FormatSystemDetails added in v1.3.0

func (b *Backend) FormatSystemDetails() string

func (*Backend) ForwardToReadwise

func (b *Backend) ForwardToReadwise() (int, error)

func (*Backend) GetBookmark

func (b *Backend) GetBookmark() *Bookmark

func (*Backend) GetContent

func (b *Backend) GetContent() *Content

func (*Backend) GetPlainSystemDetails added in v1.3.0

func (b *Backend) GetPlainSystemDetails() string

func (*Backend) GetSelectedKobo

func (b *Backend) GetSelectedKobo() Kobo

func (*Backend) GetSettings

func (b *Backend) GetSettings() *Settings

func (*Backend) NavigateExplorerToLogLocation added in v1.3.0

func (b *Backend) NavigateExplorerToLogLocation()

func (*Backend) PromptForLocalDBPath

func (b *Backend) PromptForLocalDBPath() error

func (*Backend) SelectKobo

func (b *Backend) SelectKobo(devicePath string) error

type BookListEntry

type BookListEntry struct {
	ID        int    `json:"id"`
	Title     string `json:"title"`
	CoverURL  string `json:"cover_image_url"`
	SourceURL string `json:"source_url"`
}

type BookListResponse

type BookListResponse struct {
	Count   int             `json:"count"`
	Results []BookListEntry `json:"results"`
}

type Bookmark

type Bookmark struct {
	BookmarkID               string `gorm:"BookmarkID" json:"bookmark_id"`
	VolumeID                 string `gorm:"column:VolumeID" json:"volume_id"`
	ContentID                string `json:"content_id"`
	StartContainerPath       string
	StartContainerChild      string
	StartContainerChildIndex string
	StartOffset              string
	EndContainerPath         string
	EndContainerChildIndex   string
	EndOffset                string
	Text                     string `gorm:"Text" json:"text"`
	Annotation               string `gorm:"Annotation" json:"annotation"`
	ExtraAnnotationData      string `json:"extra_annotation_data"`
	DateCreated              string `json:"date_created"`
	ChapterProgress          float64
	Hidden                   string
	Version                  string
	DateModified             string
	Creator                  string
	UUID                     string
	UserID                   string
	SyncTime                 string
	Published                string
	ContextString            string
	Type                     string
}

func (Bookmark) TableName

func (Bookmark) TableName() string

type Content

type Content struct {
	ContentID               string `gorm:"column:ContentID" json:"content_id"`
	ContentType             string `gorm:"column:ContentType" json:"content_type"`
	MimeType                string `gorm:"column:MimeType" json:"mime_type"`
	BookID                  string `json:"book_id"`
	BookTitle               string `gorm:"column:BookTitle" json:"book_title"`
	ImageId                 string `json:"image_id"`
	Title                   string `gorm:"column:Title" json:"title"`
	Attribution             string `gorm:"column:Attribution" json:"attribution"`
	Description             string `gorm:"column:Description" json:"description"`
	DateCreated             string `gorm:"column:DateCreated" json:"date_created"`
	ShortCoverKey           string
	AdobeLocation           string `gorm:"column:adobe_location"`
	Publisher               string
	IsEncrypted             bool
	DateLastRead            string `json:"date_last_read"`
	FirstTimeReading        bool
	ChapterIDBookmarked     string
	ParagraphBookmarked     int
	BookmarkWordOffset      int
	NumShortcovers          int
	VolumeIndex             int `gorm:"column:VolumeIndex"`
	NumPages                int `gorm:"column:___NumPages" json:"num_pages"`
	ReadStatus              int
	SyncTime                string `gorm:"column:___SyncTime"`
	UserID                  string `gorm:"column:___UserID"`
	PublicationId           string
	FileOffset              int    `gorm:"column:___FileOffset"`
	FileSize                int    `gorm:"column:___FileSize"`
	PercentRead             string `gorm:"column:___PercentRead" json:"percent_read"`
	ExpirationStatus        int    `gorm:"column:___ExpirationStatus"`
	FavouritesIndex         int
	Accessibility           int
	ContentURL              string
	Language                string
	BookshelfTags           string
	IsDownloaded            bool
	FeedbackType            int
	AverageRating           float64
	Depth                   int
	PageProgressDirection   string
	InWishlist              string
	ISBN                    string
	WishlistedDate          string
	FeedbackTypeSynced      bool
	IsSocialEnabled         bool
	EpubType                string
	Monetization            string
	ExternalId              string
	Series                  string
	SeriesNumber            string
	Subtitle                string
	WordCount               string
	Fallback                string
	RestOfBookEstimate      string
	CurrentChapterEstimate  string
	CurrentChapterProgress  float32
	PocketStatus            string
	UnsyncedPocketChanges   string
	ImageUrl                string
	DateAdded               string
	WorkId                  string
	Properties              string
	RenditionSpread         string
	RatingCount             string
	ReviewsSyncDate         string
	MediaOverlay            string
	RedirectPreviewUrl      bool
	PreviewFileSize         int
	EntitlementId           string
	CrossRevisionId         string
	DownloadUrl             bool
	ReadStateSynced         bool
	TimesStartedReading     int
	TimeSpentReading        int
	LastTimeStartedReading  string
	LastTimeFinishedReading string
	ApplicableSubscriptions string
	ExternalIds             string
	PurchaseRevisionId      string
	SeriesID                string
	SeriesNumberFloat       float64
	AdobeLoanExpiration     string
	HideFromHomePage        bool
	IsInternetArchive       bool
	TitleKana               string `gorm:"column:titleKana"`
	SubtitleKana            string `gorm:"column:subtitleKana"`
	SeriesKana              string `gorm:"column:seriesKana"`
	AttributionKana         string `gorm:"column:attributionKana"`
	PublisherKana           string `gorm:"column:publisherKana"`
	IsPurchaseable          bool
	IsSupported             bool
	AnnotationsSyncToken    string
	DateModified            string
}

func (Content) TableName

func (Content) TableName() string

type CoverUpdate

type CoverUpdate struct {
	Cover string `json:"cover"`
}

type Highlight

type Highlight struct {
	Text          string `json:"text"`
	Title         string `json:"title,omitempty"`
	Author        string `json:"author,omitempty"`
	SourceURL     string `json:"source_url"`
	SourceType    string `json:"source_type"`
	Category      string `json:"category"`
	Note          string `json:"note,omitempty"`
	HighlightedAt string `json:"highlighted_at,omitempty"`
}

type HighlightCounts added in v1.4.0

type HighlightCounts struct {
	Total      int64 `json:"total"`
	Sideloaded int64 `json:"sideloaded"`
	Official   int64 `json:"official"`
}

type Kobo

type Kobo struct {
	Name       string `json:"name"`
	Storage    int    `json:"storage"`
	DisplayPPI int    `json:"display_ppi"`
	MntPath    string `json:"mnt_path"`
	DbPath     string `json:"db_path"`
}

func GetKoboMetadata

func GetKoboMetadata(detectedPaths []string) []Kobo

func (*Kobo) BuildContentIndex

func (k *Kobo) BuildContentIndex(content []Content) map[string]Content

func (*Kobo) CountDeviceBookmarks

func (k *Kobo) CountDeviceBookmarks() HighlightCounts

func (*Kobo) ListDeviceBookmarks

func (k *Kobo) ListDeviceBookmarks(includeStoreBought bool) ([]Bookmark, error)

func (*Kobo) ListDeviceContent

func (k *Kobo) ListDeviceContent(includeStoreBought bool) ([]Content, error)

type Readwise

type Readwise struct{}

func (*Readwise) CheckTokenValidity

func (r *Readwise) CheckTokenValidity(token string) error

func (*Readwise) RetrieveUploadedBooks

func (r *Readwise) RetrieveUploadedBooks(token string) (BookListResponse, error)

func (*Readwise) SendBookmarks

func (r *Readwise) SendBookmarks(payloads []Response, token string) (int, error)

func (*Readwise) UploadCover

func (r *Readwise) UploadCover(encodedCover string, bookId int, token string) error

type Response

type Response struct {
	Highlights []Highlight `json:"highlights"`
}

func BuildPayload

func BuildPayload(bookmarks []Bookmark, contentIndex map[string]Content) ([]Response, error)

type Settings

type Settings struct {
	ReadwiseToken          string `json:"readwise_token"`
	UploadCovers           bool   `json:"upload_covers"`
	UploadStoreHighlights  bool   `json:"upload_store_highlights"`
	UploadStorePromptShown bool   `json:"upload_store_prompt_shown"`
	// contains filtered or unexported fields
}

func LoadSettings

func LoadSettings(portable bool) (*Settings, error)

func (*Settings) MarkUploadStorePromptShown added in v1.4.0

func (s *Settings) MarkUploadStorePromptShown() error

func (*Settings) Save

func (s *Settings) Save() error

func (*Settings) SaveCoverUploading

func (s *Settings) SaveCoverUploading(uploadCovers bool) error

func (*Settings) SaveStoreHighlights added in v1.4.0

func (s *Settings) SaveStoreHighlights(uploadStoreHighlights bool) error

func (*Settings) SaveToken

func (s *Settings) SaveToken(token string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL