ytdl

package module
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2020 License: MIT Imports: 17 Imported by: 0

README

Deprecation Notice

This project is not maintained any more. Please switch to https://github.com/kkdai/youtube

Documentation

Index

Constants

This section is empty.

Variables

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

ITAGS is a map of all itags and their attributes

Functions

This section is empty.

Types

type Client added in v0.6.5

type Client struct {
	Logger     zerolog.Logger
	HTTPClient *http.Client
}

func (*Client) Download added in v0.6.5

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 added in v0.6.5

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 added in v0.6.5

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 added in v0.6.5

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

GetVideoInfoFromID fetches video info from a youtube video id

type Format

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

func (*Format) CompareKey added in v0.5.0

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

func (*Format) ValueForKey added in v0.4.0

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 added in v0.5.0

type FormatList []*Format

FormatList is a slice of formats with filtering functionality

func (FormatList) Best added in v0.5.0

func (formats FormatList) Best(key FormatKey) FormatList

func (FormatList) Copy added in v0.5.0

func (formats FormatList) Copy() FormatList

func (FormatList) Extremes added in v0.5.0

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

func (FormatList) Filter added in v0.5.0

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

func (FormatList) Sort added in v0.5.0

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

func (FormatList) Subtract added in v0.5.0

func (formats FormatList) Subtract(other FormatList) FormatList

func (FormatList) Worst added in v0.5.0

func (formats FormatList) Worst(key FormatKey) FormatList

type Itag added in v0.6.5

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 Range added in v0.6.5

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

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 added in v0.3.0

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 added in v0.3.0

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 added in v0.3.0

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

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

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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