youtube

package
v0.0.0-...-f2b87e9 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddItemsToPlaylistBody

type AddItemsToPlaylistBody struct {
	UserID  string                    `json:"userId"`
	Payload AddItemsToPlaylistPayload `json:"payload"`
}

type AddItemsToPlaylistPayload

type AddItemsToPlaylistPayload struct {
	PlaylistID string   `json:"playlistId"`
	VideoIDs   []string `json:"videoIds"`
}

type CreatePlaylistBody

type CreatePlaylistBody struct {
	UserID  string                `json:"userId"`
	Payload CreatePlaylistPayload `json:"payload"`
}

type CreatePlaylistPayload

type CreatePlaylistPayload struct {
	Title         string `json:"title"`
	Description   string `json:"description,omitempty"`
	PrivacyStatus string `json:"privacyStatus,omitempty"` // "public", "private", or "unlisted"
}

type Playlist

type Playlist struct {
	ID            string `json:"id"`
	Title         string `json:"title"`
	Description   string `json:"description"`
	ImageURL      string `json:"imageUrl"`
	VideosCount   int64  `json:"videosCount"`
	ChannelTitle  string `json:"channelTitle"`
	PrivacyStatus string `json:"privacyStatus"`
}

type PlaylistItem

type PlaylistItem struct {
	ID                     string `json:"id"`
	Title                  string `json:"title"`
	Description            string `json:"description"`
	ThumbnailURL           string `json:"thumbnailUrl"`
	VideoID                string `json:"videoId"`
	VideoOwnerChannelTitle string `json:"videoOwnerChannelTitle"`
}

type VideoID

type VideoID struct {
	VideoID string `json:"videoId"`
}

type VideoSearchResult

type VideoSearchResult struct {
	ID           VideoID `json:"id"`
	Title        string  `json:"title"`
	Description  string  `json:"description"`
	ThumbnailURL string  `json:"thumbnailUrl"`
	ChannelTitle string  `json:"channelTitle"`
}

type YouTubeClient

type YouTubeClient struct {
	AppContext *utils.AppContext
}

func NewYouTubeClient

func NewYouTubeClient(appCtx *utils.AppContext) *YouTubeClient

func (*YouTubeClient) AddItemsToPlaylist

func (c *YouTubeClient) AddItemsToPlaylist(accessToken string, payload AddItemsToPlaylistPayload) error

Adds items to an existing YouTube playlist

func (*YouTubeClient) CreatePlaylist

func (c *YouTubeClient) CreatePlaylist(accessToken string, payload CreatePlaylistPayload) (*youtube.Playlist, error)

Creates a new YouTube playlist

func (*YouTubeClient) DeletePlaylist

func (c *YouTubeClient) DeletePlaylist(accessToken, playlistID string) error

Deletes the specified YouTube playlist

func (*YouTubeClient) GetCurrentUserPlaylists

func (c *YouTubeClient) GetCurrentUserPlaylists(accessToken string) (YouTubePlaylistsResponse, error)

Gets the current user's playlists

func (*YouTubeClient) GetPlaylistItems

func (c *YouTubeClient) GetPlaylistItems(playlistID, accessToken string) (YouTubePlaylistItemsResponse, error)

Gets a playlist's items

func (*YouTubeClient) RequestToken

func (c *YouTubeClient) RequestToken(payload url.Values) (utils.TokenResponse, error)

Requests a new access token from Google

func (*YouTubeClient) SearchVideos

func (c *YouTubeClient) SearchVideos(accessToken, query string, maxResults int64) ([]utils.UnifiedTrackSearchResult, error)

Searches for videos on YouTube based on a query

type YouTubeHandler

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

func NewYouTubeHandler

func NewYouTubeHandler(youTubeService *YouTubeService) *YouTubeHandler

func (*YouTubeHandler) AddItemsToPlaylistHandler

func (h *YouTubeHandler) AddItemsToPlaylistHandler(c *gin.Context)

Handles the insertion of multiple items into a YouTube playlist

func (*YouTubeHandler) CallbackHandler

func (h *YouTubeHandler) CallbackHandler(c *gin.Context)

After user authorizes the application, Google redirects to a specified callback URL

func (*YouTubeHandler) CheckAuthHandler

func (h *YouTubeHandler) CheckAuthHandler(c *gin.Context)

Checks YouTube authentication status for a specific user

func (*YouTubeHandler) CreatePlaylistHandler

func (h *YouTubeHandler) CreatePlaylistHandler(c *gin.Context)

Handles the creation of a new playlist

func (*YouTubeHandler) DeletePlaylistHandler

func (h *YouTubeHandler) DeletePlaylistHandler(c *gin.Context)

Handles the deletion of a YouTube playlist

func (*YouTubeHandler) GetCurrentUserPlaylistsHandler

func (h *YouTubeHandler) GetCurrentUserPlaylistsHandler(c *gin.Context)

Handles the retrieval of the current user's YouTube playlists

func (*YouTubeHandler) GetPlaylistItemsHandler

func (h *YouTubeHandler) GetPlaylistItemsHandler(c *gin.Context)

Handles the retrieval of the current user's Spotify playlists

func (*YouTubeHandler) LoginHandler

func (h *YouTubeHandler) LoginHandler(c *gin.Context)

Sends the session ID and redirect auth URL to the frontend

func (*YouTubeHandler) LogoutHandler

func (h *YouTubeHandler) LogoutHandler(c *gin.Context)

Handles a Google de-authentication

func (*YouTubeHandler) SearchVideosHandler

func (h *YouTubeHandler) SearchVideosHandler(c *gin.Context)

Handles the retrieval of videos that match the given artist name and song title

type YouTubePlaylistItemsResponse

type YouTubePlaylistItemsResponse struct {
	Items []PlaylistItem `json:"items"`
}

type YouTubePlaylistsResponse

type YouTubePlaylistsResponse struct {
	TotalCount int `json:"totalCount"`
	// PrevPageToken   string     `json:"prevPageToken"`
	// NextPageToken   string     `json:"nextPageToken"`
	Playlists []Playlist `json:"playlists"`
}

type YouTubeService

type YouTubeService struct {
	YouTubeClient *YouTubeClient
	Auth0Service  *auth0.Auth0Service
}

func NewYouTubeService

func NewYouTubeService(youTubeClient *YouTubeClient, auth0Service *auth0.Auth0Service) *YouTubeService

func (*YouTubeService) AddItemsToPlaylist

func (s *YouTubeService) AddItemsToPlaylist(userID string, payload AddItemsToPlaylistPayload) error

Wrapper service function for AddItemsToPlaylist client function

func (*YouTubeService) CreatePlaylist

func (s *YouTubeService) CreatePlaylist(userID string, payload CreatePlaylistPayload) (*youtube.Playlist, error)

Wrapper service function for CreatePlaylist client function

func (*YouTubeService) DeletePlaylist

func (s *YouTubeService) DeletePlaylist(userID, playlistID string) error

Wrapper service function for DeletePlaylist client function

func (*YouTubeService) GetCurrentUserPlaylists

func (s *YouTubeService) GetCurrentUserPlaylists(userID string) (YouTubePlaylistsResponse, error)

Wrapper service function for GetCurrentUserPlaylists client function

func (*YouTubeService) GetPlaylistItems

func (s *YouTubeService) GetPlaylistItems(userID, playlistID string) (YouTubePlaylistItemsResponse, error)

Wrapper service function for GetPlaylistItems client function

func (*YouTubeService) HandleCallback

func (s *YouTubeService) HandleCallback(code, userID, sessionID string) error

Handles the callback after user has successfully authorized our app on Google's auth page

func (*YouTubeService) SearchVideos

func (s *YouTubeService) SearchVideos(userID, artistName, songTitle string) ([]utils.UnifiedTrackSearchResult, error)

Wrapper service function for SearchVideos client function

func (*YouTubeService) StartLoginFlow

func (s *YouTubeService) StartLoginFlow() (string, string, error)

Completes the initial steps of the authorization code flow with PKCE

type YouTubeVideoSearchResponse

type YouTubeVideoSearchResponse struct {
	Items []VideoSearchResult `json:"items"`
}

Jump to

Keyboard shortcuts

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