kemono

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: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BASE_REGEX_STR             = `` /* 142-byte string literal not displayed */
	BASE_POST_SUFFIX_REGEX_STR = `/post/(?P<postId>\d+)`
	TLD_GROUP_NAME             = "topLevelDomain"
	SERVICE_GROUP_NAME         = "service"
	CREATOR_ID_GROUP_NAME      = "creatorId"
	POST_ID_GROUP_NAME         = "postId"
	API_MAX_CONCURRENT         = 3
)

Variables

View Source
var (
	POST_URL_REGEX = regexp.MustCompile(
		fmt.Sprintf(
			`^%s%s$`,
			BASE_REGEX_STR,
			BASE_POST_SUFFIX_REGEX_STR,
		),
	)
	POST_URL_REGEX_TLD_INDEX        = POST_URL_REGEX.SubexpIndex(TLD_GROUP_NAME)
	POST_URL_REGEX_SERVICE_INDEX    = POST_URL_REGEX.SubexpIndex(SERVICE_GROUP_NAME)
	POST_URL_REGEX_CREATOR_ID_INDEX = POST_URL_REGEX.SubexpIndex(CREATOR_ID_GROUP_NAME)
	POST_URL_REGEX_POST_ID_INDEX    = POST_URL_REGEX.SubexpIndex(POST_ID_GROUP_NAME)

	CREATOR_URL_REGEX = regexp.MustCompile(
		fmt.Sprintf(
			`^%s$`,
			BASE_REGEX_STR,
		),
	)
	CREATOR_URL_REGEX_TLD_INDEX        = CREATOR_URL_REGEX.SubexpIndex(TLD_GROUP_NAME)
	CREATOR_URL_REGEX_SERVICE_INDEX    = CREATOR_URL_REGEX.SubexpIndex(SERVICE_GROUP_NAME)
	CREATOR_URL_REGEX_CREATOR_ID_INDEX = CREATOR_URL_REGEX.SubexpIndex(CREATOR_ID_GROUP_NAME)
)

Functions

func GetFavourites

func GetFavourites(downloadPath string, dlOptions *KemonoDlOptions) ([]*httpfuncs.ToDownload, []*httpfuncs.ToDownload, error)

func GetMultipleCreators

func GetMultipleCreators(creators []*KemonoCreatorToDl, downloadPath string, dlOptions *KemonoDlOptions) ([]*httpfuncs.ToDownload, []*httpfuncs.ToDownload)

func GetMultiplePosts

func GetMultiplePosts(posts []*KemonoPostToDl, downloadPath string, dlOptions *KemonoDlOptions) ([]*httpfuncs.ToDownload, []*httpfuncs.ToDownload)

Types

type KemonoCreatorToDl

type KemonoCreatorToDl struct {
	Service   string
	CreatorId string
	PageNum   string
	Tld       string
}

func ProcessCreatorUrls

func ProcessCreatorUrls(creatorUrls []string, pageNums []string) []*KemonoCreatorToDl

type KemonoDl

type KemonoDl struct {
	CreatorUrls     []string
	CreatorPageNums []string
	CreatorsToDl    []*KemonoCreatorToDl

	PostUrls  []string
	PostsToDl []*KemonoPostToDl

	DlFav bool
}

func (*KemonoDl) RemoveDuplicates

func (k *KemonoDl) RemoveDuplicates()

RemoveDuplicates removes duplicate creators and posts from the slice

func (*KemonoDl) ValidateArgs

func (k *KemonoDl) ValidateArgs() error

type KemonoDlOptions

type KemonoDlOptions struct {
	DlAttachments bool
	DlGdrive      bool

	Configs *configs.Config

	// GdriveClient is the Google Drive client to be
	// used in the download process for Pixiv Fanbox posts
	GdriveClient *gdrive.GDrive

	SessionCookieId string
	SessionCookies  []*http.Cookie

	Notifier notify.Notifier

	// Prog bars
	PostProgBar              progress.Progress
	GetCreatorPostProgBar    progress.Progress
	ProcessJsonProgBar       progress.Progress
	GetFavouritesPostProgBar progress.Progress
	GdriveApiProgBar         progress.Progress
	GdriveDlProgBar          progress.Progress
	// contains filtered or unexported fields
}

KemonoDlOptions is the struct that contains the arguments for Kemono download options.

func (*KemonoDlOptions) Cancel

func (k *KemonoDlOptions) Cancel()

Cancel cancels the context of the KemonoDlOptions struct.

func (*KemonoDlOptions) GetCancel

func (k *KemonoDlOptions) GetCancel() context.CancelFunc

func (*KemonoDlOptions) GetContext

func (k *KemonoDlOptions) GetContext() context.Context

func (*KemonoDlOptions) SetContext

func (k *KemonoDlOptions) SetContext(ctx context.Context)

func (*KemonoDlOptions) ValidateArgs

func (k *KemonoDlOptions) ValidateArgs(userAgent string) error

ValidateArgs validates the session cookie ID of the Kemono account to download from. It also validates the Google Drive client if the user wants to download to Google Drive.

Should be called after initialising the struct.

type KemonoFavCreatorJson

type KemonoFavCreatorJson []struct {
	FavedSeq int    `json:"faved_seq"`
	Id       string `json:"id"`
	Indexed  string `json:"indexed"`
	Name     string `json:"name"`
	Service  string `json:"service"`
	Updated  string `json:"updated"`
}

type KemonoJson

type KemonoJson []*MainKemonoJson

type KemonoPostToDl

type KemonoPostToDl struct {
	Service   string
	CreatorId string
	PostId    string
	Tld       string
}

func ProcessPostUrls

func ProcessPostUrls(postUrls []string) []*KemonoPostToDl

type MainKemonoJson

type MainKemonoJson struct {
	Added       string `json:"added"`
	Attachments []struct {
		Name string `json:"name"`
		Path string `json:"path"`
	} `json:"attachments"`
	Content string `json:"content"`
	Edited  string `json:"edited"`
	Embed   struct {
		Description string `json:"description"`
		Subject     string `json:"subject"`
		Url         string `json:"url"`
	} `json:"embed"`
	File struct {
		// usually is for the post thumbnail
		Name string `json:"name"`
		Path string `json:"path"`
	} `json:"file"`
	Id         string `json:"id"`
	Published  string `json:"published"`
	Service    string `json:"service"`
	SharedFile bool   `json:"shared_file"`
	Title      string `json:"title"`
	User       string `json:"user"` // creator id
}

Jump to

Keyboard shortcuts

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