youtube

package module
v0.0.0-...-c5ae198 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2017 License: BSD-3-Clause Imports: 7 Imported by: 2

README

youtube

a toy YouTube Data API library for Go

see cmd/main.go for usage examples

Documentation

Index

Constants

View Source
const (
	// URI is an API endpoint
	URI = "https://www.googleapis.com/youtube/v3/videos?id=%s&part=contentDetails&key=%s"
)

Variables

View Source
var ErrKey = errors.New("get a key here: https://console.developers.google.com/apis/api/youtube.googleapis.com")

ErrKey YouTube API key error

Functions

func GetDuration

func GetDuration(key, id string) (duration string, err error)

GetDuration returns duration from YouTube video id you should pass a valid YouTube Data API Key. Can get one here: https://console.developers.google.com/apis/api/youtube.googleapis.com"

func IDs

func IDs(msg string) (ids []string)

IDs extracts ID parts from YouTube links found in a string

func ParseDuration

func ParseDuration(dur string) string

ParseDuration converts duration in YouTube format to 15:04:05

Types

type ContentDetails

type ContentDetails struct {
	Etag  string `json:"etag"`
	Items []struct {
		ContentDetails struct {
			Caption         string `json:"caption"`
			Definition      string `json:"definition"`
			Dimension       string `json:"dimension"`
			Duration        string `json:"duration"`
			LicensedContent bool   `json:"licensedContent"`
			Projection      string `json:"projection"`
		} `json:"contentDetails"`
		Etag string `json:"etag"`
		ID   string `json:"id"`
		Kind string `json:"kind"`
	} `json:"items"`
	Kind     string `json:"kind"`
	PageInfo struct {
		ResultsPerPage int64 `json:"resultsPerPage"`
		TotalResults   int64 `json:"totalResults"`
	} `json:"pageInfo"`
}

ContentDetails is a response struct for YouTube API call

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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