Documentation ¶
Index ¶
- type AudioStream
- func (stream *AudioStream) Download(destdir, filename string, overwrite bool, onStart func(total int64), ...) (path string, err error)
- func (stream *AudioStream) GetDownloadURL() (string, error)
- func (stream *AudioStream) Itag() int
- func (stream *AudioStream) Metadata() map[string]interface{}
- func (stream *AudioStream) Name() string
- func (stream *AudioStream) ParentVideo() *Video
- func (stream *AudioStream) Subtype() string
- func (stream *AudioStream) Type() string
- type AudioStreams
- type Caption
- type Captions
- type Error
- type Stream
- type Streams
- func (streams Streams) Audios() (audioStreams AudioStreams)
- func (streams Streams) Filter(f func(int, Stream) bool) (results Streams)
- func (streams Streams) First() Stream
- func (streams Streams) Itag(itag int) Stream
- func (streams Streams) Last() Stream
- func (streams Streams) Sort(less func(Stream, Stream) bool) (results Streams)
- func (streams Streams) Subtype(subtype string) Streams
- func (streams Streams) Videos() (videoStreams VideoStreams)
- type Video
- type VideoInfo
- type VideoStream
- func (stream *VideoStream) Download(destdir, filename string, overwrite bool, onStart func(total int64), ...) (path string, err error)
- func (stream *VideoStream) GetDownloadURL() (string, error)
- func (stream *VideoStream) Itag() int
- func (stream *VideoStream) Metadata() map[string]interface{}
- func (stream *VideoStream) Name() string
- func (stream *VideoStream) ParentVideo() *Video
- func (stream *VideoStream) Subtype() string
- func (stream *VideoStream) Type() string
- type VideoStreams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AudioStream ¶
type AudioStream struct { FileSize int64 `json:"file_size"` MimeType string `json:"mime_type"` Codec string `json:"codec"` Quality data.AudioQuality `json:"quality"` Bitrate int64 `json:"bitrate"` AverageBitrate int64 `json:"average_bitrate"` SampleRate int64 `json:"sample_rate"` Channels int `json:"channels"` Expiration time.Time `json:"expiration"` // contains filtered or unexported fields }
AudioStream represents a stream of type 'audio'.
func (*AudioStream) Download ¶
func (stream *AudioStream) Download(destdir, filename string, overwrite bool, onStart func(total int64), onProgress func(written int64)) (path string, err error)
Download downloads the content of this stream and saves it to a file in the local machine. If `destdir` is empty, it defaults to the current directory. If `filename` is empty, it defaults to the name of this stream (i.e. `Name()`). If `overwrite` is true, it will overwrite the existing file of the same filename, skip downloading otherwise. `onProgress` is called whenever `Write()` occurrs, with the total amount of written bytes provided as parameter.
func (*AudioStream) GetDownloadURL ¶
func (stream *AudioStream) GetDownloadURL() (string, error)
GetDownloadURL gets the decrypted URL to the direct source of this stream that can be used for downloading.
func (*AudioStream) Itag ¶
func (stream *AudioStream) Itag() int
Itag returns the itag of this stream.
func (*AudioStream) Metadata ¶
func (stream *AudioStream) Metadata() map[string]interface{}
Metadata returns a map consisting all the fields of this stream.
func (*AudioStream) Name ¶
func (stream *AudioStream) Name() string
Name returns the name of this stream.
func (*AudioStream) ParentVideo ¶
func (stream *AudioStream) ParentVideo() *Video
ParentVideo returns a pointer to the video object that this stream belongs to.
func (*AudioStream) Subtype ¶
func (stream *AudioStream) Subtype() string
Subtype returns the subtype (extension) gotten from mime type of this stream.
func (*AudioStream) Type ¶
func (stream *AudioStream) Type() string
Type returns the type of this stream. (audio)
type AudioStreams ¶
type AudioStreams []*AudioStream
AudioStreams represents a sequence of streams of type 'audio'.
func (AudioStreams) Best ¶
func (streams AudioStreams) Best() *AudioStream
Best returns the `AudioStream` object with the highest overall bitrate.
func (AudioStreams) First ¶
func (streams AudioStreams) First() *AudioStream
First returns the first `AudioStream` object in this `AudioStreams`.
func (AudioStreams) Last ¶
func (streams AudioStreams) Last() *AudioStream
Last returns the last `AudioStream` object in this `AudioStreams`.
func (AudioStreams) Worst ¶
func (streams AudioStreams) Worst() *AudioStream
Worst returns the `AudioStream` object with the lowest overall bitrate.
type Caption ¶
type Caption struct { URL string Name string LanguageCode string // contains filtered or unexported fields }
Caption represents a caption of a YouTube video.
func (*Caption) GetContent ¶
GetContent retrieves the content of this caption (most likely in xml format).
func (*Caption) GetWebVTT ¶
GetWebVTT first retrieves the content of this caption by calling `GetContent()` then converts and returns it in WebVTT format.
func (*Caption) Save ¶
Save downloads the content of this caption and saves it to a file in the local machine. If `destdir` is empty, it defaults to the current directory. If `filename` is empty, it defaults to the name of this caption. If `webvtt` is true, it saves the content in a WebVTT (.vtt) format file.
type Captions ¶
type Captions []*Caption
Captions represents a sequence of captions.
func (Captions) LanguageCode ¶
LanguageCode returns the `Caption` of the given language code.
type Stream ¶
type Stream interface { ParentVideo() *Video Type() string Subtype() string Name() string Itag() int Metadata() map[string]interface{} GetDownloadURL() (string, error) Download(destdir, filename string, overwrite bool, onStart func(int64), onProgress func(int64)) (string, error) }
Stream is an interface which is implemented by `VideoStream` and `AudioStream`.
type Streams ¶
type Streams []Stream
Streams represents a generic sequence of streams which can be of type 'video' or type 'audio'.
func (Streams) Audios ¶
func (streams Streams) Audios() (audioStreams AudioStreams)
Audios returns a `AudioStreams` (i.e. streams of type 'audio' only) from this `Streams`.
func (Streams) Filter ¶
Filter returns a filtered copy of this `Streams` according to the conditions of `f`. If `f` returns true, keep the stream, remove otherwise.
func (Streams) Sort ¶
Sort returns a sorted copy of this `Streams` according to the conditions of `less` (works the same with the sort package).
func (Streams) Videos ¶
func (streams Streams) Videos() (videoStreams VideoStreams)
Videos returns a `VideoStreams` (i.e. streams of type 'video' only) from this `Streams`.
type Video ¶
type Video struct { *VideoInfo ID string WatchURL string EmbedURL string IsAgeRestricted bool // contains filtered or unexported fields }
Video represents a YouTube video object, carrying the information, streams and captions of the video.
func NewVideo ¶
NewVideo returns a new video object of the given `idurl` (can be one of video id or video url). If `preinit` is true, all necessary HTTP requests will be done and data will be fetched on initialization. Otherwise, you will need to call `Initialize()` yourself before accessing any fields of this video object.
func (*Video) Initialize ¶
Initialize performs all necessary HTTP requests and descrambles the fetched data.
type VideoInfo ¶
type VideoInfo struct { Title string Description string Keywords []string Category string Duration int Views int AverageRating float64 Author string ThumbnailURL string IsAgeRestricted bool IsUnlisted bool }
VideoInfo carries information of a video.
type VideoStream ¶
type VideoStream struct { FileSize int64 `json:"file_size"` MimeType string `json:"mime_type"` VideoCodec string `json:"video_codec"` AudioCodec string `json:"audio_codec"` Bitrate int64 `json:"bitrate"` AverageBitrate int64 `json:"average_bitrate"` QualityLabel string `json:"quality_label"` Width int `json:"width"` Height int `json:"height"` HasAudio bool `json:"has_audio"` Expiration time.Time `json:"expiration"` // contains filtered or unexported fields }
VideoStream represents a stream of type 'video'.
func (*VideoStream) Download ¶
func (stream *VideoStream) Download(destdir, filename string, overwrite bool, onStart func(total int64), onProgress func(written int64)) (path string, err error)
Download downloads the content of this stream and saves it to a file in the local machine. If `destdir` is empty, it defaults to the current directory. If `filename` is empty, it defaults to the name of this stream (i.e. `Name()`). If `overwrite` is true, it will overwrite the existing file of the same filename, skip downloading otherwise. `onProgress` is called whenever `Write()` occurrs, with the total amount of written bytes provided as parameter.
func (*VideoStream) GetDownloadURL ¶
func (stream *VideoStream) GetDownloadURL() (string, error)
GetDownloadURL gets the decrypted URL to the direct source of this stream that can be used for downloading.
func (*VideoStream) Itag ¶
func (stream *VideoStream) Itag() int
Itag returns the itag of this stream.
func (*VideoStream) Metadata ¶
func (stream *VideoStream) Metadata() map[string]interface{}
Metadata returns a map consisting all the fields of this stream.
func (*VideoStream) Name ¶
func (stream *VideoStream) Name() string
Name returns the name of this stream.
func (*VideoStream) ParentVideo ¶
func (stream *VideoStream) ParentVideo() *Video
ParentVideo returns a pointer to the video object that this stream belongs to.
func (*VideoStream) Subtype ¶
func (stream *VideoStream) Subtype() string
Subtype returns the subtype (extension) gotten from mime type of this stream.
func (*VideoStream) Type ¶
func (stream *VideoStream) Type() string
Type returns the type of this stream. (video or video+audio)
type VideoStreams ¶
type VideoStreams []*VideoStream
VideoStreams represents a sequence of streams of type 'video' (can be with / without audio).
func (VideoStreams) Best ¶
func (streams VideoStreams) Best() *VideoStream
Best returns the `VideoStream` object with the highest resolution.
func (VideoStreams) First ¶
func (streams VideoStreams) First() *VideoStream
First returns the first `VideoStream` object in this `VideoStreams`.
func (VideoStreams) Last ¶
func (streams VideoStreams) Last() *VideoStream
Last returns the last `VideoStream` object in this `VideoStreams`.
func (VideoStreams) WithAudio ¶
func (streams VideoStreams) WithAudio() (videoStreams VideoStreams)
WithAudio returns a copy of `VideoStreams` containing only `VideoStream` objects that also has audio.
func (VideoStreams) Worst ¶
func (streams VideoStreams) Worst() *VideoStream
Worst returns the `VideoStream` object with the lowest resolution.