feed

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(_ context.Context, feed *model.Feed, cfg *Config, hostname string) (*itunes.Podcast, error)

func BuildOPML

func BuildOPML(ctx context.Context, feeds map[string]*Config, db feedProvider, hostname string) (string, error)

func EnclosureFromExtension

func EnclosureFromExtension(feedConfig *Config) itunes.EnclosureType

func EpisodeName

func EpisodeName(feedConfig *Config, episode *model.Episode) string

Types

type Cleanup

type Cleanup struct {
	// KeepLast defines how many episodes to keep
	KeepLast int `toml:"keep_last"`
}

type Config

type Config struct {
	ID string `toml:"-"`
	// URL is a full URL of the field
	URL string `toml:"url"`
	// PageSize is the number of pages to query from YouTube API.
	// NOTE: larger page sizes/often requests might drain your API token.
	PageSize int `toml:"page_size"`
	// UpdatePeriod is how often to check for updates.
	// Format is "300ms", "1.5h" or "2h45m".
	// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
	// NOTE: too often update check might drain your API token.
	UpdatePeriod time.Duration `toml:"update_period"`
	// Cron expression format is how often to check update
	// NOTE: too often update check might drain your API token.
	CronSchedule string `toml:"cron_schedule"`
	// Quality to use for this feed
	Quality model.Quality `toml:"quality"`
	// Maximum height of video
	MaxHeight int `toml:"max_height"`
	// Format to use for this feed
	Format model.Format `toml:"format"`
	// Custom format properties
	CustomFormat CustomFormat `toml:"custom_format"`
	// Only download episodes that match the filters (defaults to matching anything)
	Filters Filters `toml:"filters"`
	// Clean is a cleanup policy to use for this feed
	Clean *Cleanup `toml:"clean"`
	// Custom is a list of feed customizations
	Custom Custom `toml:"custom"`
	// List of additional youtube-dl arguments passed at download time
	YouTubeDLArgs []string `toml:"youtube_dl_args"`
	// Post episode download hooks - executed after each episode is successfully downloaded
	// Multiple hooks can be configured and will execute in sequence
	// Example:
	//   [[feeds.ID1.post_episode_download]]
	//   command = ["echo", "Downloaded: $EPISODE_TITLE"]
	//   timeout = 10
	PostEpisodeDownload []*ExecHook `toml:"post_episode_download"`
	// Included in OPML file
	OPML bool `toml:"opml"`
	// Private feed (not indexed by podcast aggregators)
	PrivateFeed bool `toml:"private_feed"`
	// Playlist sort
	PlaylistSort model.Sorting `toml:"playlist_sort"`
}

Config is a configuration for a feed loaded from TOML

type Custom

type Custom struct {
	CoverArt        string        `toml:"cover_art"`
	CoverArtQuality model.Quality `toml:"cover_art_quality"`
	Category        string        `toml:"category"`
	Subcategories   []string      `toml:"subcategories"`
	Explicit        bool          `toml:"explicit"`
	Language        string        `toml:"lang"`
	Author          string        `toml:"author"`
	Title           string        `toml:"title"`
	Description     string        `toml:"description"`
	OwnerName       string        `toml:"ownerName"`
	OwnerEmail      string        `toml:"ownerEmail"`
	Link            string        `toml:"link"`
}

type CustomFormat

type CustomFormat struct {
	YouTubeDLFormat string `toml:"youtube_dl_format"`
	Extension       string `toml:"extension"`
}

type ExecHook

type ExecHook struct {
	// Command is the command and arguments to execute.
	// For single commands, use shell parsing: ["echo hello"]
	// For multiple args, pass directly: ["curl", "-X", "POST", "url"]
	Command []string `toml:"command"`

	// Timeout in seconds for command execution.
	// If 0 or unset, defaults to 60 seconds.
	Timeout int `toml:"timeout"`
}

ExecHook represents a single hook configuration that executes commands after specific lifecycle events (e.g., episode downloads).

Example configuration:

[[feeds.ID1.post_episode_download]]
command = ["curl", "-X", "POST", "-d", "$EPISODE_TITLE", "webhook.example.com"]
timeout = 30

Environment variables available to hooks:

  • EPISODE_FILE: Path to downloaded file (e.g., "podcast-id/episode.mp3")
  • FEED_NAME: The feed identifier
  • EPISODE_TITLE: The episode title

func (*ExecHook) Invoke

func (h *ExecHook) Invoke(env []string) error

Invoke executes the hook command with the provided environment variables.

The method handles nil hooks gracefully (returns nil) and validates that the command is not empty. Commands are executed with a timeout (default 60s) and inherit the parent process environment plus any additional variables.

Single-element commands are executed via shell (/bin/sh -c), while multi-element commands are executed directly for better security.

Returns an error if the command fails, times out, or returns a non-zero exit code. The error includes the combined stdout/stderr output for debugging.

type Filters

type Filters struct {
	Title          string `toml:"title"`
	NotTitle       string `toml:"not_title"`
	Description    string `toml:"description"`
	NotDescription string `toml:"not_description"`
	MinDuration    int64  `toml:"min_duration"`
	MaxDuration    int64  `toml:"max_duration"`
	MaxAge         int    `toml:"max_age"`
	MinAge         int    `toml:"min_age"`
}

type FixedKeyProvider

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

func (FixedKeyProvider) Get

func (p FixedKeyProvider) Get() string

type KeyProvider

type KeyProvider interface {
	Get() string
}

func NewFixedKey

func NewFixedKey(key string) (KeyProvider, error)

func NewKeyProvider

func NewKeyProvider(keys []string) (KeyProvider, error)

func NewRotatedKeys

func NewRotatedKeys(keys []string) (KeyProvider, error)

type RotatedKeyProvider

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

func (*RotatedKeyProvider) Get

func (p *RotatedKeyProvider) Get() string

Jump to

Keyboard shortcuts

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