Documentation ¶
Index ¶
- Constants
- func Validate(m Metadata) error
- type Chapter
- type ComicInfoXML
- type ComicInfoXMLOptions
- type Date
- type DownloadStatus
- type DownloadedChapter
- type Error
- type ID
- type IDCode
- type IDSource
- type Metadata
- type Provider
- type ProviderInfo
- type ProviderWithCache
- func (p *ProviderWithCache) Authenticated() bool
- func (p *ProviderWithCache) BindTitleWithID(title string, id int) error
- func (p *ProviderWithCache) FindClosest(ctx context.Context, title string, tries, steps int) (Metadata, bool, error)
- func (p *ProviderWithCache) Info() ProviderInfo
- func (p *ProviderWithCache) Logger() *logger.Logger
- func (p *ProviderWithCache) Login(ctx context.Context, token string) error
- func (p *ProviderWithCache) Logout() error
- func (p *ProviderWithCache) Search(ctx context.Context, query string) ([]Metadata, error)
- func (p *ProviderWithCache) SearchByID(ctx context.Context, id int) (Metadata, bool, error)
- func (p *ProviderWithCache) SetLogger(logger *logger.Logger)
- func (p *ProviderWithCache) SetMangaProgress(ctx context.Context, id, chapterNumber int) error
- func (p *ProviderWithCache) String() string
- func (p *ProviderWithCache) User() User
- type ProviderWithCacheOptions
- type SeriesJSON
- type Status
- type User
Constants ¶
const ( FilenameComicInfoXML = "ComicInfo.xml" FilenameSeriesJSON = "series.json" FilenameCoverJPG = "cover.jpg" FilenameBannerJPG = "banner.jpg" )
const ( // QueryToIDs maps manga query to multiple metadata ids. // // ["berserk" => [7, 42, 69], "death note" => [887, 3, 134]] CacheBucketNameQueryToIDs = "query-to-ids" // TitleToID maps manga title to metadata id. // // ["berserk" => 7, "death note" => 3] CacheBucketNameTitleToID = "title-to-id" // IDToManga maps anilist id to metadata manga. // // [7 => "{title: ..., image: ..., ...}"] CacheBucketNameIDToManga = "id-to-manga" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Chapter ¶
type Chapter struct { Title string `json:"title"` URL string `json:"url"` Number float32 `json:"number"` Date Date `json:"date"` ScanlationGroup string `json:"scanlation_group"` Pages int `json:"pages"` }
Chapter is the ComicInfoXML extra chapter information.
type ComicInfoXML ¶
type ComicInfoXML struct { // Title of the book Title string // Series title of the series the book is part of. Series string // Number of the book in the series. Number float32 // Web a URL pointing to a reference website for the book. Web string // Genres of the book or series. For example, Science-Fiction or Shonen. Genres []string // Summary a description or summary of the book. Summary string // Count the total number of books in the series. Count int // PageCount the total pages in the book. PageCount int // Characters present in the book. Characters []string // Year of the book release Year int // Month of the book release Month int // Day of the book release Day int // Publisher person or organization responsible for // publishing, releasing, or issuing a resource. Publisher string // LanguageISO A language code describing the language of the book. LanguageISO string // StoryArc the story arc that books belong to. StoryArc string // StoryArcNumber While StoryArc was originally designed to store the arc within a series, // it was often used to indicate that a book was part of a reading order, composed of books // from multiple series. Mylar for instance was using the field as such. // // Since StoryArc itself wasn't able to carry the information about ordering of books // within a reading order, StoryArcNumber was added. // // StoryArc and StoryArcNumber can work in combination, to indicate in // which position the book is located at for a specific reading order. StoryArcNumber int // ScanInformation is a free text field, usually used to store information about who // scanned the book. ScanInformation string // AgeRating of the book. AgeRating string // CommunityRating Community rating of the book, from 0.0 to 5.0. CommunityRating float32 // Review of the book. Review string // GTIN a Global Trade Item Number identifying the book. // GTIN incorporates other standards like ISBN, ISSN, EAN, or JAN. // // https://en.wikipedia.org/wiki/Global_Trade_Item_Number GTIN string // Format the original publication's binding format for scanned physical books or presentation format for digital sources. // // "TBP", "HC", "Web", "Digital" are common designators. Format string // Writers people or organizations responsible for creating the scenario. Writers []string // Pencillers people or organizations responsible for drawing the art. Pencillers []string // Letterers people or organizations responsible for drawing text and speech bubbles. Letterers []string // Translators people or organizations responsible for rendering a text from one language into another, // or from an older form of a language into the modern form. // // This can also be used for fan translations ("scanlator"). Translators []string // Tags of the book or series. For example, ninja or school life. Tags []string // Notes a free text field, usually used to store information about // the application that created the ComicInfo.xml file. Notes string }
ComicInfoXML contains metadata information about a comic book. It is often used by comic book readers and management software to organize and display information about comic books in a library or collection.
func ToComicInfoXML ¶ added in v0.17.0
func ToComicInfoXML(m Metadata, chapter Chapter) ComicInfoXML
func (*ComicInfoXML) Marshal ¶
func (c *ComicInfoXML) Marshal(options ComicInfoXMLOptions) ([]byte, error)
type ComicInfoXMLOptions ¶
type ComicInfoXMLOptions struct { // AddDate whether to add series release date or not. AddDate bool // AlternativeDate use other date. AlternativeDate *Date }
ComicInfoXMLOptions tweaks ComicInfoXML generation.
func DefaultComicInfoOptions ¶
func DefaultComicInfoOptions() ComicInfoXMLOptions
DefaultComicInfoOptions constructs default ComicInfoXMLOptions.
type DownloadStatus ¶
type DownloadStatus string
const ( DownloadStatusNew DownloadStatus = "new" DownloadStatusSkip DownloadStatus = "skip" DownloadStatusExists DownloadStatus = "exists" DownloadStatusFailed DownloadStatus = "failed" DownloadStatusMissingMetadata DownloadStatus = "missing_metadata" DownloadStatusOverwritten DownloadStatus = "overwritten" )
type DownloadedChapter ¶
type DownloadedChapter struct { // Number of the chapter. Number float32 `json:"number"` // Title of the chapter. Title string `json:"title"` // Filename as written to system. Filename string `json:"filename"` // Directory of the chapter (absolute). Directory string `json:"directory"` // ChapterStatus is the status of the downloaded chapter. ChapterStatus DownloadStatus `json:"chapter_status"` // SeriesJSONStatus is the status of the downloaded series.json. SeriesJSONStatus DownloadStatus `json:"series_json_status"` // ComicInfoXMLStatus is the status of the downloaded ComicInfo.xml. ComicInfoXMLStatus DownloadStatus `json:"comicinfo_xml_status"` // ChapterStatus is the status of the downloaded chapter CoverStatus DownloadStatus `json:"cover_status"` // ChapterStatus is the status of the downloaded chapter. BannerStatus DownloadStatus `json:"banner_status"` }
DownloadedChapter provides general information about the downloaded chapter, and status for the metadata when the chapter was downloaded.
func (*DownloadedChapter) Path ¶
func (d *DownloadedChapter) Path() string
type ID ¶ added in v0.17.0
type ID struct { // Raw id of the manga in the provider. // Must be non-empty unless IDSource is IDSourceProvider. // Must be an integer unless IDSource is IDSourceAnimePlanet. Raw string // Source of the metadata. // Must be non-zero. Source IDSource // Code of the metadata provider. // Must be non-empty. // // For the Provider metadata, the code must be short, ideally 2-3 chars. Code IDCode }
ID is the ID information of the metadata.
type Metadata ¶
type Metadata interface { // String is the short representation of the manga. // Must be non-empty. // // At the minimum it should return "`Title` (`Year`)", else // "`Title` (`Year`) [`IDCode`id-`ID`]" if available. String() string // Title is the English title of the manga. // Must be non-empty. // // If English is not available, then in in order of availability: // Romaji (the romanized title) or Native (usually Kanji). Title() string // AlternateTitles is a list of alternative titles in order of relevance. AlternateTitles() []string // Score is the community score for the manga. // // Accepted values are between 0.0 and 5.0. Score() float32 // Description is the description/summary for the manga. Description() string // Cover is the cover image of the manga. Cover() string // Banner is the banner image of the manga. Banner() string // Tags is the list of tags associated with the manga. Tags() []string // Genres is the list of genres associated with the manga. Genres() []string // Characters is the list of characters, in order of relevance. Characters() []string // Authors (or Writers) is the list of authors, in order of relevance. // Must contain at least one artist. Authors() []string // Artists is the list of artists, in order of relevance. Artists() []string // Translators is the list of translators, in order of relevance. Translators() []string // Letterers is the list of letterers, in order of relevance. Letterers() []string // StartDate is the date the manga started publishing. // Must be non-zero. StartDate() Date // EndDate is the date the manga ended publishing. EndDate() Date // Publisher of the manga. Publisher() string // Current status of the manga. // Must be non-empty. // // One of: FINISHED, RELEASING, NOT_YET_RELEASED, CANCELLED, HIATUS Status() Status // Format the original publication. // // For example: TBP, HC, Web, Digital, etc.. Format() string // Country of origin of the manga. ISO 3166-1 alpha-2 country code. Country() string // Chapter count until this point. Chapters() int // Extra notes to be added. Notes() string // URL is the source URL of the metadata. URL() string // ID is the ID information of the metadata. // Must be valid (ID.Validate). ID() ID // ExtraIDs is a list of extra available IDs in the metadata provider. // Each extra ID must be valid (ID.Validate). ExtraIDs() []ID }
Metadata is the general metadata information about a manga.
In its most basic form, it's just the metadata that is available from the provider. It contains the necessary fields to build the series.json and ComicInfo.xml files.
type Provider ¶ added in v0.20.0
type Provider interface { fmt.Stringer // Info information about Provider. Info() ProviderInfo // SetLogger sets logger to use for this provider. SetLogger(*logger.Logger) // Logger returns the set logger. // // Always returns a non-nil logger. Logger() *logger.Logger // SearchByID for metadata with the given id. // // Implementation should only handle the request and and marshaling. SearchByID(ctx context.Context, id int) (Metadata, bool, error) // Search for metadata with the given query. // // Implementation should only handle the request and and marshaling. Search(ctx context.Context, query string) ([]Metadata, error) // SetMangaProgress sets the reading progress for a given manga metadata id. SetMangaProgress(ctx context.Context, id, chapterNumber int) error // Authenticated returns true if the Provider is // currently authenticated (user logged in). Authenticated() bool // User returns the currently authenticated user. // // nil User means non-authenticated. User() User // Login authorizes an user with the given access token. Login(ctx context.Context, token string) error // Logout de-authorizes the currently authorized user. Logout() error }
Provider exposes methods for searching mangas, getting chapters, pages and images.
type ProviderInfo ¶ added in v0.20.0
type ProviderInfo struct { // ID is the unique identifier of the provider. // // For a ProviderWithCache this is used as the cache DB name. ID string `json:"id"` // Code is the unique code of the provider. // // E.g. IDCodeAnilist, IDCodeMyAnimeList, etc. Code IDCode `json:"code"` // Source is the source of the metadata. // // E.g. IDSourceAnilist, IDSourceMyAnimeList, etc. Source IDSource `json:"source"` // Name is the non-empty name of the provider. Name string `json:"name"` // Version is a semantic version of the provider. // // "v" prefix is not permitted. // E.g. "0.1.0" is valid, but "v0.1.0" is not. // // See https://semver.org/ Version string `json:"version"` // Description of the provider. May be empty. Description string `json:"description"` // Website of the provider. May be empty. Website string `json:"website"` }
ProviderInfo is the passport of the metadata provider.
func (ProviderInfo) Validate ¶ added in v0.20.0
func (p ProviderInfo) Validate() error
Validate checks if the ProviderInfo is valid.
This means that ID and ID are non-empty and Version is a valid semver.
type ProviderWithCache ¶ added in v0.20.0
type ProviderWithCache struct {
// contains filtered or unexported fields
}
ProviderWithCache is a Provider implementation with cache features, and extra search behavior.
This is a wrapper on a normal Provider.
func NewProviderWithCache ¶ added in v0.20.0
func NewProviderWithCache(options ProviderWithCacheOptions) (*ProviderWithCache, error)
NewProviderWithCache constructs new Provider with cache given the Provider.
func (*ProviderWithCache) Authenticated ¶ added in v0.20.0
func (p *ProviderWithCache) Authenticated() bool
Authenticated returns true if the Provider is currently authenticated (user logged in).
func (*ProviderWithCache) BindTitleWithID ¶ added in v0.20.0
func (p *ProviderWithCache) BindTitleWithID(title string, id int) error
BindTitleWithID sets a given id to a title, so on each title search the same manga metadata with that id is obtained.
func (*ProviderWithCache) FindClosest ¶ added in v0.20.0
func (p *ProviderWithCache) FindClosest(ctx context.Context, title string, tries, steps int) (Metadata, bool, error)
FindClosest metadata with the given title with its closest result.
func (*ProviderWithCache) Info ¶ added in v0.20.0
func (p *ProviderWithCache) Info() ProviderInfo
Info information about Provider.
func (*ProviderWithCache) Logger ¶ added in v0.20.0
func (p *ProviderWithCache) Logger() *logger.Logger
Logger returns the set logger.
Always returns a non-nil logger.
func (*ProviderWithCache) Login ¶ added in v0.20.0
func (p *ProviderWithCache) Login(ctx context.Context, token string) error
Login authorizes an user with the given access token.
func (*ProviderWithCache) Logout ¶ added in v0.20.0
func (p *ProviderWithCache) Logout() error
Logout de-authorizes the currently authorized user.
func (*ProviderWithCache) Search ¶ added in v0.20.0
TODO: implement cache for title (get single id by title if existent)?
Search for metadata with the given query.
Implementation should only handle the request and and marshaling.
func (*ProviderWithCache) SearchByID ¶ added in v0.20.0
SearchByID for metadata with the given id.
Implementation should only handle the request and and marshaling.
func (*ProviderWithCache) SetLogger ¶ added in v0.20.0
func (p *ProviderWithCache) SetLogger(logger *logger.Logger)
SetLogger sets logger to use for this provider.
func (*ProviderWithCache) SetMangaProgress ¶ added in v0.20.0
func (p *ProviderWithCache) SetMangaProgress(ctx context.Context, id, chapterNumber int) error
SetMangaProgress sets the reading progress for a given manga metadata id.
For ProviderWithCache this is only a wrapper around the actual provider's method.
func (*ProviderWithCache) String ¶ added in v0.20.0
func (p *ProviderWithCache) String() string
func (*ProviderWithCache) User ¶ added in v0.20.0
func (p *ProviderWithCache) User() User
User returns the currently authenticated user.
nil User means non-authenticated.
type ProviderWithCacheOptions ¶ added in v0.20.0
type ProviderWithCacheOptions struct { // Provider is the underlying provider to which the cache is implemented on. // // Must be non-nil. Provider Provider // CacheStore returns a gokv.Store implementation for use as a cache storage. // // It will use the given provider's ID as the dbName. CacheStore func(dbName, bucketName string) (gokv.Store, error) }
func DefaultProviderWithCacheOptions ¶ added in v0.20.0
func DefaultProviderWithCacheOptions() ProviderWithCacheOptions
DefaultProviderWithCacheOptions constructs the default ProviderWithCacheOptions.
Note: the Provider must be added afterwards, this (for now) only builds a default CacheStore.
type SeriesJSON ¶
type SeriesJSON struct { Type string `json:"type"` Name string `json:"name"` DescriptionFormatted string `json:"description_formatted"` DescriptionText string `json:"description_text"` Status string `json:"status"` Year int `json:"year"` ComicImage string `json:"comic_image"` Publisher string `json:"publisher"` ComicID int `json:"comicid"` BookType string `json:"booktype"` TotalIssues int `json:"total_issues"` PublicationRun string `json:"publication_run"` }
SeriesJSON v1.0.2 is similar to ComicInfoXML but designed for the series as a whole rather than a single chapter. Defined by MyLar.
https://github.com/mylar3/mylar3/wiki/series.json-schema-%28version-1.0.2%29
func ToSeriesJSON ¶ added in v0.17.0
func ToSeriesJSON(m Metadata) SeriesJSON
func (SeriesJSON) Marshal ¶
func (s SeriesJSON) Marshal() ([]byte, error)
TODO: need to decide if HTML escaping should be disabled
type User ¶ added in v0.20.0
type User interface { // String is the short representation of the user. // Must be non-empty. // // For example "`Name` (`ID`)". String() string // ID is the id of the user. ID() int // Name of the user. Name() string // About is the about section of the user. About() string // Avatar is the URL of the avatar image. Avatar() string // URL is the user's URL on the metadata provider website. URL() string // Source provider of the user. // // For example if coming from Anilist: IDSourceAnilist. Source() IDSource }
User is the general authenticated user information.