faapi

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: BSD-3-Clause Imports: 15 Imported by: 2

README

Go language API wrapper for Fur Affinity, since they don't provide any API whatsoever. Parses HTML responses.

Make sure that the account you use with this has the Classic UI template selected, or some things may not work right.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotLoggedIn = errors.New("not logged in")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a FurAffinity client.

func New

func New(config Config) (*Client, error)

New creates a new Client with the given configuration.

func (*Client) Close

func (c *Client) Close()

func (*Client) GetSubmissionDetails

func (c *Client) GetSubmissionDetails(id int64) (*SubmissionDetails, error)

func (*Client) GetUsername

func (c *Client) GetUsername() (string, error)

GetUsername makes a request to FA to verify that the provided cookies result in being logged in by finding our username. Returns ErrNotLoggedIn if username could not be found.

func (*Client) NewSearch

func (c *Client) NewSearch(query string) *Search

NewSearch creates a new search for the given query.

func (*Client) NewUser

func (c *Client) NewUser(name string) *User

type Config

type Config struct {
	Cookies []Cookie
	Proxy   string
	// RateLimit is how often requests to furaffinity.net itself are allowed.
	// Requests to e.g. facdn.net to download images are not affected.
	RateLimit time.Duration
	// RequestTimeout is the timeout for a single attempt at the request.
	RequestTimeout time.Duration
	RetryDelay     time.Duration
	RetryLimit     int
	// Timeout is the timeout on the entire request, including retries.
	Timeout   time.Duration
	UserAgent string
}

Config is the configuration for the client.

type Cookie struct {
	Name  string
	Value string
}

type Journal

type Journal struct {
	ID    int64
	Title string
	User  string
	// contains filtered or unexported fields
}

Journal is a journal entry.

func (*Journal) Content

func (j *Journal) Content() (string, error)

func (*Journal) String

func (j *Journal) String() string

func (*Journal) URL

func (j *Journal) URL() string

type Rating

type Rating string

Rating is the decency rating of a submission.

const (
	RatingGeneral Rating = "general"
	RatingMature  Rating = "mature"
	RatingAdult   Rating = "adult"
)

Rating values

type Search struct {
	// contains filtered or unexported fields
}

func (*Search) GetPage

func (s *Search) GetPage(page int) ([]*Submission, error)

GetPage returns the search results on the given page. The page numbering starts at 1.

type Submission

type Submission struct {
	ID         int64
	PreviewURL string
	Rating     Rating
	Title      string
	User       string
	// contains filtered or unexported fields
}

Submission is an artwork submission.

func (*Submission) Details

func (s *Submission) Details() (*SubmissionDetails, error)

func (*Submission) PreviewImage

func (s *Submission) PreviewImage() ([]byte, error)

func (*Submission) String

func (s *Submission) String() string

type SubmissionDetails

type SubmissionDetails struct {
	DownloadURL string
	Description string
	Stats       string
	// contains filtered or unexported fields
}

SubmissionDetails are the details of a specific submission. TODO add more stuff here

func (*SubmissionDetails) Download

func (sd *SubmissionDetails) Download() ([]byte, error)

type SubmissionType

type SubmissionType int
const (
	SubmissionTypeGallery SubmissionType = iota
	SubmissionTypeScraps
)

func (SubmissionType) URI

func (st SubmissionType) URI() string

type User

type User struct {
	// contains filtered or unexported fields
}

func (*User) GetGallery

func (u *User) GetGallery(st SubmissionType, page uint) ([]*Submission, error)

GetGallery retrieves the specified page of the user's gallery of the specified type. Page numbering starts at 1. NOTE: Rating information is currently not provided on the submissions.

func (*User) GetJournals

func (u *User) GetJournals(page uint) ([]*Journal, error)

GetJournals retrieves the specified page of the user's journal. Page numbering starts at 1.

func (*User) GetRecent

func (u *User) GetRecent() ([]*Submission, []*Journal, error)

GetRecent retrieves the user's most recent submissions and journal. It obtains the data from the user's profile page, so the number of results is limited.

func (*User) GetSubmissions

func (u *User) GetSubmissions(page uint) ([]*Submission, error)

GetSubmissions retrieves the specified page of the user's gallery. Page numbering starts at 1. NOTE: Rating information is currently not provided on the submissions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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