bunny

package
v0.0.0-...-53ad115 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VideoStatusCreated = iota
	VideoStatusUploaded
	VideoStatusProcessing
	VideoStatusTranscoding
	// Video is ready
	VideoStatusFinished
	VideoStatusError
	VideoStatusUploadFailed
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Message string
}

func (APIError) Error

func (res APIError) Error() string

type AddCustomHostnameInput

type AddCustomHostnameInput struct {
	Hostname string `json:"Hostname"`
}

type Client

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

func NewClient

func NewClient(acountApiKey, streamApiKey string, httpClient *http.Client) *Client

func (*Client) AddCustomHostname

func (client *Client) AddCustomHostname(ctx context.Context, pullZone, hostname string) (err error)

func (*Client) CreateVideo

func (client *Client) CreateVideo(ctx context.Context, input CreateVideoInput) (output Video, err error)

https://docs.bunny.net/reference/video_createvideo

func (*Client) DeleteVideo

func (client *Client) DeleteVideo(ctx context.Context, libraryID, videoID string) (err error)

https://docs.bunny.net/reference/video_deletevideo

func (*Client) FetchVideo

func (client *Client) FetchVideo(ctx context.Context, libraryID, videoUrl string) (output FetchVideoOutput, err error)

https://docs.bunny.net/reference/video_fetchnewvideo

func (*Client) GenerateIframeVideoUrl

func (client *Client) GenerateIframeVideoUrl(libraryID string, videoID string, options *GenerateIframeVideoUrlOptions) (videoUrl string)

GenerateIframeVideoUrl generates the URL of the given video to be embeded with an iframe See https://docs.bunny.net/docs/stream-embedding-videos for more information See https://docs.bunny.net/docs/stream-embed-token-authentication for documentation about authentication

func (*Client) GetVideo

func (client *Client) GetVideo(ctx context.Context, libraryID, videoID string) (video Video, err error)

https://docs.bunny.net/reference/video_getvideo

func (*Client) LoadFreeCertificate

func (client *Client) LoadFreeCertificate(ctx context.Context, hostname string) (err error)

func (*Client) ReencodeVideo

func (client *Client) ReencodeVideo(ctx context.Context, libraryID, videoID string) (video Video, err error)

https://docs.bunny.net/reference/video_reencodevideo

func (*Client) RemoveCustomHostname

func (client *Client) RemoveCustomHostname(ctx context.Context, pullZone, hostname string) (err error)

func (*Client) SignVideoUrl

func (client *Client) SignVideoUrl(videoId string, expiresAt time.Time) (token, expiresAtStr string)

See https://docs.bunny.net/docs/stream-embed-token-authentication

type CreateVideoInput

type CreateVideoInput struct {
	LibraryID     string  `json:"-"`
	Title         string  `json:"title"`
	CollectionID  *string `json:"collectionId,omitempty"`
	ThumbnailTime *int64  `json:"thumbnailTime,omitempty"`
}

type DownloadFileInput

type DownloadFileInput struct {
	// Leave empty for Falkenstein, DE
	Region          string
	StorageZoneName string
	Filename        string
}

type FetchVideoInput

type FetchVideoInput struct {
	Url string `json:"url"`
}

type FetchVideoOutput

type FetchVideoOutput struct {
	Success    bool   `json:"success"`
	Message    string `json:"message"`
	StatusCode int64  `json:"statusCode"`

	ID string `json:"id"`
}

type GenerateIframeVideoUrlOptions

type GenerateIframeVideoUrlOptions struct {
	Signed bool
	// If Signed is true and Expires is nil we use a default value of 24 hours
	Expires  *time.Time
	Autoplay *bool
	// We recommend to set to false
	TrackView *bool
	// We recommend to set to true
	Preload        *bool
	Captions       *string
	VideoStartTime *uint64
	Refresh        *bool
}

See here for the avilable options: https://docs.bunny.net/docs/stream-embedding-videos#parameters

type RemoveCustomHostnameInput

type RemoveCustomHostnameInput struct {
	Hostname string `json:"Hostname"`
}

type UpdateVideoInput

type UpdateVideoInput struct {
	LibraryID    string         `json:"-"`
	VideoID      string         `json:"-"`
	Title        *string        `json:"title,omitempty"`
	CollectionID *string        `json:"collectionId,omitempty"`
	Chapters     []VideoChapter `json:"chapters,omitempty"`
	Moments      []VideoMoment  `json:"moments,omitempty"`
	MetaTags     []VideoMetaTag `json:"metaTags,omitempty"`
}

type UploadFileInput

type UploadFileInput struct {
	// Leave empty for Falkenstein, DE
	Region          string
	StorageZoneName string
	Filename        string
	Data            io.Reader
}

type UploadVideoInput

type UploadVideoInput struct {
	LibraryID string
	VideoID   string
	Data      io.Reader
}

type UploadVideoOutput

type UploadVideoOutput struct {
	Success    bool   `json:"success"`
	Message    string `json:"message"`
	StatusCode int64  `json:"statusCode"`
}

type Video

type Video struct {
	VideoLibraryID int64  `json:"videoLibraryId"`
	Guid           string `json:"guid"`
	Title          string `json:"title"`
	// "dateUploaded": "2023-08-17T12:45:11.381",
	Views    int64 `json:"views"`
	IsPublic bool  `json:"isPublic"`
	// Length is the duration of the video in seconds
	Length    int64       `json:"length"`
	Status    VideoStatus `json:"status"`
	Framerate float64     `json:"framerate"`
	// "rotation": 0,
	Width  int64 `json:"width"`
	Height int64 `json:"height"`
	// The available resolutions of the video. "360p,720p,1080p" for example
	AvailableResolutions string `json:"availableResolutions"`
	ThumbnailCount       int64  `json:"thumbnailCount"`
	// The current encode progress of the video
	EncodeProgress int64 `json:"encodeProgress"`
	// The amount of storage used by this video
	StorageSize int64 `json:"storageSize"`
	// "captions": [],
	HasMP4Fallback bool `json:"hasMP4Fallback"`
	// The ID of the collection where the video belongs. Can be empty.
	CollectionID string `json:"collectionId"`
	// The file name of the thumbnail inside of the storage
	ThumbnailFileName string `json:"thumbnailFileName"`
	// The average watch time of the video in seconds
	AverageWatchTime int64 `json:"averageWatchTime"`
	// The total video watch time in seconds
	TotalWatchTime int64 `json:"totalWatchTime"`
	// The automatically detected category of the video. Default: "unknown"
	Category string         `json:"category"`
	Chapters []VideoChapter `json:"chapters"`
	Moments  []VideoMoment  `json:"moments"`
	MetaTags []VideoMetaTag `json:"metaTags"`
}

See https://docs.bunny.net/reference/video_getvideo for details

type VideoChapter

type VideoChapter struct {
	Title string `json:"title"`
	Start int64  `json:"start"`
	End   int64  `json:"end"`
}

type VideoMetaTag

type VideoMetaTag struct {
	Property string `json:"property"`
	Value    string `json:"value"`
}

type VideoMoment

type VideoMoment struct {
	Label     string `json:"label"`
	Timestamp int64  `json:"timestamp"`
}

type VideoStatus

type VideoStatus int64

Jump to

Keyboard shortcuts

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