youtube

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseVideosResponse

func ParseVideosResponse(data []byte) (map[string]VideoDetails, error)

ParseVideosResponse parses a YouTube videos.list JSON response. It returns a map keyed by video ID containing duration and tag details.

Types

type Episode

type Episode struct {
	ID          string
	Title       string
	URL         string
	Published   time.Time
	Description string
	Duration    string
	Tags        []string
}

Episode is a single SAP Developer News video from the YouTube playlist.

func FetchPlaylist

func FetchPlaylist(url string) ([]Episode, error)

FetchPlaylist fetches the YouTube playlist RSS feed at url and returns episodes.

func FetchPlaylistAPI

func FetchPlaylistAPI(playlistID, apiKey string) ([]Episode, error)

FetchPlaylistAPI fetches all episodes in a YouTube playlist using the Data API v3. It paginates through playlistItems.list and batch-fetches video details via videos.list. Video detail fetch failures are non-fatal — episodes are returned without enrichment.

func FetchPlaylistRetry

func FetchPlaylistRetry(url string, maxAttempts int) ([]Episode, error)

FetchPlaylistRetry wraps FetchPlaylist with exponential backoff. Only retries on HTTP 404/5xx (YouTube's intermittent outage codes).

func ParseFeed

func ParseFeed(data []byte) ([]Episode, error)

ParseFeed parses a YouTube Atom RSS feed and returns the episodes in feed order.

func Resolve

func Resolve(src content.YouTubeSource, apiKey string) ([]Episode, error)

Resolve fetches videos for a YouTubeSource. For type:"video", returns a synthetic Episode without a network call. For type:"playlist" with apiKey, tries API v3 first, falls back to RSS. For type:"playlist" without apiKey, uses RSS directly.

type HTTPError

type HTTPError struct {
	StatusCode int
	URL        string
}

HTTPError records an HTTP status code from a failed YouTube request.

func (*HTTPError) Error

func (e *HTTPError) Error() string

type PlaylistItemParsed

type PlaylistItemParsed struct {
	VideoID     string
	Title       string
	Description string
	Published   time.Time
}

PlaylistItemParsed holds the fields extracted from a playlistItems.list response item.

func ParsePlaylistItemsResponse

func ParsePlaylistItemsResponse(data []byte) ([]PlaylistItemParsed, string, error)

ParsePlaylistItemsResponse parses a YouTube playlistItems.list JSON response. It returns the parsed items and the nextPageToken (empty string when no more pages).

type VideoDetails

type VideoDetails struct {
	Duration string
	Tags     []string
}

VideoDetails holds the enrichment fields returned by a videos.list response item.

Jump to

Keyboard shortcuts

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