youtubelength: 4d63.com/youtubelength Index | Examples | Files

package youtubelength

import "4d63.com/youtubelength"

Package youtubelength get the length of Youtube videos.

Index

Examples

Package Files

client.go doc.go youtubelength.go

Variables

var DefaultClient = Client{}

DefaultClient is a default youtubelength.Client.

func Get Uses

func Get(c context.Context, videoID string) (time.Duration, error)

Get gets the length of the video using the DefaultClient.

Code:

// https://www.youtube.com/watch?v=G_OlRWGLdnw
length, err := youtubelength.Get(context.Background(), "G_OlRWGLdnw")
if err != nil {
    fmt.Println(err)
}
fmt.Println(length)

Output:

6m51s

type Client Uses

type Client struct {
    // HTTPClient is an optional http.Client that will be used to get the
    // length of the Youtube video. If it is not set a zero http.Client with a
    // timeout of 10s will be used.
    HTTPClient *http.Client
}

Client is the client that can get the length of a Youtube video.

func (*Client) Get Uses

func (cl *Client) Get(c context.Context, videoID string) (time.Duration, error)

Get gets the length of the video.

Package youtubelength imports 7 packages (graph). Updated 2018-01-05. Refresh now. Tools for package owners.