utils

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFileDocument

func GetFileDocument(filePath string) (*goquery.Document, error)

GetFileDocument opens an HTML file and returns a GoQuery document from that file.

func HTTPGet

func HTTPGet(url string) (*goquery.Document, error)

HTTPGet fetches an HTTP url and returns a goquery.Document. It will also set the appropriate headers to make sure the pages are returned in English.

func HTTPGetJSON

func HTTPGetJSON(url string, resp interface{}) error

HTTPGetJSON fetches an HTTP url and deserializes the JSON response into resp. It will also set the appropriate headers to make sure the pages are returned in English.

func HTTPPost

func HTTPPost(url string, req interface{}, resp interface{}) error

HTTPPost executes an HTTP post request on the given url by serializing the given object into JSON.

func NormalizeMediaTitle

func NormalizeMediaTitle(title string) string

NormalizeMediaTitle removes any parts of the title that are in brackets or parentheses.

func NormalizeQuery

func NormalizeQuery(query string) string

NormalizeQuery will appropriate replace special characters in a title as to normalize it for better comparisons.

Types

type GoirateLogger added in v0.13.1

type GoirateLogger struct {
}

GoirateLogger acts as a logger for filtering certain types of problematic output. Main case is forms of "Unsolicited response received on idle HTTP channel", which Go for some reason thinks is a good idea to dump straight into stdout...

func (*GoirateLogger) Write added in v0.13.1

func (logger *GoirateLogger) Write(data []byte) (n int, err error)

type HTTPClient

type HTTPClient struct {
	// Timeout is the time limit for requests.
	Timeout   time.Duration
	AuthToken string
}

HTTPClient holds parameters for performing HTTP requests in the library.

func (*HTTPClient) Get

func (c *HTTPClient) Get(urlString string) (*goquery.Document, error)

Get fetches an HTTP url and returns a goquery.Document. It will also set the appropriate headers to make sure the pages are returned in English.

func (*HTTPClient) GetJSON

func (c *HTTPClient) GetJSON(url string, resp interface{}) error

GetJSON executes an HTTP get request on the given url by serializing the given object into JSON.

func (*HTTPClient) Post

func (c *HTTPClient) Post(url string, req interface{}, resp interface{}) error

Post executes an HTTP post request on the given url by serializing the given object into JSON.

type OptionalBoolean

type OptionalBoolean string

OptionalBoolean defines a boolean constant that can also be undefined.

const (
	// Default represents an undefined value.
	Default OptionalBoolean = ""
	// True represents a positive value.
	True OptionalBoolean = "true"
	// False represents a negative value.
	False OptionalBoolean = "false"
)

func (OptionalBoolean) OverridenBy

func (opt OptionalBoolean) OverridenBy(other OptionalBoolean) bool

OverridenBy returns true if one of this or the other action is true, or if the other action is true.

type WatchlistActions

type WatchlistActions struct {
	SendEmail OptionalBoolean `toml:"email" json:"email"`
	Emails    []string        `toml:"notify" json:"notify"`
	Download  OptionalBoolean `toml:"download" json:"download"`
}

WatchlistActions defines actions to be taken upon discovering a new torrent, along with any parameters regarding said action.

Jump to

Keyboard shortcuts

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