ytservice

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2019 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package ytservice encapsulates all the YouTube API services

Copyright David Thorpe 2015-2016 All Rights Reserved
Please see file LICENSE for information on distribution, etc

Copyright David Thorpe 2015-2016 All Rights Reserved
Please see file LICENSE for information on distribution, etc

Copyright David Thorpe 2015-2016 All Rights Reserved
Please see file LICENSE for information on distribution, etc

Copyright David Thorpe 2015-2016 All Rights Reserved
Please see file LICENSE for information on distribution, etc

Copyright David Thorpe 2015-2016 All Rights Reserved
Please see file LICENSE for information on distribution, etc

Index

Constants

View Source
const (
	FLAG_REQUIRED = 0x0000
	FLAG_OPTIONAL = 0x0001
	FLAG_STRING   = 0x0010
	FLAG_UINT     = 0x0020
	FLAG_ENUM     = 0x0030
	FLAG_VIDEO    = 0x0040
	FLAG_CHANNEL  = 0x0050
	FLAG_PLAYLIST = 0x0060
	FLAG_LANGUAGE = 0x0070
)
View Source
const (
	FIELD_STRING = iota
	FIELD_DATETIME
	FIELD_NUMBER
	FIELD_BOOLEAN
)

Variables

View Source
var (
	ErrorMissingContentOwner   = errors.New("Missing content owner parameter")
	ErrorInvalidServiceAccount = errors.New("Invalid service account")
	ErrorInvalidClientSecrets  = errors.New("Invalid client secrets configuration")
	ErrorInvalidDefaults       = errors.New("Invalid defaults file")
	ErrorCacheTokenRead        = errors.New("Invalid Cache Token")
	ErrorCacheTokenWrite       = errors.New("Unable to create cache token")
	ErrorTokenExchange         = errors.New("Token Exchange Error")
	ErrorDenied                = errors.New("Denied")
	ErrorResponse              = errors.New("Bad Response")
	ErrorBadParameter          = errors.New("Invalid Parameter")
)

Enumeration of Errors

Functions

This section is empty.

Types

type CellValue

type CellValue struct {
	StringValue string
}

Value object

type Error

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

Error type

func NewError

func NewError(base error, detail error) *Error

NewError creates a new error object

func (*Error) Error

func (this *Error) Error() string

Error returns an error as a string

type FieldSpec

type FieldSpec struct {
	Key  string
	Path string
	Type int
}

Field specification

type Flag

type Flag struct {
	Name  string
	Type  uint32
	Extra string
}

Flag represents a parameter name and type

type Params

type Params struct {
	ContentOwner    *string `json:"contentowner,omitempty"`
	Channel         *string `json:"channel,omitempty"`
	Video           *string `json:"-"`
	Stream          *string `json:"-"`
	MaxResults      int64   `json:"-"`
	Query           *string `json:"-"`
	BroadcastStatus *string `json:"-"`
	Language        *string `json:"-"`
	Title           *string `json:"-"`
	Description     *string `json:"-"`

	SetupHook map[string]func(*Params, *Table) error           // command -> SetupFunc
	ExecHook  map[string]func(*Service, *Params, *Table) error // command -> ExecFunc
	FlagSpec  map[string]map[string]Flag                       // command:flag -> Flag
	// contains filtered or unexported fields
}

Params object stores all the parameters used for making API requests

func NewParams

func NewParams() *Params

NewParams returns a new Params object

func NewParamsFromJSON

func NewParamsFromJSON(filename string) (*Params, error)

NewParamsFromJSON returns a params object from a JSON file

func (*Params) CheckFlags

func (this *Params) CheckFlags(command string) error

CheckFlags checks all parameters

func (*Params) Commands

func (this *Params) Commands() []string

Commands returns the list of command names

func (*Params) Copy

func (this *Params) Copy() *Params

Copy nakes a copy of the object

func (*Params) Flags

func (this *Params) Flags(command string) map[string]Flag

func (*Params) IsEmptyBroadcastStatus

func (this *Params) IsEmptyBroadcastStatus() bool

Return boolean value which indicates an empty video parameter

func (*Params) IsEmptyChannel

func (this *Params) IsEmptyChannel() bool

Return boolean value which indicates an empty channel

func (*Params) IsEmptyContentOwner

func (this *Params) IsEmptyContentOwner() bool

Return boolean value which indicates if a content owner parameter is missing

func (*Params) IsEmptyDescription

func (this *Params) IsEmptyDescription() bool

Return boolean value which indicates an empty title parameter

func (*Params) IsEmptyLanguage

func (this *Params) IsEmptyLanguage() bool

Return boolean value which indicates an empty language parameter

func (*Params) IsEmptyQuery

func (this *Params) IsEmptyQuery() bool

Return boolean value which indicates an empty query

func (*Params) IsEmptyStream

func (this *Params) IsEmptyStream() bool

Return boolean value which indicates an empty stream parameter

func (*Params) IsEmptyTitle

func (this *Params) IsEmptyTitle() bool

Return boolean value which indicates an empty title parameter

func (*Params) IsEmptyVideo

func (this *Params) IsEmptyVideo() bool

Return boolean value which indicates an empty video parameter

func (*Params) IsValidBroadcastStatus

func (this *Params) IsValidBroadcastStatus() bool

Return boolean value which indicates a valid video parameter

func (*Params) IsValidChannel

func (this *Params) IsValidChannel() bool

Return boolean value whichindicates a valid content owner setting

func (*Params) IsValidContentOwner

func (this *Params) IsValidContentOwner() bool

Return boolean value which indicates a valid content owner setting

func (*Params) IsValidLanguage

func (this *Params) IsValidLanguage() bool

Return boolean value which indicates a valid language parameter

func (*Params) IsValidStream

func (this *Params) IsValidStream() bool

Return boolean value which indicates a valid stream parameter

func (*Params) IsValidVideo

func (this *Params) IsValidVideo() bool

Return boolean value which indicates a valid video parameter

func (*Params) Register

func (this *Params) Register(command string, setup func(*Params, *Table) error, exec func(*Service, *Params, *Table) error, flags []Flag) error

Register flags and setup/do hooks

func (*Params) Save

func (this *Params) Save(filename string, perm os.FileMode) error

Save params object

type Row

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

Row object

func (*Row) SetCell

func (this *Row) SetCell(key string, value CellValue)

func (*Row) SetString

func (this *Row) SetString(key string, value string)

type Service

type Service struct {
	// Data API
	API *youtube.Service
	// Partner API
	PAPI *youtubepartner.Service
	// Analytics API
	AAPI *youtubeanalytics.Service
	// Bulk Reporting API
	RAPI *youtubereporting.Service
	// Whether this is a service account
	ServiceAccount bool
	// The email address of the service account
	ServiceAccountEmail string
	// contains filtered or unexported fields
}

Service object which contains the main context for calling the YouTube API

func NewYouTubeServiceFromClientSecretsJSON

func NewYouTubeServiceFromClientSecretsJSON(clientsecrets string, tokencache string, debug bool) (*Service, error)

NewYouTubeServiceFromClientSecretsJSON returns a service object given client secrets details

func NewYouTubeServiceFromServiceAccountJSON

func NewYouTubeServiceFromServiceAccountJSON(filename string, debug bool) (*Service, error)

NewYouTubeServiceFromServiceAccountJSON returns a service object given service account details

func (*Service) CallOptions

func (this *Service) CallOptions() []googleapi.CallOption

CallOptions returns the array of call options

func (*Service) SetQuotaUser

func (this *Service) SetQuotaUser(value string)

SetQuotaUser sets the quota user parameter for all API requests

func (*Service) SetTraceToken

func (this *Service) SetTraceToken(value string)

SetTraceToken sets the tracetoken parameter for all API requests

func (*Service) SetUserIP

func (this *Service) SetUserIP(value string)

SetUserIP sets the userid parameter for all API requests

type Table

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

Table object

func NewTable

func NewTable() *Table

Returns a service object given service account details

func (*Table) ASCII

func (this *Table) ASCII(io io.Writer) error

func (*Table) AddColumn

func (this *Table) AddColumn(key string)

Add a column

func (*Table) AddColumnsForPart

func (this *Table) AddColumnsForPart(part string) error

func (*Table) Append

func (this *Table) Append(items interface{}) error

func (*Table) CSV

func (this *Table) CSV(io io.Writer) error

func (*Table) NewRow

func (this *Table) NewRow() *Row

func (*Table) NumberOfColumns

func (this *Table) NumberOfColumns() int

func (*Table) NumberOfRows

func (this *Table) NumberOfRows() int

func (*Table) Parts

func (this *Table) Parts() []string

func (*Table) RegisterPart

func (this *Table) RegisterPart(part string, fields []FieldSpec)

Register output formats

func (*Table) RemoveColumnsForPart

func (this *Table) RemoveColumnsForPart(part string) error

func (*Table) SetColumns

func (this *Table) SetColumns(columns []string)

Set the output columns

Jump to

Keyboard shortcuts

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