feed

package
v1.0.1-0...-ec039c9 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package feed provided parser and downloader for youtube feeds and entries.

Index

Constants

View Source
const (
	FTDefault  = Type("")
	FTChannel  = Type("channel")
	FTPlaylist = Type("playlist")
)

enum for the different YouTube feed types.

Variables

View Source
var ErrSkip = errors.New("skip")

ErrSkip is returned when the file is not downloaded

Functions

This section is empty.

Types

type Downloader

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

Downloader executes an external command to download a video and extract its audio.

func NewDownloader

func NewDownloader(tmpl string, logOutWriter, logErrWriter io.Writer, destination string) *Downloader

NewDownloader creates a new Downloader with the given template (full command with placeholders for {{.ID}} and {{.Filename}}. Destination is the directory where the audio files will be stored.

func (*Downloader) Get

func (d *Downloader) Get(ctx context.Context, id, fname string) (file string, err error)

Get downloads a video from youtube and extracts audio. yt-dlp --extract-audio --audio-format=mp3 --audio-quality=0 -f m4a/bestaudio "https://www.youtube.com/watch?v={{.ID}}" --no-progress -o {{.Filename}}

type Entry

type Entry struct {
	ChannelID string `xml:"http://www.youtube.com/xml/schemas/2015 channelId"`
	VideoID   string `xml:"http://www.youtube.com/xml/schemas/2015 videoId"`
	Title     string `xml:"title"`
	Link      struct {
		Href string `xml:"href,attr"`
	} `xml:"link"`
	Published time.Time `xml:"published"`
	Updated   time.Time `xml:"updated"`

	Media struct {
		Description template.HTML `xml:"description"`
		Thumbnail   struct {
			URL string `xml:"url,attr"`
		} `xml:"thumbnail"`
	} `xml:"http://search.yahoo.com/mrss/ group"`

	Author struct {
		Name string `xml:"name"`
		URI  string `xml:"uri"`
	} `xml:"author"`

	File        string
	Duration    int    // seconds
	DurationFmt string // used for ui only
}

Entry represents a YouTube channel entry.

func (*Entry) String

func (e *Entry) String() string

func (*Entry) UID

func (e *Entry) UID() string

UID returns the unique identifier of the entry.

type Feed

type Feed struct {
	Client          *http.Client
	ChannelBaseURL  string
	PlaylistBaseURL string
}

Feed represents a YouTube channel feed.

func (*Feed) Get

func (c *Feed) Get(ctx context.Context, id string, feedType Type) ([]Entry, error)

Get xml/rss feed for channel https://www.youtube.com/feeds/videos.xml?channel_id=UCPU28A9z_ka_R5dQfecHJlA

type Type

type Type string

Type represents the type of YouTube feed.

Jump to

Keyboard shortcuts

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