cyberdrop

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package cyberdrop contains functions that can be used to accurately extract and validate Cyberdrop links.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delegate

func Delegate(res, source string) ([]models.Entry, error)

Delegate takes a string as an argument and returns a slice of valid Cyberdrop links found within the response (if any) or nil, and an error

func Extract

func Extract(res string) ([]string, error)

Extract returns a slice of all Cyberdrop links contained within a string, if any.

func ExtractDescription

func ExtractDescription(doodContents string, excludeDefault bool) string

ExtractDescription takes the body response/contents of a Cyberdrop page (raw source/html (formatted as string)) and the excludeDefault flag (bool). The exclude default flag will return an empty string in the case that the album creator did not specify a description, rather than Cyberdrop's ~150 character default description. This should be set to true in most cases. If the album creator did specify a description, it will be returned as a string.

func ExtractFileCount

func ExtractFileCount(doodContents string) int

ExtractFileCount takes the body response/contents of a Cyberdrop page (raw source/html (formatted as string)) as an argument and returns the album's file count as an integer. It will return -1 in the case of a syntax error.

func ExtractSize

func ExtractSize(doodContents string) string

ExtractSize takes the body response/contents of a Cyberdrop page (raw source/html (formatted as string)) as an argument and returns the album's total/cumulative file size as a string.

func ExtractThumbnail

func ExtractThumbnail(doodContents string) string

ExtractThumbnail takes the body response/contents of a Cyberdrop page (raw source/html (formatted as string)) as an argument. Cyberdrop albums do not have a dedicated thumbnail, so ExtractThumbnail() instead extracts the first image URL it finds, as this can grant more insight if other metadata is misleading/inconclusive. The extracted URL is unescaped to ensure validity and returned in string format.

func ExtractTitle

func ExtractTitle(doodContents string) string

ExtractTitle takes the body response/contents of a Cyberdrop page (raw source/html (formatted as string)) as an argument and returns the album's title as a string.

func ExtractUploadDate

func ExtractUploadDate(doodContents string, dateFormat string) (string, error)

ExtractUploadDate takes the body response/contents of a Cyberdrop page (raw source/html (formatted as string)) as and a dateFormat string as it's arguments. The dateFormat string will be used to format a time.Time into a more favorable format. The default dateFormat used by tempest is "Jan 02, 2006". It will return a date in string format, which has been formatted in accordance with the specified dateFormat, and an error which will be nil if successful.

func Validate

func Validate(x string) (bool, error)

Validate performs a GET request to the Cyberdrop URL and uses the response status code to identify its validity

Types

This section is empty.

Jump to

Keyboard shortcuts

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