api

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombineStringsWithNewline

func CombineStringsWithNewline(strs ...string) string

Same as strings.Join([]string, "\n")

func ConvertPageNumToOffset

func ConvertPageNumToOffset(minPageNum, maxPageNum, perPage int) (int, int)

Convert the page number to the offset as one page might have x posts.

Usually for paginated results like Pixiv's mobile API (60 per page), checkPixivMax should be set to true.

func DetectGDriveLinks(text, postFolderPath string, isUrl, logUrls bool) bool

Detects if the given string contains any GDrive links and logs it if detected

func DetectOtherExtDLLink(text, postFolderPath string) bool

Detects if the given string contains any other external file hosting providers links and logs it if detected

func DetectPasswordInText

func DetectPasswordInText(text string) bool

Detects if the given string contains any passwords

func ExecuteChromedpActions

func ExecuteChromedpActions(allocCtx context.Context, allocCancelFn context.CancelFunc, actions ...chromedp.Action) error

func GetCookie

func GetCookie(sessionID, website string) *http.Cookie

Returns a cookie with given value and website to be used in requests

func GetDefaultChromedpAlloc

func GetDefaultChromedpAlloc(userAgent string, ctx context.Context) (context.Context, context.CancelFunc)

func GetMinMaxFromStr

func GetMinMaxFromStr(numStr string) (int, int, bool, error)

Returns the min, max, hasMaxNum, and error from the given string of "num" or "min-max"

E.g.

"1-10" => 1, 10, true, nil
"1" => 1, 1, true, nil
"" => 1, 1, false, nil (defaults to min = 1, max = inf)

func GetReadableSiteStr

func GetReadableSiteStr(site string) string

Returns a readable format of the website name for the user

Will panic if the site string doesn't match one of its cases.

func HandleCaptchaErr

func HandleCaptchaErr(err error, dlOptions DlOptions, website string) error

try the alternative method if the first one fails.

E.g. User preferred to solve the reCAPTCHA automatically, but the program failed to do so,

The program will then ask the user to solve the reCAPTCHA manually on their browser with the SAME session.

func RemoveDuplicateIdAndPageNum

func RemoveDuplicateIdAndPageNum[T SliceTypes](idSlice, pageSlice []T) ([]T, []T)

Used for removing duplicate IDs with its corresponding page number from the given slices.

Returns the the new idSlice and pageSlice with the duplicates removed.

func RemoveSliceDuplicates

func RemoveSliceDuplicates[T SliceTypes](s []T) []T

Removes duplicates from the given slice.

func SetChromedpAllocCookies

func SetChromedpAllocCookies(cookies []*http.Cookie) chromedp.Action

func SliceContains

func SliceContains(arr []string, str string) bool

Checks if the given str is in the given arr and returns a boolean

func SliceMatchesRegex

func SliceMatchesRegex(regex *regexp.Regexp, slice []string) (bool, string)

Checks if the slice of string all matches the given regex pattern

Returns true if all matches, false otherwise with the outlier string

func SolveCaptcha

func SolveCaptcha(dlOptions DlOptions, website string) error

func ValidateIds

func ValidateIds(args []string) error

Validates if the slice of strings contains only numbers Otherwise, os.Exit(1) is called after printing error messages for the user to read

func ValidatePageNumInput

func ValidatePageNumInput(baseSliceLen int, pageNums []string, errMsgs []string) error

check page nums if they are in the correct format.

E.g. "1-10" is valid, but "0-9" is not valid because "0" is not accepted If the page nums are not in the correct format, os.Exit(1) is called

func ValidatePageNumInputPanic

func ValidatePageNumInputPanic(baseSliceLen int, pageNums []string, errMsgs []string)

Similar to ValidatePageNumInput, but will call os.Exit(1) if the page nums are not in the correct format

func ValidateStrArgs

func ValidateStrArgs(str string, slice, errMsgs []string) (string, error)

Checks if the slice of string contains the target str. Otherwise, returns an error.

func VerifyAndGetCookie

func VerifyAndGetCookie(website, cookieValue, userAgent string) (*http.Cookie, error)

Verifies the given cookie by making a request to the website and checks if the cookie is valid If the cookie is valid, the cookie will be returned

However, if the cookie is invalid, an error message will be printed out and the program will shutdown

func VerifyCookie

func VerifyCookie(cookie *http.Cookie, website, userAgent string) (bool, error)

Verifies the given cookie by making a request to the website and returns true if the cookie is valid

Types

type DlOptions

type DlOptions interface {
	GetConfigs() *configs.Config
	GetSessionCookies() []*http.Cookie
	GetAutoSolveCaptcha() bool
	GetNotifier() notify.Notifier
	GetCaptchaHandler() constants.CAPTCHA_FN
	GetContext() context.Context

	// Prog bars
	GetCaptchaSolverProgBar() progress.Progress

	SetAutoSolveCaptcha(bool)
}

type SliceTypes

type SliceTypes interface {
	~string | ~int
}

Directories

Path Synopsis
web

Jump to

Keyboard shortcuts

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