youtube

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UploadStatusUploaded  = "uploaded"
	UploadStatusProcessed = "processed"
	UploadStatusFailed    = "failed"
	UploadStatusRejected  = "rejected"
	UploadStatusDeleted   = "deleted"
)

Upload Status constants.

Variables

View Source
var ErrUnknownStatus = errors.New("unknown video status")

Functions

func CheckUploadStatus added in v0.0.9

func CheckUploadStatus(ctx context.Context, videoID string, account string) (string, error)

CheckUploadStatus checks the status for the video with the associated videoID. the returned status will be one of: - UploadStatusUploaded - UploadStatusProcessed - UploadStatusFailed - UploadStatusRejected - UploadStatusDeleted

NOTE: The passed account should match the account of the uploader. If no account is passed, the AusOcean channel will be used.

func UploadVideo

func UploadVideo(ctx context.Context, media io.Reader, account string, opts ...VideoUploadOption) (*youtube.Video, error)

UploadVideo uploads a video to the given YouTube account using the provided media reader and options. If no account is specified, the upload will default to the AusOcean channel. Defaults are applied for title, description, category, privacy, and tags if not specified in options. Defaults are as follows: - Title: "Uploaded at <current time>" - Description: "No description provided." - Category: "Science & Technology" (ID: 28) - Privacy: "unlisted" - Tags: ["ocean uploads"] It returns the created video object, and an error if the upload fails.

Types

type VideoUploadOption

type VideoUploadOption func(*youtube.Video) error

VideoUploadOption is a functional option type for configuring YouTube video uploads.

func WithCategory

func WithCategory(categoryID string) VideoUploadOption

WithCategory sets the category of the video being uploaded. It accepts either a category ID or a category name (both as strings) from the following:

1 - Film & Animation 2 - Autos & Vehicles 10 - Music 15 - Pets & Animals 17 - Sports 18 - Short Movies 19 - Travel & Events 20 - Gaming 21 - Videoblogging 22 - People & Blogs 23 - Comedy 24 - Entertainment 25 - News & Politics 26 - Howto & Style 27 - Education 28 - Science & Technology 29 - Nonprofits & Activism 30 - Movies 31 - Anime/Animation 32 - Action/Adventure 33 - Classics 34 - Comedy 35 - Documentary 36 - Drama 37 - Family 38 - Foreign 39 - Horror 40 - Sci-Fi/Fantasy 41 - Thriller 42 - Shorts 43 - Shows 44 - Trailers

If a name is provided, it will be matched against a predefined list of categories and the corresponding ID will be used. It returns an error if the category ID/name is not found.

func WithDescription

func WithDescription(description string) VideoUploadOption

WithDescription sets the description of the video being uploaded. It returns an error if the description is empty.

func WithPrivacy

func WithPrivacy(privacy string) VideoUploadOption

WithPrivacy sets the privacy status of the video being uploaded. It accepts "public", "unlisted", or "private" as valid privacy statuses. It returns an error if the privacy status is empty or invalid.

func WithTags

func WithTags(tags []string) VideoUploadOption

WithTags sets the tags for the video being uploaded. It returns an error if the tags slice is empty.

func WithTitle

func WithTitle(title string) VideoUploadOption

WithTitle sets the title of the video being uploaded. It returns an error if the title is empty.

Jump to

Keyboard shortcuts

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