publication

package
v0.0.0-...-0f3d56e Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CatalogURL = "https://app.jw-cdn.org/catalogs/publications/v4/%s/catalog.db.gz"

CatalogURL is the URL to the publication catalog

View Source
var ManifestURL = "https://app.jw-cdn.org/catalogs/publications/v4/manifest.json"

ManifestURL is the URL to the publication manifest

Functions

func CatalogExists

func CatalogExists(path string) bool

CatalogExists checks if catalog.db exists at path

func CatalogNeedsUpdate

func CatalogNeedsUpdate(path string) bool

CatalogNeedsUpdate checks if catalog.db located at path is still up-to-date. For now it just makes sure that it is younger than one month. If it can't find a file at path, it returns true

func CatalogSize

func CatalogSize(path string) int64

CatalogSize returns the size of the catalog.db at path

func DownloadCatalog

func DownloadCatalog(ctx context.Context, prgrs chan Progress, dst string) error

DownloadCatalog downloads the newest catalog.db and saves it at dst. The prgrs channel informs about the progress of the download.

Types

type Lookup

type Lookup struct {
	DocumentID     int
	KeySymbol      string
	IssueTagNumber int
	MepsLanguage   int
}

Lookup represents a lookup for a publication. This query can contain various fields.

type Progress

type Progress struct {
	Size           int64
	BytesComplete  int64
	BytesPerSecond float64
	Progress       float64
	Duration       time.Duration
	ETA            time.Time
	Done           bool
}

Progress represents the progress of a running download

type Publication

type Publication struct {
	ID                    int
	PublicationRootKeyID  int
	MepsLanguageID        int
	PublicationTypeID     int
	IssueTagNumber        int
	Title                 string
	IssueTitle            sql.NullString
	ShortTitle            string
	CoverTitle            sql.NullString
	UndatedTitle          sql.NullString
	UndatedReferenceTitle sql.NullString
	Year                  int
	Symbol                string
	KeySymbol             sql.NullString
	Reserved              int
}

Publication represents a publication with all its information from the catalogDB

func LookupPublication

func LookupPublication(dbPath string, query Lookup) (Publication, error)

LookupPublication looks up a publication from catalogDB located at dbPath

func (Publication) MarshalJSON

func (m Publication) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of the entry

Jump to

Keyboard shortcuts

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