ytdl

package
v0.0.0-...-7e99c83 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WithStandardOutput = func() Option {
		return func(commands *[]string) {
			*commands = append(*commands, "-o", "-")
		}
	}

	WithVerbose = func() Option {
		return func(commands *[]string) {
			*commands = append(*commands, "-v")
		}
	}

	WithTemplate = func(t Template) Option {
		return func(commands *[]string) {
			*commands = append(*commands, "--print", t.String())
		}
	}

	WithFormat = func(f Format) Option {
		return func(commands *[]string) {
			*commands = append(*commands, "-f", f.String())
		}
	}
)
View Source
var ErrIvalidURLFormat = errors.New("invalid url format")

Functions

func ExtractURL

func ExtractURL(url string) (string, error)

Types

type Config

type Config struct {
	Alias string `required:"true"`
}

type DL

type DL interface {
	GetAudioStream(url string, opts ...Option) (Stream, error)
	GetVideoAttributes(url string, opts ...Option) (VideoAttributes, error)
}

func NewDL

func NewDL(cfg Config) DL

type Duration

type Duration time.Duration

func (*Duration) String

func (d *Duration) String() string

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

type Format

type Format string

Format see more format https://github.com/yt-dlp/yt-dlp?tab=readme-ov-file#format-selection

const (
	// BestVideoFormat select the best quality format containing the video
	BestVideoFormat Format = "bestvideo"

	// BestAudioFormat select the best quality format containing audio
	BestAudioFormat Format = "bestaudio"
)

func (Format) String

func (f Format) String() string

type Option

type Option func(commands *[]string)

type Stream

type Stream interface {
	GetOutput() (io.ReadCloser, error)
	Start() error
	Cancel() error
	Wait() error
}

type Template

type Template string
const (
	VideoAttributesTemplate Template = `{
	"id": %(id)j,
	"title": %(title)j,
	"webpage_url": %(webpage_url)j,
	"duration": "%(duration)j"
}`
)

func (Template) String

func (t Template) String() string

type VideoAttributes

type VideoAttributes struct {
	ID         string   `json:"id"`
	Title      string   `json:"title"`
	WebpageURL string   `json:"webpage_url"`
	Duration   Duration `json:"duration"`
	StartTime  Duration `json:"start_time"`
}

func (*VideoAttributes) DurationToString

func (a *VideoAttributes) DurationToString() string

Jump to

Keyboard shortcuts

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