reddit_uploader

package
v0.0.0-...-003e112 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseErrors

func ParseErrors(r *http.Response) error

func PostFiles

func PostFiles(url string, data map[string]string, files ...FilePart) *http.Response

func ReadAndPostMedia

func ReadAndPostMedia(mediaPath, uploadURL string, data map[string]string) *http.Response

Types

type FilePart

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

type Submission

type Submission struct {
	Subreddit string `url:"sr,omitempty"`
	Title     string `url:"title,omitempty"`

	FlairID   string `url:"flair_id,omitempty"`
	FlairText string `url:"flair_text,omitempty"`

	SendReplies *bool `url:"sendreplies,omitempty"`
	Resubmit    bool  `url:"resubmit,omitempty"`
	NSFW        bool  `url:"nsfw,omitempty"`
	Spoiler     bool  `url:"spoiler,omitempty"`
}

type SubmitMediaResponse

type SubmitMediaResponse struct {
	Message string `json:"message"`
	Error   int    `json:"error"`
	JSON    struct {
		Errors [][]string `json:"errors"`
		Data   struct {
			URL               string `json:"url"`
			UserSubmittedPage string `json:"user_submitted_page"`
			WebsocketURL      string `json:"websocket_url"`
		} `json:"data"`
	} `json:"json"`
}

type UploadMediaResponse

type UploadMediaResponse struct {
	Args struct {
		Action string `json:"action"`
		Fields []struct {
			Name  string `json:"name"`
			Value string `json:"value"`
		} `json:"fields"`
	} `json:"args"`
	Asset struct {
		WebsocketURL string `json:"websocket_url"`
	} `json:"asset"`
}

type Uploader

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

func New

func New(username, password, clientID, clientSecret, userAgent string) (*Uploader, error)

func (*Uploader) GetAccessToken

func (u *Uploader) GetAccessToken() (string, error)

func (*Uploader) Post

func (u *Uploader) Post(url string, data io.Reader, auth ...bool) *http.Response

func (*Uploader) SubmitImage

func (u *Uploader) SubmitImage(params Submission, imagePath string) error

func (*Uploader) SubmitMedia

func (u *Uploader) SubmitMedia(post interface{}) error

func (*Uploader) SubmitVideo

func (u *Uploader) SubmitVideo(params Submission, videoPath, previewPath string) error

func (*Uploader) UploadMedia

func (u *Uploader) UploadMedia(mediaPath string) (string, string)

Jump to

Keyboard shortcuts

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