youtube

package
v0.0.0-...-15b0568 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	APIKey     string
	YtDlPath   string
	YTCacheDir string
}

Manager is used to initialize a youtube object with needed config.

func (Manager) DownloadDCAAudio

func (yt Manager) DownloadDCAAudio(videoID string) (string, error)

DownloadDCAAudio takes a youtube video id, downloads the audio and then converts the song to DCA format to be compatible with discordgo.

func (Manager) Search

func (yt Manager) Search(searchStr string) (SearchListResponse, error)

Search takes a string input and searches youtube for results. Search returns a YoutubeSearchListResponse with the results.

func (Manager) SearchFirstResult

func (yt Manager) SearchFirstResult(searchStr string) (SearchResult, error)

SearchFirstResult takes a string input and searches youtube, returning only the first result in a YoutubeSearchResult

type SearchListResponse

type SearchListResponse struct {
	Kind          string `json:"kind"`
	Etag          string `json:"etag"`
	NextPageToken string `json:"nextPageToken"`
	PrevPageToken string `json:"prevPageToken"`
	RegionCode    string `json:"regionCode"`
	PageInfo      struct {
		TotalResults   float64 `json:"totalResults"`
		ResultsPerPage float64 `json:"resutlsPerPage"`
	} `json:"pageInfo"`
	Items []SearchResult `json:"items"`
}

SearchListResponse is used for json unmarshalling a Youtube search result

type SearchResult

type SearchResult struct {
	Kind string `json:"kind"`
	Etag string `json:"etag"`
	ID   struct {
		Kind       string `json:"kind"`
		VideoID    string `json:"videoId"`
		ChannelID  string `json:"channelId"`
		PlaylistID string `json:"playlistId"`
	} `json:"id"`
	Snippet struct {
		PublishedAt string `json:"publishedAt"`
		ChannelID   string `json:"channelId"`
		Title       string `json:"title"`
		Description string `json:"description"`
		Thumbnails  struct {
			Default thumbnailInfo `json:"default"`
			Medium  thumbnailInfo `json:"medium"`
			High    thumbnailInfo `json:"high"`
		} `json:"thumbnails"`
		ChannelTitle         string `json:"channelTitle"`
		LiveBroadcastContent string `json:"liveBroadcastContent"`
	} `json:"snippet"`
}

SearchResult is use for json unmarshalling a Youtube search result.

Jump to

Keyboard shortcuts

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