config

package
v0.0.0-...-03f6f9a Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProgramAuthor      = "Alexander Linkov <kvark128@yandex.ru>"
	ProgramName        = "OnlineLibrary"
	ProgramVersion     = "2024.01.20"
	ProgramDescription = "DAISY Online Client"
	CopyrightInfo      = "Copyright (C) 2020 - 2024 Alexander Linkov"
	ConfigFile         = "config.yaml"
	LogFile            = "session.log"
	MessageBufferSize  = 16
	HTTPTimeout        = time.Second * 12
	LocalStorageID     = "localstorage"
	MetadataFileName   = "metadata.xml"
)
View Source
const (
	MP3_FORMAT = "audio/mpeg"
	LKF_FORMAT = "audio/x-lkf"
	LGK_FORMAT = "application/lgk"
)

Supported mime types of content

Variables

View Source
var (
	BookNotFound      = errors.New("book not found")
	ListeningPosition = "listening_position"
)
View Source
var ReadingSystemAttributes = dodp.ReadingSystemAttributes{
	Manufacturer: ProgramAuthor,
	Model:        ProgramName,
	Version:      ProgramVersion,
	Config: dodp.Config{
		SupportsMultipleSelections:        false,
		PreferredUILanguage:               "ru-RU",
		SupportedContentFormats:           dodp.SupportedContentFormats{},
		SupportedContentProtectionFormats: dodp.SupportedContentProtectionFormats{},
		SupportedMimeTypes:                dodp.SupportedMimeTypes{MimeType: []dodp.MimeType{dodp.MimeType{Type: LKF_FORMAT}, dodp.MimeType{Type: LGK_FORMAT}, dodp.MimeType{Type: MP3_FORMAT}}},
		SupportedInputTypes:               dodp.SupportedInputTypes{Input: []dodp.Input{dodp.Input{Type: dodp.TEXT_ALPHANUMERIC}, dodp.Input{Type: dodp.AUDIO}}},
		RequiresAudioLabels:               false,
	},
}

General client configuration of DAISY-online

View Source
var (
	ServiceNotFound = errors.New("service not found")
)

Functions

func BookDir

func BookDir(name string) (string, error)

BookDir returns the full path to the book directory by it name

func UserData

func UserData() string

Types

type Book

type Book struct {
	// Unique ID of the book
	ID string `yaml:"id"`
	// Values for speed when playing the book
	Speed float64 `yaml:"speed,omitempty"`
	// Set of bookmarks in the book
	Bookmarks map[string]Bookmark `yaml:"bookmarks,omitempty"`
}

type BookSet

type BookSet []Book

func (*BookSet) Book

func (setP *BookSet) Book(id string, defaultSpeed float64) Book

func (*BookSet) LastBook

func (setP *BookSet) LastBook() (Book, error)

func (*BookSet) SetBook

func (setP *BookSet) SetBook(book Book)

func (*BookSet) Tidy

func (setP *BookSet) Tidy(ids []string)

type Bookmark

type Bookmark struct {
	// Name of the bookmark. Reserved for future use
	Name string `yaml:"name,omitempty"`
	// Fragment of a book with the bookmark
	Fragment int `yaml:"fragment"`
	// Offset from the beginning of the fragment
	Position time.Duration `yaml:"position"`
}

type Config

type Config struct {
	General    General    `yaml:"general,omitempty"`
	Services   []*Service `yaml:"services,omitempty"`
	LocalBooks BookSet    `yaml:"local_books,omitempty"`
}

func NewConfig

func NewConfig() *Config

func (*Config) CurrentService

func (cfg *Config) CurrentService() (*Service, error)

func (*Config) Load

func (cfg *Config) Load(path string) error

func (*Config) RemoveService

func (cfg *Config) RemoveService(service *Service) bool

func (*Config) Save

func (cfg *Config) Save(path string) error

func (*Config) ServiceByID

func (cfg *Config) ServiceByID(id string) (*Service, error)

func (*Config) ServiceByName

func (cfg *Config) ServiceByName(name string) (*Service, error)

func (*Config) SetCurrentService

func (cfg *Config) SetCurrentService(service *Service) error

func (*Config) SetService

func (cfg *Config) SetService(service *Service)

type General

type General struct {
	OutputDevice string        `yaml:"output_device,omitempty"`
	Language     string        `yaml:"language,omitempty"`
	Volume       float64       `yaml:"volume,omitempty"`
	PauseTimer   time.Duration `yaml:"pause_timer,omitempty"`
	LogLevel     string        `yaml:"log_level,omitempty"`
	Provider     string        `yaml:"provider,omitempty"`
}

type Service

type Service struct {
	ID                   string  `yaml:"id"`
	Name                 string  `yaml:"name"`
	URL                  string  `yaml:"url"`
	Username             string  `yaml:"username"`
	Password             string  `yaml:"password"`
	OpenBookshelfOnLogin bool    `yaml:"open_bookshelf_on_login"`
	RecentBooks          BookSet `yaml:"books,omitempty"`
}

Jump to

Keyboard shortcuts

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