client

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// API is the api endpoint.
	API = "/api/v1/"

	// InstanceData is the URL to retrieve available Invidious instances.
	InstanceData = "https://api.invidious.io/instances.json?sort_by=api,health"

	// UserAgent is the user agent for the client.
	UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"
)
View Source
const Scopes = "GET:playlists*,GET:subscriptions*,GET:feed*,GET:notifications*,GET:tokens*"

Scopes lists the user token's scopes.

Variables

This section is empty.

Functions

func AddAuth

func AddAuth(instance, token string)

AddAuth adds and stores an instance and token credential.

func AddCurrentAuth

func AddCurrentAuth(token string)

AddCurrentAuth adds and stores an instance and token credential for the selected instance.

func AuthLink(instance ...string) string

AuthLink returns an authorization link.

func Cancel

func Cancel()

Cancel cancels the client's context.

func CheckInstance

func CheckInstance(host string) (string, error)

CheckInstance returns if the provided instance is valid.

func Ctx

func Ctx() context.Context

Ctx returns the client's current context.

func CurrentTokenValid

func CurrentTokenValid() bool

CurrentTokenValid tests the validity of the stored token.

func Delete

func Delete(ctx context.Context, param string, token ...string) (*http.Response, error)

Delete send a DELETE request to the host and returns a response.

func Fetch

func Fetch(ctx context.Context, param string, token ...string) (*http.Response, error)

Fetch sends a GET request to the API endpoint and returns a response.

func Get

func Get(ctx context.Context, param string, token ...string) (*http.Response, error)

Get send a GET request to the host and returns a response

func GetBestInstance

func GetBestInstance(custom string) (string, error)

GetBestInstance determines and returns the best instance.

func GetInstances

func GetInstances() ([]string, error)

GetInstances returns a list of instances.

func Host

func Host() string

Host returns the client's host.

func Init

func Init()

Init intitializes the client.

func Instance

func Instance() string

Instance returns the client's current instance.

func IsAuthInstance

func IsAuthInstance() bool

IsAuthInstance checks whether the selected instance has a stored token.

func IsTokenValid

func IsTokenValid(token string) bool

IsTokenValid tests the validity of the given token.

func Modify

func Modify(param, body string, token ...string) (*http.Response, error)

Modify sends a PATCH request to the API endpoint and returns a response.

func Patch

func Patch(ctx context.Context, param, body string, token ...string) (*http.Response, error)

Patch send a PATCH request to the host and returns a response.

func Post

func Post(ctx context.Context, param, body string, token ...string) (*http.Response, error)

Post send a POST request to the host and returns a response.

func Remove

func Remove(param string, token ...string) (*http.Response, error)

Remove sends a DELETE request to the API endpoint and returns a response.

func Send

func Send(param, body string, token ...string) (*http.Response, error)

Send sends a POST request to the API endpoint and returns a response.

func SendCancel

func SendCancel()

SendCancel cancels the client's send context.

func SendCtx

func SendCtx() context.Context

SendCtx returns the client's send context.

func SetAuthCredentials added in v0.3.3

func SetAuthCredentials(credentials []Credential)

SetAuthCredentials sets the authentication credentials.

func SetHost

func SetHost(host string) *url.URL

SetHost sets the client's host.

func Token

func Token() string

Token returns the stored token for the selected instance.

Types

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

Auth stores information about instances and the user's authentication tokens associated with it.

type Client

type Client struct {
	*http.Client
	// contains filtered or unexported fields
}

Client stores information about a client.

type Credential

type Credential struct {
	Instance string `json:"instance"`
	Token    string `json:"token"`
}

Credential stores an instance and the user's authentication token.

func GetAuthCredentials added in v0.3.3

func GetAuthCredentials() []Credential

GetAuthCredentials returns the authentication credentials.

Jump to

Keyboard shortcuts

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