fanbox

package
v0.27.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFailedToThumbnailing = fmt.Errorf("failed to thumbnailing")
View Source
var ErrStatusForbidden = errors.New("status code 403")

Functions

func IsFailedToThumbnailingErr added in v0.25.0

func IsFailedToThumbnailingErr(resp *http.Response) (bool, error)

fanbox returns HTTP 500 error and response body is "failed to thumbnailing" when the image is not available (e.g. too large).

Types

type Block

type Block struct {
	Type    string  `json:"type"` // p(text) or image.
	ImageID *string `json:"imageId"`
	FileID  *string `json:"fileId"`
}

type Client

type Client struct {
	CheckAllPosts     bool
	DryRun            bool
	SkipFiles         bool
	SkipImages        bool
	SkipOnError       bool
	OfficialAPIClient *OfficialAPIClient
	Storage           *LocalStorage
}

Client is the struct for Client.

func (*Client) Run

func (c *Client) Run(ctx context.Context, creatorID string) error

type Creator added in v0.11.0

type Creator struct {
	CreatorID string `json:"creatorId"`
}

type CreatorIDLister added in v0.15.0

type CreatorIDLister struct {
	OfficialAPIClient *OfficialAPIClient
}

func (*CreatorIDLister) Do added in v0.15.0

type CreatorIDListerDoInput added in v0.15.0

type CreatorIDListerDoInput struct {
	InputCreatorIDs   []string
	IncludeSupporting bool
	IncludeFollowing  bool
	IgnoreCreatorIDs  []string
}

type CreatorListFollowingResponse added in v0.15.0

type CreatorListFollowingResponse struct {
	Body []Creator `json:"body"`
}

type Downloadable added in v0.15.0

type Downloadable interface {
	GetID() string
	GetURL() string
	GetThumbnailURL() (string, bool)
	GetExtension() string
}

type File added in v0.12.0

type File struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Extension string `json:"extension"`
	URL       string `json:"url"`
}

File represents a uploaded file.

func (File) GetExtension added in v0.15.0

func (f File) GetExtension() string

func (File) GetID added in v0.15.0

func (f File) GetID() string

func (File) GetThumbnailURL added in v0.25.0

func (f File) GetThumbnailURL() (string, bool)

func (File) GetURL added in v0.15.0

func (f File) GetURL() string

type Image

type Image struct {
	ID           string `json:"id"`
	Extension    string `json:"extension"`
	OriginalURL  string `json:"originalUrl"`
	ThumbnailURL string `json:"thumbnailUrl"`
}

Image represents a uploaded image.

func (Image) GetExtension added in v0.15.0

func (i Image) GetExtension() string

func (Image) GetID added in v0.15.0

func (i Image) GetID() string

func (Image) GetThumbnailURL added in v0.25.0

func (i Image) GetThumbnailURL() (string, bool)

func (Image) GetURL added in v0.15.0

func (i Image) GetURL() string

type ListCreatorResponse added in v0.15.0

type ListCreatorResponse struct {
	Body []Post `json:"body"`
}

ListCreatorResponse represents the response of https://api.fanbox.cc/post.listCreator.

type LocalStorage added in v0.15.0

type LocalStorage struct {
	SaveDir   string
	DirByPost bool
	DirByPlan bool

	RemoveUnprintableChars bool
}

func (*LocalStorage) Exist added in v0.15.0

func (s *LocalStorage) Exist(post Post, order int, d Downloadable) (bool, error)

func (*LocalStorage) Save added in v0.15.0

func (s *LocalStorage) Save(post Post, order int, d Downloadable, r io.Reader) error

type OfficialAPIClient added in v0.15.0

type OfficialAPIClient struct {
	HTTPClient *retryablehttp.Client
	Cookie     string
	UserAgent  string
}

func (*OfficialAPIClient) Request added in v0.15.0

func (c *OfficialAPIClient) Request(ctx context.Context, method string, url string) (*http.Response, error)

func (*OfficialAPIClient) RequestAndUnwrapJSON added in v0.15.0

func (c *OfficialAPIClient) RequestAndUnwrapJSON(ctx context.Context, method string, url string, v interface{}) error

type Pagination added in v0.23.0

type Pagination struct {
	Pages []string `json:"body"`
}

Pagination represents the response of https://api.fanbox.cc/post.paginateCreator?creatorId=x.

type Plan added in v0.10.0

type Plan struct {
	CreatorID string `json:"creatorId"`
}

type PlanListSupportingResponse added in v0.15.0

type PlanListSupportingResponse struct {
	Body []Plan `json:"body"`
}

type Post

type Post struct {
	ID                string    `json:"id"`
	Title             string    `json:"title"`
	PublishedDateTime string    `json:"publishedDatetime"`
	CreatorID         string    `json:"creatorId"`
	FeeRequired       int       `json:"feeRequired"`
	IsRestricted      bool      `json:"isRestricted"`
	IsPinned          bool      `json:"isPinned"`
	Body              *PostBody `json:"body"`
}

Post represents post attributes.

func (*Post) ListDownloadable added in v0.15.0

func (f *Post) ListDownloadable() []Downloadable

type PostBody

type PostBody struct {
	// Files is not nil if post type is "file".
	Files *[]File `json:"files"`
	// Images is not nil if post type is "image".
	Images *[]Image `json:"images"`
	// Blocks is not nil if post type is "blog".
	Blocks *[]Block `json:"blocks"`
	// ImageMap is not nil if post type is "blog".
	ImageMap *map[string]Image `json:"imageMap"`
	// FileMap is not nil if post type is "blog".
	FileMap *map[string]File `json:"fileMap"`
}

type PostInfoResponse added in v0.15.0

type PostInfoResponse struct {
	Body Post `json:"body"`
}

PostInfoResponse represents the response of https://api.fanbox.cc/post.info.

Jump to

Keyboard shortcuts

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