ytdl

package
v0.0.0-...-1a76b75 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: MIT, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = &Client{
	HTTPClient: http.DefaultClient,
}
View Source
var ITAGS = generateItags()

ITAGS is a map of all itags and their attributes

Functions

This section is empty.

Types

type AdaptiveStream

type AdaptiveStream struct {
	Index    *Range
	Init     *Range
	MimeType string
	Codecs   string
	Bitrate  int

	// Video stream specific
	Width     int
	Height    int
	FrameRate string

	// Audio stream specific
	AudioSamplingRate string
	AudioChannels     int
}

Type AdaptiveStream represents an adaptive stream

type Client

type Client struct {
	HTTPClient *http.Client
}

func (*Client) Download

func (c *Client) Download(cx context.Context, info *VideoInfo, format *Format, dest io.Writer) error

Download is a convenience method to download a format to an io.Writer

func (*Client) GetDownloadURL

func (c *Client) GetDownloadURL(cx context.Context, info *VideoInfo, format *Format) (*url.URL, error)

GetDownloadURL gets the download url for a format

func (*Client) GetVideoInfo

func (c *Client) GetVideoInfo(cx context.Context, value interface{}) (*VideoInfo, error)

GetVideoInfo fetches info from a url string, url object, or a url string

func (*Client) GetVideoInfoFromID

func (c *Client) GetVideoInfoFromID(cx context.Context, id string) (*VideoInfo, error)

GetVideoInfoFromID fetches video info from a youtube video id

type Content

type Content struct {
	SimpleText *string `json:"simpleText,omitempty"`

	Lines []struct {
		Text string `json:"text,omitempty"`
	} `json:"runs"`
}

func (*Content) String

func (c *Content) String() string

type Format

type Format struct {
	Itag
	Adaptive       bool
	AdaptiveStream *AdaptiveStream
	// FromDASH indicates that the stream
	// was extracted from the DASH manifest file
	FromDASH bool
	// contains filtered or unexported fields
}

func (*Format) CompareKey

func (f *Format) CompareKey(other *Format, key FormatKey) int

func (*Format) ValueForKey

func (f *Format) ValueForKey(key FormatKey) interface{}

ValueForKey gets the format value for a format key, used for filtering

type FormatKey

type FormatKey string

FormatKey is a string type containing a key in a video format map

const (
	FormatExtensionKey     FormatKey = "ext"
	FormatResolutionKey    FormatKey = "res"
	FormatVideoEncodingKey FormatKey = "videnc"
	FormatAudioEncodingKey FormatKey = "audenc"
	FormatItagKey          FormatKey = "itag"
	FormatAudioBitrateKey  FormatKey = "audbr"
	FormatFPSKey           FormatKey = "fps"
)

Available format Keys

type FormatList

type FormatList []*Format

FormatList is a slice of formats with filtering functionality

func (FormatList) Best

func (formats FormatList) Best(key FormatKey) FormatList

func (FormatList) Copy

func (formats FormatList) Copy() FormatList

func (FormatList) Extremes

func (formats FormatList) Extremes(key FormatKey, best bool) FormatList

func (FormatList) Filter

func (formats FormatList) Filter(key FormatKey, values []interface{}) FormatList

func (FormatList) Sort

func (formats FormatList) Sort(key FormatKey, reverse bool)

func (FormatList) Subtract

func (formats FormatList) Subtract(other FormatList) FormatList

func (FormatList) Worst

func (formats FormatList) Worst(key FormatKey) FormatList

type Itag

type Itag struct {
	Number        int
	Extension     string
	Resolution    string
	VideoEncoding string
	AudioEncoding string
	AudioBitrate  int
	FPS           int // FPS are frames per second
}

Itag is a youtube is a static youtube video format

type MetadataRows

type MetadataRows []struct {
	MetadataRowRenderer struct {
		Title    Content   `json:"title"`
		Contents []Content `json:"contents"`
	} `json:"metadataRowRenderer,omitempty"`
}

func (MetadataRows) Get

func (rows MetadataRows) Get(title string) string

type Range

type Range struct {
	Start string `json:"start"`
	End   string `json:"end"`
}

func (*Range) String

func (r *Range) String() string

type ThumbnailQuality

type ThumbnailQuality string

ThumbnailQuality is a youtube thumbnail quality option

const ThumbnailQualityDefault ThumbnailQuality = "default"

ThumbnailQualityDefault is the default quality thumbnail jpg

const ThumbnailQualityHigh ThumbnailQuality = "hqdefault"

ThumbnailQualityHigh is the high quality thumbnail jpg

const ThumbnailQualityMaxRes ThumbnailQuality = "maxresdefault"

ThumbnailQualityMaxRes is the maximum resolution quality jpg

const ThumbnailQualityMedium ThumbnailQuality = "mqdefault"

ThumbnailQualityMedium is the medium quality thumbnail jpg

const ThumbnailQualitySD ThumbnailQuality = "sddefault"

ThumbnailQualitySD is the standard def quality thumbnail jpg

type VideoInfo

type VideoInfo struct {
	ID              string     // The video ID
	Title           string     // The video title
	Description     string     // The video description
	DatePublished   time.Time  // The date the video was published
	Formats         FormatList // Formats the video is available in
	DASHManifestURL string     // URI of the DASH manifest file
	HLSManifestURL  string     // URI of the HLS manifest file
	Keywords        []string   // List of keywords associated with the video
	Uploader        string     // Author of the video
	Song            string
	Artist          string
	Album           string
	Writers         string
	Duration        time.Duration // Duration of the video
	// contains filtered or unexported fields
}

VideoInfo contains the info a youtube video

func GetVideoInfo

func GetVideoInfo(cx context.Context, value interface{}) (*VideoInfo, error)

GetVideoInfo fetches info from a url string, url object, or a url string

func (*VideoInfo) GetThumbnailURL

func (info *VideoInfo) GetThumbnailURL(quality ThumbnailQuality) *url.URL

GetThumbnailURL returns a url for the thumbnail image with the given quality

Jump to

Keyboard shortcuts

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