fantia

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DlFantiaPost

func DlFantiaPost(count, maxCount int, postId string, dlOptions *FantiaDlOptions) ([]*httpfuncs.ToDownload, error)

Types

type FantiaContent

type FantiaContent struct {
	// Any attachments such as pdfs that are on their dedicated section
	AttachmentURI string `json:"attachment_uri"`

	// For images that are uploaded to their own section
	PostContentPhotos []struct {
		ID  int `json:"id"`
		URL struct {
			Original string `json:"original"`
		} `json:"url"`
	} `json:"post_content_photos"`

	// For images that are embedded in the post content blocks.
	// Could also contain links to other external file hosting providers.
	Comment string `json:"comment"`

	// for attachments such as pdfs that are embedded in the post content
	DownloadUri string `json:"download_uri"`
	Filename    string `json:"filename"`
}

type FantiaDl

type FantiaDl struct {
	FanclubIds      []string
	FanclubPageNums []string
	PostIds         []string
}

FantiaDl is the struct that contains the IDs of the Fantia fanclubs and posts to download.

func (*FantiaDl) DlFantiaPosts

func (f *FantiaDl) DlFantiaPosts(dlOptions *FantiaDlOptions) []*httpfuncs.ToDownload

Query Fantia's API based on the slice of post IDs and get a map of urls to download from.

Note that only the downloading of the URL(s) is/are executed concurrently to reduce the chance of the signed AWS S3 URL(s) from expiring before the download is executed or completed due to a download queue to avoid resource exhaustion of the user's system.

func (*FantiaDl) GetCreatorsPosts

func (f *FantiaDl) GetCreatorsPosts(dlOptions *FantiaDlOptions)

Retrieves all the posts based on the slice of creator IDs and updates its PostIds slice

func (*FantiaDl) ValidateArgs

func (f *FantiaDl) ValidateArgs()

ValidateArgs validates the IDs of the Fantia fanclubs and posts to download.

It also validates the page numbers of the fanclubs to download.

Should be called after initialising the struct.

type FantiaDlOptions

type FantiaDlOptions struct {
	DlThumbnails     bool
	DlImages         bool
	DlAttachments    bool
	DlGdrive         bool
	AutoSolveCaptcha bool // whether to use chromedp to solve reCAPTCHA automatically

	GdriveClient *gdrive.GDrive

	Configs *configs.Config

	SessionCookieId string
	SessionCookies  []*http.Cookie

	CsrfToken string

	Notifier notify.Notifier

	// Progress indicators
	CaptchaSolverProgBar   progress.Progress
	PostProgBar            progress.Progress
	GetFanclubPostsProgBar progress.Progress
	ProcessJsonProgBar     progress.Progress
	GdriveApiProgBar       progress.Progress
	GdriveDlProgBar        progress.Progress
	// contains filtered or unexported fields
}

FantiaDlOptions is the struct that contains the options for downloading from Fantia.

func (*FantiaDlOptions) Cancel

func (f *FantiaDlOptions) Cancel()

Cancel cancels the context of the FantiaDlOptions struct.

func (*FantiaDlOptions) GetAutoSolveCaptcha

func (f *FantiaDlOptions) GetAutoSolveCaptcha() bool

func (*FantiaDlOptions) GetCancel

func (f *FantiaDlOptions) GetCancel() context.CancelFunc

func (*FantiaDlOptions) GetCaptchaHandler

func (f *FantiaDlOptions) GetCaptchaHandler() constants.CAPTCHA_FN

func (*FantiaDlOptions) GetCaptchaSolverProgBar

func (f *FantiaDlOptions) GetCaptchaSolverProgBar() progress.Progress

func (*FantiaDlOptions) GetConfigs

func (f *FantiaDlOptions) GetConfigs() *configs.Config

func (*FantiaDlOptions) GetContext

func (f *FantiaDlOptions) GetContext() context.Context

func (*FantiaDlOptions) GetCsrfToken

func (f *FantiaDlOptions) GetCsrfToken(userAgent string) error

GetCsrfToken gets the CSRF token from Fantia's index HTML which is required to communicate with their API.

func (*FantiaDlOptions) GetNotifier

func (f *FantiaDlOptions) GetNotifier() notify.Notifier

func (*FantiaDlOptions) GetSessionCookies

func (f *FantiaDlOptions) GetSessionCookies() []*http.Cookie

func (*FantiaDlOptions) SetAutoSolveCaptcha

func (f *FantiaDlOptions) SetAutoSolveCaptcha(autoSolveCaptcha bool)

func (*FantiaDlOptions) SetContext

func (f *FantiaDlOptions) SetContext(ctx context.Context)

func (*FantiaDlOptions) ValidateArgs

func (f *FantiaDlOptions) ValidateArgs(userAgent string) error

ValidateArgs validates the options for downloading from Fantia.

Should be called after initialising the struct.

type FantiaPost

type FantiaPost struct {
	Post struct {
		ID      int    `json:"id"`
		Comment string `json:"comment"` // the main post content
		Title   string `json:"title"`
		Thumb   struct {
			Original string `json:"original"`
		} `json:"thumb"`
		Fanclub struct {
			User struct {
				Name string `json:"name"`
			} `json:"user"`
		} `json:"fanclub"`
		Status       string          `json:"status"`
		PostContents []FantiaContent `json:"post_contents"`
	} `json:"post"`
	Redirect string `json:"redirect"` // if get flagged by the system, it will redirect to this recaptcha url
}

Jump to

Keyboard shortcuts

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