Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) Download(cx context.Context, info *VideoInfo, format *Format, dest io.Writer) error
- func (c *Client) GetDownloadURL(cx context.Context, info *VideoInfo, format *Format) (*url.URL, error)
- func (c *Client) GetVideoInfo(cx context.Context, value interface{}) (*VideoInfo, error)
- func (c *Client) GetVideoInfoFromID(cx context.Context, id string) (*VideoInfo, error)
- type Format
- type FormatKey
- type FormatList
- func (formats FormatList) Best(key FormatKey) FormatList
- func (formats FormatList) Copy() FormatList
- func (formats FormatList) Extremes(key FormatKey, best bool) FormatList
- func (formats FormatList) Filter(key FormatKey, values []interface{}) FormatList
- func (formats FormatList) Sort(key FormatKey, reverse bool)
- func (formats FormatList) Subtract(other FormatList) FormatList
- func (formats FormatList) Worst(key FormatKey) FormatList
- type Itag
- type Range
- type ThumbnailQuality
- type VideoInfo
Constants ¶
This section is empty.
Variables ¶
var DefaultClient = &Client{ HTTPClient: http.DefaultClient, Logger: zerolog.Nop(), }
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.3
func (*Client) Download ¶ added in v0.6.3
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.3
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.3
GetVideoInfo fetches info from a url string, url object, or a url string
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 (*Format) ValueForKey ¶ added in v0.4.0
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.2
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 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
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