fanbox

package
v0.0.0-...-808a313 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Domain     = "fanbox.cc"
	CookieURL  = "https://.fanbox.cc"
	OriginURL  = "https://www.fanbox.cc"
	RefererURL = "https://www.fanbox.cc/"
	APIURL     = "https://api.fanbox.cc"

	UserAgent = "" +
		"Mozilla/5.0 (X11; Linux x86_64) " +
		"AppleWebKit/537.36 (KHTML, like Gecko) " +
		"Chrome/88.0.4300.0 " +
		"Safari/537.36"
)

Functions

func PostImageURL

func PostImageURL(postID, imageID string) string

PostImageURL returns the direct link to the image in JPEG format.

Types

type ArticleBody

type ArticleBody struct {
	Blocks   []ArticleBodyBlock `json:"blocks"`
	ImageMap map[string]Image   `json:"imageMap"`
}

type ArticleBodyBlock

type ArticleBodyBlock struct {
	Type    string `json:"type"`
	Text    string `json:"text,omitempty"`    // Type == "p"
	ImageID string `json:"imageId,omitempty"` // Type == "image"
}

type DateTime

type DateTime time.Time

func (*DateTime) UnmarshalJSON

func (dt *DateTime) UnmarshalJSON(b []byte) error

type File

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

type FileBody

type FileBody struct {
	Files []File `json:"files"`
	Text  string `json:"text"`
}

type Image

type Image struct {
	ID           string `json:"id"`
	Extension    string `json:"extension"`
	Width        int    `json:"width"`
	Height       int    `json:"height"`
	OriginalURL  string `json:"originalUrl"`
	ThumbnailURL string `json:"thumbnailUrl"`
}

type ImageBody

type ImageBody struct {
	Text   string  `json:"text"`
	Images []Image `json:"images"`
}

type Item

type Item struct {
	ItemBase
	Body ItemBody `json:"body"` // ArticleBody || ImageBody
}

func (*Item) UnmarshalJSON

func (i *Item) UnmarshalJSON(b []byte) error

type ItemBase

type ItemBase struct {
	ID                string   `json:"id"`
	Title             string   `json:"title"`
	Type              ItemType `json:"type"`
	CoverImageURL     string   `json:"coverImageUrl"`
	FeeRequired       int      `json:"feeRequired"`
	PublishedDateTime DateTime `json:"publishedDatetime"`
	UpdatedDateTime   DateTime `json:"updatedDatetime"`
	Excerpt           string   `json:"excerpt"`
	IsLiked           bool     `json:"isLiked"`
	LikeCount         int      `json:"likeCount"`
	CommentCount      int      `json:"commentCount"`
	User              User     `json:"user"`
	CreatorID         string   `json:"creatorId"`
	HasAdultContent   bool     `json:"hasAdultContent"`
	Status            string   `json:"status"`
}

func (ItemBase) URL

func (i ItemBase) URL() string

URL returns the direct URL to the post.

type ItemBody

type ItemBody interface {
	// contains filtered or unexported methods
}

type ItemType

type ItemType string
const (
	ItemTypeArticle ItemType = "article"
	ItemTypeImage   ItemType = "image"
	ItemTypeFile    ItemType = "file"
)

type Page

type Page struct {
	Body PageBody `json:"body"`
}

type PageBody

type PageBody struct {
	Items   []Item `json:"items"`
	NextURL string `json:"nextUrl"`
}

type Session

type Session struct {
	*SessionClient
}

Session is a Pixiv user session. It is copyable.

func New

func New(sessionID string) *Session

func (*Session) Posts

func (s *Session) Posts() (*Page, error)

Posts returns the first 10 posts in the homepage.

func (*Session) PostsFromURL

func (s *Session) PostsFromURL(url string) (*Page, error)

func (*Session) SupportingPosts

func (s *Session) SupportingPosts() (*Page, error)

SupportingPosts returns the first 10 posts in the homepage, except it only shows creators that the user is supporting.

type SessionClient

type SessionClient struct {
	Client  *http.Client
	Retries int
}

SessionClient contains methods to request with the required cookies.

func NewSessionClient

func NewSessionClient() *SessionClient

func (*SessionClient) Do

func (sc *SessionClient) Do(r *http.Request) (*http.Response, error)

func (*SessionClient) Download

func (sc *SessionClient) Download(url string) (body io.ReadCloser, err error)

func (*SessionClient) Get

func (sc *SessionClient) Get(url string, v interface{}) error

type User

type User struct {
	UserID  string `json:"userId"`
	Name    string `json:"name"`
	IconURL string `json:"iconUrl"`
}

Jump to

Keyboard shortcuts

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