README

4d63.com/youtubelength

Build Status Codecov Go Report Card Go docs

Go package that gets the length of Youtube videos.

Usage

import "4d63.com/youtubelength"
length, err := youtubelength.Get(context.Background(), "G_OlRWGLdnw")

Usage (App Engine)

import (
	"net/http"

	"google.golang.org/appengine"
	"google.golang.org/appengine/urlfetch"

	"4d63.com/youtubelength"
)

func handler(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	httpClient := urlfetch.Client(c)
	ytlClient := youtubelength.Client{HTTPClient:httpClient}
	length, err := ytlClient.Get(c, "G_OlRWGLdnw")
	...
}

Documentation

Overview

    Package youtubelength get the length of Youtube videos.

    Index

    Examples

    Constants

    This section is empty.

    Variables

    View Source
    var DefaultClient = Client{}

      DefaultClient is a default youtubelength.Client.

      Functions

      func Get

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

        Get gets the length of the video using the DefaultClient.

        Example
        Output:
        
        6m51s
        

        Types

        type Client

        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

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

            Get gets the length of the video.