Documentation
¶
Overview ¶
Copyright David Thorpe 2015-2016 All Rights Reserved Please see file LICENSE for information on distribution, etc
Index ¶
- Constants
- Variables
- func DoActivityList(call *youtube.ActivitiesListCall, table *Table, maxresults int64) error
- func DoBroadcastsList(call *youtube.LiveBroadcastsListCall, table *Table, maxresults int64) error
- func DoChannelsList(call *youtube.ChannelsListCall, table *Table, maxresults int64) error
- func DoChatMessagesList(call *youtube.LiveChatMessagesListCall, table *Table, maxresults int64) error
- func DoChatModeratorsList(call *youtube.LiveChatModeratorsListCall, table *Table, maxresults int64) error
- func DoClaimsList(call *youtubepartner.ClaimsListCall, table *Table, maxresults int64) error
- func DoCommentThreadsList(call *youtube.CommentThreadsListCall, table *Table, maxresults int64) error
- func DoCommentsList(call *youtube.CommentsListCall, table *Table, maxresults int64) error
- func DoPlaylistItemsList(call *youtube.PlaylistItemsListCall, table *Table, maxresults int64) error
- func DoPlaylistsList(call *youtube.PlaylistsListCall, table *Table, maxresults int64) error
- func DoSearchList(call *youtube.SearchListCall, table *Table, maxresults int64) error
- func DoStreamsList(call *youtube.LiveStreamsListCall, table *Table, maxresults int64) error
- func DoVideosList(call *youtube.VideosListCall, table *Table, maxresults int64) error
- type Command
- type Defaults
- type Flag
- type FlagSet
- func (this *FlagSet) AddFlag(flag *Flag) error
- func (this *FlagSet) AddFlags(flags []*Flag) error
- func (this *FlagSet) CloseOutput() error
- func (this *FlagSet) DisplayOutput() error
- func (this *FlagSet) ExecuteCommand(command *Command, service *ytservice.Service) error
- func (this *FlagSet) GetCommandFromName(name string) (*Command, error)
- func (this *FlagSet) OpenOutput() error
- func (this *FlagSet) Parse() (*Command, error)
- func (this *FlagSet) ReadDefaults() error
- func (this *FlagSet) ReadInput() error
- func (this *FlagSet) RegisterCommands(funcs []*RegisterFunction) error
- func (this *FlagSet) RemoveAuthToken() error
- func (this *FlagSet) SetFields(fields []string) error
- func (this *FlagSet) SetupCommand(command *Command) error
- func (this *FlagSet) UsageCommand(command *Command)
- func (this *FlagSet) UsageCommandList()
- func (this *FlagSet) UsageFields()
- func (this *FlagSet) UsageGlobalFlags()
- func (this *FlagSet) WriteClientSecret(data64 string) error
- func (this *FlagSet) WriteDefaults() error
- func (this *FlagSet) WriteServiceAccount(data64 string) error
- type Input
- type InputFormat
- type RegisterFunction
- type Section
- type Table
- func (this *Table) AddFieldOrPart(key string) error
- func (this *Table) Append(items interface{}) error
- func (this *Table) DataOutput() error
- func (this *Table) FieldsForPart(part string) []*Flag
- func (this *Table) Info(message string)
- func (this *Table) NewRow() *Values
- func (this *Table) NumberOfColumns() int
- func (this *Table) NumberOfRows() int
- func (this *Table) Parts(all bool) []string
- func (this *Table) RegisterPart(part string, fields []*Flag)
- func (this *Table) RemoveFieldOrPart(key string) error
- func (this *Table) SetColumns(columns []string) error
- func (this *Table) SetDataFormat(handle io.Writer, format int)
- type Value
- func (this *Value) Bool() bool
- func (this *Value) Duration() time.Duration
- func (this *Value) IsBoolFlag() bool
- func (this *Value) IsSet() bool
- func (this *Value) Set(value string) error
- func (this *Value) SetBool(value bool) error
- func (this *Value) SetFloat(value float64) error
- func (this *Value) SetInt(value int64) error
- func (this *Value) SetString(value string) error
- func (this *Value) SetUint(value uint64) error
- func (this *Value) String() string
- func (this *Value) Time() time.Time
- func (this *Value) Uint64() uint64
- type Values
- func (this *Values) Get(flag *Flag) *Value
- func (this *Values) GetBool(flag *Flag) bool
- func (this *Values) GetDuration(flag *Flag) time.Duration
- func (this *Values) GetInt(flag *Flag) int64
- func (this *Values) GetString(flag *Flag) string
- func (this *Values) GetTime(flag *Flag) time.Time
- func (this *Values) GetTimeInISOFormat(flag *Flag) string
- func (this *Values) GetUint(flag *Flag) uint64
- func (this *Values) IsKindOf(flag *Flag, kind int) bool
- func (this *Values) IsSet(flag *Flag) bool
- func (this *Values) Set(value *Value) *Value
- func (this *Values) SetDefault(flag *Flag, value string) error
- func (this *Values) SetFields(fieldmap map[string]*Flag) []string
Constants ¶
const ( YouTubeMaxPagingResults = 50 YouTubeMaxLiveChatPagingResults = 200 )
Constants
const ( OUTPUT_ASCII = iota OUTPUT_CSV )
const ( FLAG_STRING = iota FLAG_UINT FLAG_BOOL FLAG_ENUM FLAG_VIDEO FLAG_CHANNEL FLAG_PLAYLIST FLAG_LANGUAGE FLAG_REGION FLAG_STREAM FLAG_CONTENTOWNER FLAG_TIME FLAG_DURATION )
Variables ¶
var ( FlagCredentials = Flag{Name: "credentials", Description: "Folder containing credentials", Type: FLAG_STRING, Default: ".ytapi"} FlagDebug = Flag{Name: "debug", Description: "Show API requests and responses on stderr", Type: FLAG_BOOL, Default: "false"} FlagQuotaUser = Flag{Name: "quotauser", Description: "Set Quota User for API calls", Type: FLAG_STRING} FlagTraceToken = Flag{Name: "tracetoken", Description: "Set Trace Token for API calls", Type: FLAG_STRING} FlagServiceAccount = Flag{Name: "serviceaccount", Description: "Obtain token using service account information", Type: FLAG_BOOL, Default: "false"} FlagScope = Flag{Name: "scope", Description: "Permissions granted during authentication", Type: FLAG_ENUM, Default: "data", Extra: "data|dataread|partner|audit|analytics|revenue|all"} FlagFields = Flag{Name: "fields", Description: "Comma-separated list of output fields", Type: FLAG_STRING} FlagInput = Flag{Name: "in", Description: "Input filename and/or format (csv)", Type: FLAG_STRING, Default: "csv"} FlagOutput = Flag{Name: "out", Description: "Output filename and/or format (txt, csv)", Type: FLAG_STRING, Default: "txt"} FlagFile = Flag{Name: "file", Description: "Filename", Type: FLAG_STRING} FlagContentOwner = Flag{Name: "contentowner", Description: "Content Owner ID", Type: FLAG_CONTENTOWNER} FlagChannel = Flag{Name: "channel", Description: "Channel ID", Type: FLAG_CHANNEL} FlagMaxResults = Flag{Name: "maxresults", Description: "Maximum number of results to return", Type: FLAG_UINT, Default: "0"} FlagVideo = Flag{Name: "video", Description: "Video ID", Type: FLAG_VIDEO} FlagPlaylist = Flag{Name: "playlist", Description: "Playlist ID", Type: FLAG_PLAYLIST} FlagStream = Flag{Name: "stream", Description: "Stream ID or Key", Type: FLAG_STREAM} FlagLanguage = Flag{Name: "language", Description: "Localized language", Type: FLAG_LANGUAGE} FlagRegion = Flag{Name: "region", Description: "Country region code", Type: FLAG_REGION} FlagTitle = Flag{Name: "title", Description: "Metadata title", Type: FLAG_STRING} FlagDescription = Flag{Name: "description", Description: "Metadata description", Type: FLAG_STRING} FlagEmbeds = Flag{Name: "embeds", Description: "Embed player flag", Type: FLAG_BOOL} FlagLicense = Flag{Name: "license", Description: "Video License", Type: FLAG_ENUM, Extra: "youtube|creativeCommon"} FlagStatsViewable = Flag{Name: "statsviewable", Description: "Extended video statistics are publicly viewable", Type: FLAG_BOOL} FlagPrivacyStatus = Flag{Name: "status", Description: "Privacy status", Type: FLAG_ENUM, Extra: "private|public|unlisted"} FlagDate = Flag{Name: "date", Description: "Publish date and time", Type: FLAG_TIME} FlagBroadcastStatus = Flag{Name: "status", Description: "Broadcast status", Type: FLAG_ENUM, Extra: "all|upcoming|active|completed"} FlagBroadcastTransition = Flag{Name: "status", Description: "Broadcast transition", Type: FLAG_ENUM, Extra: "complete|live|testing"} FlagStartTime = Flag{Name: "start", Description: "Scheduled start time", Type: FLAG_TIME} FlagEndTime = Flag{Name: "end", Description: "Scheduled end time", Type: FLAG_TIME} FlagDvr = Flag{Name: "dvr", Description: "Enable DVR", Type: FLAG_BOOL} FlagContentEncryption = Flag{Name: "encryption", Description: "Enable content encryption", Type: FLAG_BOOL} FlagEmbed = Flag{Name: "embed", Description: "Enable embedding", Type: FLAG_BOOL} FlagRecordFromStart = Flag{Name: "record", Description: "Enable recording", Type: FLAG_BOOL} FlagStartWithSlate = Flag{Name: "slate", Description: "Start with slate", Type: FLAG_BOOL} FlagClosedCaptions = Flag{Name: "captions", Description: "Enable closed captions", Type: FLAG_BOOL} FlagMonitorStream = Flag{Name: "monitor", Description: "Enable stream monitoring", Type: FLAG_BOOL} FlagBroadcastDelay = Flag{Name: "delay", Description: "Broadcast delay (ms)", Type: FLAG_UINT} FlagLowLatency = Flag{Name: "lowlatency", Description: "Enable low latency", Type: FLAG_BOOL} FlagProjection = Flag{Name: "projection", Description: "Projection format", Type: FLAG_ENUM, Extra: "360|rectangular"} FlagCuepointOffset = Flag{Name: "offset", Description: "Offset time (ms)", Type: FLAG_UINT} FlagCuepointDuration = Flag{Name: "duration", Description: "Duration", Type: FLAG_DURATION} FlagCuepointTime = Flag{Name: "time", Description: "Walltime", Type: FLAG_TIME} FlagCuepointPodDuration = Flag{Name: "podduration", Description: "Ad Pod Duration", Type: FLAG_DURATION} FlagVideoFilter = Flag{Name: "filter", Description: "Video filter", Type: FLAG_ENUM, Extra: "chart|like|dislike|likes|favorites|uploads|watchhistory|watchlater", Default: "uploads"} FlagVideoCategory = Flag{Name: "category", Description: "Video Category", Type: FLAG_UINT} FlagVideoRating = Flag{Name: "rating", Description: "Video Rating", Type: FLAG_ENUM, Extra: "like|dislike|none"} FlagCommentThread = Flag{Name: "thread", Description: "Comment Thread", Type: FLAG_STRING} FlagCommentText = Flag{Name: "text", Description: "Comment Text", Type: FLAG_STRING} FlagCommentFormat = Flag{Name: "format", Description: "Comment Format", Type: FLAG_ENUM, Extra: "plainText|html", Default: "plainText"} FlagCommentOrder = Flag{Name: "order", Description: "Comment order", Type: FLAG_ENUM, Extra: "time|relevance"} FlagCommentModerationStatus = Flag{Name: "status", Description: "Comment moderation status", Type: FLAG_ENUM, Extra: "heldForReview|likelySpam|published"} FlagCommentModerationStatus2 = Flag{Name: "status", Description: "Comment moderation status", Type: FLAG_ENUM, Extra: "heldForReview|published|rejected"} FlagCommentBanAuthor = Flag{Name: "ban", Description: "Ban comment author", Type: FLAG_BOOL} FlagChat = Flag{Name: "chat", Description: "Live Chat or Broadcast ID", Type: FLAG_STRING} FlagChatMessage = Flag{Name: "message", Description: "Live Chat Message", Type: FLAG_STRING} FlagChatText = Flag{Name: "text", Description: "Chat Text", Type: FLAG_STRING} FlagActivityHome = Flag{Name: "home", Description: "Display Homepage Activity Feed", Type: FLAG_BOOL} FlagPlaylistPosition = Flag{Name: "position", Description: "Playlist position", Type: FLAG_UINT} FlagPlaylistNote = Flag{Name: "note", Description: "Playlist note", Type: FLAG_STRING} FlagSectionType = Flag{Name: "type", Description: "Channel Section type", Type: FLAG_ENUM, Extra: "allPlaylists|completedEvents|likedPlaylists|likes|liveEvents|multipleChannels|multiplePlaylists|popularUploads|postedPlaylists|postedVideos|recentActivity|recentPosts|recentUploads|singlePlaylist|subscriptions|upcomingEvents"} FlagSectionStyle = Flag{Name: "style", Description: "Channel Section style", Type: FLAG_ENUM, Extra: "horizontalRow|verticalList", Default: "horizontalRow"} FlagSectionPosition = Flag{Name: "position", Description: "Channel Section position", Type: FLAG_UINT} FlagSearchQuery = Flag{Name: "q", Description: "Search query", Type: FLAG_STRING} FlagSearchOrder = Flag{Name: "order", Description: "Search order", Type: FLAG_ENUM, Extra: "date|rating|relevance|title|viewcount"} FlagSearchChannelOrder = Flag{Name: "order", Description: "Search order", Type: FLAG_ENUM, Extra: "date|rating|relevance|title|viewcount|videocount"} FlagSearchVideo = Flag{Name: "video", Description: "Related video", Type: FLAG_VIDEO} FlagSearchSafe = Flag{Name: "safesearch", Description: "Restricted content filter", Type: FLAG_ENUM, Extra: "none|moderate|strict"} FlagSearchBroadcastStatus = Flag{Name: "status", Description: "Broadcast status", Type: FLAG_ENUM, Extra: "completed|live|upcoming"} FlagCaption = Flag{Name: "caption", Description: "Caption ID", Type: FLAG_STRING} FlagCaptionSync = Flag{Name: "sync", Description: "Automatically synchronize the caption file with the audio track of the video", Type: FLAG_BOOL} FlagCaptionDraft = Flag{Name: "draft", Description: "Status of the caption track", Type: FLAG_BOOL} FlagCaptionFormat = Flag{Name: "format", Description: "Format of the caption track", Type: FLAG_ENUM, Extra: "sbv|scc|srt|ttml|vtt"} FlagCaptionName = Flag{Name: "name", Description: "Name of the caption track", Type: FLAG_STRING} FlagPolicy = Flag{Name: "policy", Description: "Policy ID", Type: FLAG_STRING} FlagPolicyOrder = Flag{Name: "order", Description: "Policy list order", Type: FLAG_ENUM, Extra: "timeUpdatedAsc|timeUpdatedDesc"} FlagClaim = Flag{Name: "claim", Description: "Claim ID", Type: FLAG_VIDEO} FlagClaimType = Flag{Name: "type", Description: "Claim Type: Defaults to audiovisual", Type: FLAG_ENUM, Extra: "audio|visual|audiovisual", Default: "audiovisual"} FlagClaimStatus = Flag{Name: "status", Description: "Claim Status", Type: FLAG_ENUM, Extra: "active|inactive"} FlagClaimBlockOutsideOwnership = Flag{Name: "blockoutsideownership", Description: "Block viewing outside ownership regions", Type: FLAG_BOOL} FlagAsset = Flag{Name: "asset", Description: "Asset ID", Type: FLAG_STRING} FlagAssetFilter = Flag{Name: "filter", Description: "Retrieve computed asset information or my asset information", Type: FLAG_ENUM, Extra: "none|effective|mine", Default: "none"} FlagUploader = Flag{Name: "uploader", Description: "Content Owner Uploader Name", Type: FLAG_STRING} FlagStreamResolution = Flag{Name: "resolution", Description: "Stream Resolution", Type: FLAG_ENUM, Extra: "2160p_hfr|2160p|1440p_hfr|1440p|1080p_hfr|1080p|720p_hfr|720p|480p|360p|240p", Default: "1080p"} FlagStreamType = Flag{Name: "type", Description: "Stream Ingestion Type", Type: FLAG_ENUM, Extra: "rtmp|dash", Default: "rtmp"} FlagStreamReusable = Flag{Name: "reusable", Description: "Stream Reusable", Type: FLAG_BOOL} FlagAnalyticsPeriod = Flag{Name: "period", Description: "Time period", Type: FLAG_STRING, Default: "last28Days"} FlagAnalyticsMetrics = Flag{Name: "metrics", Description: "Analytics Metrics", Type: FLAG_STRING} FlagAnalyticsDimensions = Flag{Name: "dimensions", Description: "Analytics Dimensions", Type: FLAG_STRING} FlagAnalyticsFilter = Flag{Name: "filter", Description: "Analytics Filters", Type: FLAG_STRING} FlagAnalyticsSort = Flag{Name: "sort", Description: "Data sort order", Type: FLAG_STRING} FlagAnalyticsCurrency = Flag{Name: "currency", Description: "Reporting Currency", Type: FLAG_STRING} FlagAnalyticsIncludeSystem = Flag{Name: "system", Description: "Include system managed reports", Type: FLAG_BOOL} )
Command-line flags
var ( // Global flags which are defined for every invocation of the tool GlobalFlags = []*Flag{ &FlagDebug, &FlagQuotaUser, &FlagTraceToken, &FlagCredentials, &FlagContentOwner, &FlagChannel, &FlagFields, &FlagOutput, &FlagInput, } // Variety of error conditions ErrorEmptyArgs = errors.New("No Arguments") ErrorUsage = errors.New("Display usage information") ErrorWriteDefaults = errors.New("Write Defaults to file") ErrorWriteCredentials = errors.New("Write Credentials") ErrorRemoveAuthToken = errors.New("Remove OAuth token") ErrorServiceAccount = errors.New("Invalid service account or missing content owner") )
////////////////////////////////////////////////////////////////////////////// Global variables
var ( RegExStreamKey = regexp.MustCompile("^([a-zA-Z0-9]{4})-([a-zA-Z0-9]{4})-([a-zA-Z0-9]{4})-([a-zA-Z0-9]{4})$") RegExStreamIdentifier = regexp.MustCompile("^([a-zA-Z0-9\\-]{38})$") RegExVideoIdentifier = regexp.MustCompile("^([a-zA-Z0-9\\-\\_]{11})$") )
var (
ErrFieldMismatch = errors.New("Number of fields does not match")
)
Functions ¶
func DoActivityList ¶
func DoBroadcastsList ¶
func DoChannelsList ¶
func DoChatMessagesList ¶
func DoChatModeratorsList ¶
func DoClaimsList ¶
func DoCommentThreadsList ¶
func DoCommentsList ¶
func DoPlaylistItemsList ¶
func DoPlaylistsList ¶
func DoSearchList ¶
func DoStreamsList ¶
func DoVideosList ¶
Types ¶
type Command ¶
type Command struct { Name string Description string ServiceAccount bool Optional []*Flag Required []*Flag Setup func(*Values, *Table) error Execute func(*ytservice.Service, *Values, *Table) error }
Command structure defines a command
type Defaults ¶
type Defaults struct { ContentOwner string `json:"contentowner,omitempty"` Channel string `json:"channel,omitempty"` }
Defaults structure defines values read from store
type Flag ¶
type Flag struct { Name string Description string Type uint32 Extra string Default string Path string Array bool // contains filtered or unexported fields }
Flag structure defines a parameter type
func (*Flag) TypeString ¶
type FlagSet ¶
type FlagSet struct { Values *Values Input *Input Output *Table ClientSecrets string ServiceAccount string AuthToken string Defaults string // contains filtered or unexported fields }
FlagSet structure defines the main object for execution of a set of instructions
func (*FlagSet) CloseOutput ¶
func (*FlagSet) DisplayOutput ¶
func (*FlagSet) ExecuteCommand ¶
func (*FlagSet) GetCommandFromName ¶
func (*FlagSet) OpenOutput ¶
func (*FlagSet) ReadDefaults ¶
func (*FlagSet) RegisterCommands ¶
func (this *FlagSet) RegisterCommands(funcs []*RegisterFunction) error
func (*FlagSet) RemoveAuthToken ¶
func (*FlagSet) SetupCommand ¶
func (*FlagSet) UsageCommand ¶
Output a list of flags for a command.
func (*FlagSet) UsageCommandList ¶
func (this *FlagSet) UsageCommandList()
Output a list of possible commands, grouped by section. Will not display commands which are only to be used for service accounts, if no service account is installed
func (*FlagSet) UsageFields ¶
func (this *FlagSet) UsageFields()
func (*FlagSet) UsageGlobalFlags ¶
func (this *FlagSet) UsageGlobalFlags()
func (*FlagSet) WriteClientSecret ¶
func (*FlagSet) WriteDefaults ¶
func (*FlagSet) WriteServiceAccount ¶
type Input ¶
type Input struct {
// contains filtered or unexported fields
}
func (*Input) SetDataSource ¶
func (this *Input) SetDataSource(handle io.ReadCloser, format InputFormat)
SetDataSource sets Incoming data source
type RegisterFunction ¶
RegisterFunction defines a registration function
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func (*Table) AddFieldOrPart ¶
Add a column or part
func (*Table) DataOutput ¶
func (*Table) FieldsForPart ¶
Return fields for a particular part
func (*Table) Parts ¶
Return parts which are used in the column output, or if 'all' is set to true, return all parts registered in order
func (*Table) RegisterPart ¶
Register a part & fields
func (*Table) RemoveFieldOrPart ¶
Remove a field or part from the output columns
func (*Table) SetColumns ¶
Set the default output columns
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value structure defines a generic value
func (*Value) IsBoolFlag ¶
type Values ¶
type Values struct {
// contains filtered or unexported fields
}
Values structure defines a set of values