youtube

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FeedHistory

func FeedHistory(selectedVideo SearchResultItem)

func GetLocalSubscribedChannels

func GetLocalSubscribedChannels() ([]string, error)

func GetLocalSubscribedChannelsVideos

func GetLocalSubscribedChannelsVideos() (*[]SearchResultItem, error)

func NewYouTubeAPI

func NewYouTubeAPI(clientID, clientSecret string) (chan *YouTubeAPI, error)

NewYouTubeAPI initializes the YouTube API by handling the OAuth2 flow.

func SaveHistory

func SaveHistory(history *[]SearchResultItem, filename string) error

func SearchVideos

func SearchVideos(query string, subscription bool) (*[]SearchResultItem, error)

Types

type SearchChannelResult

type SearchChannelResult struct {
	Author    string `json:"author"`
	AuthorUrl string `json:"authorUrl"`
}

Struct to parse the JSON response from the Invidious API

func GetAllChannelsInfo

func GetAllChannelsInfo(channelIds []string) ([]SearchChannelResult, error)

Function to fetch author information for a list of channel IDs

func SearchAuthorInfo

func SearchAuthorInfo(channelId string) (SearchChannelResult, error)

type SearchResultItem

type SearchResultItem struct {
	Type            string           `json:"type"`
	Title           string           `json:"title"`
	VideoID         string           `json:"videoId"`
	Author          string           `json:"author"`
	AuthorID        string           `json:"authorId"`
	AuthorURL       string           `json:"authorUrl"`
	VideoThumbnails []VideoThumbnail `json:"videoThumbnails"`
	Description     string           `json:"description"`
	ViewCount       int64            `json:"viewCount"`
	ViewCountText   string           `json:"viewCountText"`
	Published       int64            `json:"published"`
	PublishedText   string           `json:"publishedText"`
	LengthSeconds   int32            `json:"lengthSeconds"`
	ViewedDate      int64            `json:"vieweddate"`
}

SearchResultItem represents a single search result

func GetWatchedVideos

func GetWatchedVideos(filename string) ([]SearchResultItem, error)

func SearchVideoInfo

func SearchVideoInfo(videoID string) (SearchResultItem, error)

func YoutubeResultMenu

func YoutubeResultMenu(videoData []SearchResultItem) (SearchResultItem, error)

Handles the interactive menu for video selection. Powered by fzf-like

type VideoSnippet

type VideoSnippet struct {
	Title        string `json:"title"`
	Description  string `json:"description"`
	ChannelTitle string `json:"channelTitle"`
	PublishedAt  string `json:"publishedAt"`
	VideoURL     string `json:"videoUrl"`
}

type VideoThumbnail

type VideoThumbnail struct {
	Quality string `json:"quality"`
	URL     string `json:"url"`
	Width   int32  `json:"width"`
	Height  int32  `json:"height"`
}

type YouTubeAPI

type YouTubeAPI struct {
	Client *http.Client
}

func (*YouTubeAPI) GetAllSubscribedChannelsVideos

func (yt *YouTubeAPI) GetAllSubscribedChannelsVideos() (*[]SearchResultItem, error)

func (*YouTubeAPI) GetSubscribedChannels

func (yt *YouTubeAPI) GetSubscribedChannels() ([]string, error)

type YouTubeSearchResponse

type YouTubeSearchResponse []SearchResultItem

YouTubeSearchResponse represents the response from a YouTube search

type YouTubeSubscriptionsResponse

type YouTubeSubscriptionsResponse struct {
	Items []struct {
		Snippet struct {
			ResourceId struct {
				ChannelId string `json:"channelId"`
			} `json:"resourceId"`
		} `json:"snippet"`
	} `json:"items"`
}

Jump to

Keyboard shortcuts

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