search

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const API_URL = "https://youtube.googleapis.com/youtube/v3/search"
View Source
const DefaultSearchTypes = TypeVideo | TypeChannel | TypePlaylist

DefaultSearchTypes uses all types

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client uses YouTube search REST API See https://developers.google.com/youtube/v3/docs/search

func New

func New(apikey string, client *http.Client) *Client

func (Client) Search

func (s Client) Search(query string, types TypeParam, custom map[string]string) (*Result, error)

Search searches YouTube REST API with given query See https://developers.google.com/youtube/v3/docs/search/list

Parameter `types` sets the scope (videos, playlists, channels) for search, use 0 for default (all)

Parameter `custom` is a map which may contain custom parameters set by user. For example - `pageToken` which points to `nextPageToken` or `prevPageToken` - `publishedAfter` date - `relevanceLanguage` language code - `regionCode` such as US, UK, FI, ... See https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes

type ID

type ID struct {
	Kind       string  `json:"kind"` // channel, playlist, video
	VideoID    *string `json:"videoId,omitempty"`
	ChannelID  *string `json:"channelId,omitempty"`
	PlaylistID *string `json:"playlistId,omitempty"`
}

type Item

type Item struct {
	//Kind    string  `json:"kind"`
	Etag    string  `json:"etag"` // for cache
	ID      ID      `json:"id,omitempty"`
	Snippet Snippet `json:"snippet"`
}

type Result

type Result struct {
	//Kind          string          `json:"kind"`
	Etag          string          `json:"etag"` // for cache
	NextPageToken *string         `json:"nextPageToken,omitempty"`
	RegionCode    string          `json:"regionCode"`
	PageInfo      shared.PageInfo `json:"pageInfo"`
	Items         []Item          `json:"items"`
}

type Snippet

type Snippet struct {
	ChannelID            string            `json:"channelId"`
	ChannelTitle         string            `json:"channelTitle"`
	PublishedAt          time.Time         `json:"publishedAt"`
	PublishTime          time.Time         `json:"publishTime"`
	Title                string            `json:"title"`
	Description          string            `json:"description"`
	Thumbnails           shared.Thumbnails `json:"thumbnails"`
	LiveBroadcastContent string            `json:"liveBroadcastContent"` // "none"
}

type TypeParam added in v1.4.0

type TypeParam uint8

TypeParam defines what kind of content is searched

const (
	TypeChannel TypeParam = 1 << iota
	TypePlaylist
	TypeVideo
)

func (TypeParam) String added in v1.4.0

func (tp TypeParam) String() string

Jump to

Keyboard shortcuts

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