Пример #1
0
func init() {
	cmd := &tool.Command{
		Name:    "search",
		Summary: "print the URLs of resources matching a query",
		Usage:   "[<option>]... <query>...",
		Description: `
Search YouTube for <query> (joined by spaces if multiple arguments are
given) and print the URLs of the top matches in descending order by
relevance.
`,
		Function: search,
		MinArgs:  1,
		MaxArgs:  -1,
		HasOpts:  true,
	}

	cmd.FlagSet = flag.NewFlagSet(cmd.Name, flag.ExitOnError)
	cmd.FlagSet.Usage = tool.UsageFunc(cmd)
	cmd.FlagSet.UintVar(&flagSearchN, "n", flagSearchN,
		"maximum number of results, in the range [0, 50]")
	cmd.FlagSet.StringVar(&flagSearchType, "type", flagSearchType,
		"restrict search to given resource types")

	tool.Commands[cmd.Name] = cmd
}
Пример #2
0
func init() {
	cmd := &tool.Command{
		Name:    "title",
		Summary: "print the title of a video or playlist at a URL",
		Usage:   "<url>",
		Description: `
Print the title of the video or playlist at <url>.
`,
		Function: title,
		MinArgs:  1,
		MaxArgs:  1,
	}

	cmd.FlagSet = flag.NewFlagSet(cmd.Name, flag.ExitOnError)
	cmd.FlagSet.Usage = tool.UsageFunc(cmd)

	tool.Commands[cmd.Name] = cmd
}
Пример #3
0
func init() {
	cmd := &tool.Command{
		Name:    "playlist",
		Summary: "print the URLs of videos in a playlist",
		Usage:   "<url>",
		Description: `
Print the URLs of the videos in the playlist at <url>, up to a maximum
of 50 videos.
`,
		Function: playlist,
		MinArgs:  1,
		MaxArgs:  1,
	}

	cmd.FlagSet = flag.NewFlagSet(cmd.Name, flag.ExitOnError)
	cmd.FlagSet.Usage = tool.UsageFunc(cmd)

	tool.Commands[cmd.Name] = cmd
}