comicinfo

package module
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: MIT Imports: 5 Imported by: 1

README

go-comicinfo

Go Reference Go Report Card codecov

Golang implementation of the ComicInfo.xml specification to read and write comicinfo.xml files.

Contributing

Contributions are welcome, please open an issue or a pull request.

Versioning

This project uses Semantic Versioning and will follow the major and minor versions of the ComicInfo.xml specification, while using the hotfix version for any changes to the library itself.

Usage example

package main

import "github.com/fmartingr/go-comicinfo/v2"

func main() {
	ci := comicinfo.NewComicInfo()
	ci.Series = "One Piece"
	ci.Number = "3093"
	ci.Summary = "Luffy and the Straw Hat Pirates return in an all-new Epic Voyage!"
	ci.AgeRating = comicinfo.AgeRatingEveryone
	ci.LanguageISO = "en"

	for i := 1; i <= 17; i++ {
		ci.Pages.Pages = append(ci.Pages.Pages, comicinfo.ComicPageInfo{
			Image: i,
		})
	}

	_ = comicinfo.Write(ci, "volume/comicinfo.xml")
}

Result

<?xml version="1.0" encoding="UTF-8"?>
<ComicInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Series>One Piece</Series>
    <Number>3093</Number>
    <Summary>Luffy and the Straw Hat Pirates return in an all-new Epic Voyage!</Summary>
    <LanguageISO>en</LanguageISO>
    <AgeRating>Everyone</AgeRating>
    <Pages>
        <Page Image="1"></Page>
        <Page Image="2"></Page>
        <Page Image="3"></Page>
        <Page Image="4"></Page>
        <Page Image="5"></Page>
        <Page Image="6"></Page>
        <Page Image="7"></Page>
        <Page Image="8"></Page>
        <Page Image="9"></Page>
        <Page Image="10"></Page>
        <Page Image="11"></Page>
        <Page Image="12"></Page>
        <Page Image="13"></Page>
        <Page Image="14"></Page>
        <Page Image="15"></Page>
        <Page Image="16"></Page>
        <Page Image="17"></Page>
    </Pages>
</ComicInfo>

License

MIT LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Save added in v2.0.2

func Save(ci *ComicInfo, path string) error

Save writes the ComicInfo spec to the specified path.

func Write

func Write(ci *ComicInfo, w io.Writer) error

Write writes the ComicInfo spec to the specified writter

Types

type AgeRating

type AgeRating string

AgeRating defines the AgeRating type

var (
	AgeRatingUnknown          AgeRating = "Unknown"
	AgeRatingAdultsOnlyPlus18 AgeRating = "Adults Only 18+"
	AgeRatingEarlyChildhood   AgeRating = "Early Childhood"
	AgeRatingEveryone         AgeRating = "Everyone"
	AgeRatingEveryone10Plus   AgeRating = "Everyone 10+"
	AgeRatingG                AgeRating = "G"
	AgeRatingKidsToAdults     AgeRating = "Kids to Adults"
	AgeRatingM                AgeRating = "M"
	AgeRatingMAPlus15         AgeRating = "MA15+"
	AgeRatingMaturePlus17     AgeRating = "Mature 17+"
	AgeRatingPG               AgeRating = "PG"
	AgeRatingRPlus18          AgeRating = "R18+"
	AgeRatingPending          AgeRating = "Rating Pending"
	AgeRatingTeen             AgeRating = "Teen"
	AgeRatingXPlus18          AgeRating = "X18+"
)

type ComicInfo

type ComicInfo struct {
	Title               string    `xml:"Title,omitempty"`
	Series              string    `xml:"Series,omitempty"`
	Number              string    `xml:"Number,omitempty"`
	Count               int       `xml:"Count,omitempty"`
	Volume              int       `xml:"Volume,omitempty"`
	AlternateSeries     string    `xml:"AlternateSeries,omitempty"`
	AlternateNumber     string    `xml:"AlternateNumber,omitempty"`
	AlternateCount      int       `xml:"AlternateCount,omitempty"`
	Summary             string    `xml:"Summary,omitempty"`
	Notes               string    `xml:"Notes,omitempty"`
	Year                int       `xml:"Year,omitempty"`
	Month               int       `xml:"Month,omitempty"`
	Day                 int       `xml:"Day,omitempty"`
	Writer              string    `xml:"Writer,omitempty"`
	Penciller           string    `xml:"Penciller,omitempty"`
	Inker               string    `xml:"Inker,omitempty"`
	Colorist            string    `xml:"Colorist,omitempty"`
	Letterer            string    `xml:"Letterer,omitempty"`
	CoverArtist         string    `xml:"CoverArtist,omitempty"`
	Editor              string    `xml:"Editor,omitempty"`
	Publisher           string    `xml:"Publisher,omitempty"`
	Imprint             string    `xml:"Imprint,omitempty"`
	Genre               string    `xml:"Genre,omitempty"`
	Web                 string    `xml:"Web,omitempty"`
	PageCount           int       `xml:"PageCount,omitempty"`
	LanguageISO         string    `xml:"LanguageISO,omitempty"`
	Format              string    `xml:"Format,omitempty"`
	BlackAndWhite       YesNo     `xml:"BlackAndWhite,omitempty"`
	Manga               Manga     `xml:"Manga,omitempty"`
	Characters          string    `xml:"Characters,omitempty"`
	Teams               string    `xml:"Teams,omitempty"`
	Locations           string    `xml:"Locations,omitempty"`
	ScanInformation     string    `xml:"ScanInformation,omitempty"`
	StoryArc            string    `xml:"StoryArc,omitempty"`
	SeriesGroup         string    `xml:"SeriesGroup,omitempty"`
	AgeRating           AgeRating `xml:"AgeRating,omitempty"`
	Pages               Pages     `xml:"Pages,omitempty"`
	CommunityRating     Rating    `xml:"CommunityRating,omitempty"`
	MainCharacterOrTeam string    `xml:"MainCharacterOrTeam,omitempty"`
	Review              string    `xml:"Review,omitempty"`

	// Internal
	XmlnsXsd string `xml:"xmlns:xsd,attr"`
	XmlNsXsi string `xml:"xmlns:xsi,attr"`
}

ComicInfo ...

func NewComicInfo

func NewComicInfo() *ComicInfo

New provides a new ComicInfo struct with the XML attributes set

func Open added in v2.0.1

func Open(path string) (*ComicInfo, error)

Read reads the ComicInfo spec from the specified path.

func Read

func Read(r io.Reader) (*ComicInfo, error)

Read reads the ComicInfo spec from the specified reader

func (*ComicInfo) SetXMLAttributes

func (ci *ComicInfo) SetXMLAttributes()

type ComicPageInfo

type ComicPageInfo struct {
	Image       int           `xml:"Image,attr"`
	Type        ComicPageType `xml:"Type,omitempty,attr"`
	DoublePage  bool          `xml:"DoublePage,omitempty,attr"`
	ImageSize   int64         `xml:"ImageSize,omitempty,attr"`
	Key         string        `xml:"Key,omitempty,attr"`
	Bookmark    string        `xml:"Bookmark,omitempty,attr"`
	ImageWidth  int           `xml:"ImageWidth,omitempty,attr"`
	ImageHeight int           `xml:"ImageHeight,omitempty,attr"`
}

ComicPageInfo defines the ComicPageInfo type

func NewComicPageInfo

func NewComicPageInfo() ComicPageInfo

NewComicPageInfo provides a new ComicPageInfo struct with the XML attributes set

type ComicPageType

type ComicPageType string

ComicPageType defines the ComicPageType type

var (
	ComicPageTypeFrontCover    ComicPageType = "FrontCover"
	ComicPageTypeInnerCover    ComicPageType = "InnerCover"
	ComicPageTypeRoundup       ComicPageType = "Roundup"
	ComicPageTypeStory         ComicPageType = "Story"
	ComicPageTypeAdvertisement ComicPageType = "Advertisement"
	ComicPageTypeEditorial     ComicPageType = "Editorial"
	ComicPageTypeLetters       ComicPageType = "Letters"
	ComicPageTypePreview       ComicPageType = "Preview"
	ComicPageTypeBackCover     ComicPageType = "BackCover"
	ComicPageTypeOther         ComicPageType = "Other"
	ComicPageTypeDeleted       ComicPageType = "Deleted"
)

type Manga

type Manga string

Manga defines the Manga type

var (
	MangaUnknown           Manga = "Unknown"
	MangaYes               Manga = "Yes"
	MangaNo                Manga = "No"
	MangeYesAndRightToLeft Manga = "YesAndRightToLeft"
)

type Pages

type Pages struct {
	Pages []ComicPageInfo `xml:"Page,omitempty"`
}

Pages defines the Pages type (slice of ComicPageInfo for proper XML marshalling)

type Rating

type Rating float64

Rating defines the Rating type

type YesNo

type YesNo string

YesNo defines the YesNo type

var (
	YesNoUnknown YesNo = "Unknown"
	Yes          YesNo = "Yes"
	No           YesNo = "No"
)

Jump to

Keyboard shortcuts

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