Documentation
¶
Overview ¶
Package vimego: Search, download Vimeo videos and retrieve metadata.
Index ¶
- Constants
- Variables
- type ChannelItem
- type DashAudioStream
- type DashAudioStreams
- type DashFormat
- type DashSegment
- type DashStream
- type DashStreams
- type DashVideoStream
- type DashVideoStreams
- type ErrUnexpectedStatusCode
- type GroupItem
- type HlsFormat
- type Metadata
- type PeopleItem
- type PictureSize
- type ProgressiveFormat
- type ProgressiveFormats
- type SearchCategory
- type SearchClient
- type SearchData
- type SearchFilter
- type SearchResult
- type SortDirection
- type SortOrder
- type Video
- type VideoFormats
- type VideoItem
Constants ¶
const UserAgent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0"
Variables ¶
var ( ErrInvalidUrl = errors.New("the URL is invalid") ErrParsingFailed = errors.New("couldn't get config") )
Functions ¶
This section is empty.
Types ¶
type ChannelItem ¶
type ChannelItem struct { Name string `json:"name"` Link string `json:"link"` Pictures struct { Sizes []PictureSize `json:"sizes"` } `json:"pictures"` Metadata struct { Connections struct { Users struct { Total int `json:"total"` } `json:"users"` Videos struct { Total int `json:"total"` } `json:"videos"` } `json:"connections"` } `json:"metadata"` }
type DashAudioStream ¶
type DashAudioStream struct { Channels int `json:"channels"` SampleRate int `json:"sample_rate"` DashStream }
type DashAudioStreams ¶
type DashAudioStreams []*DashAudioStream
func (DashAudioStreams) Best ¶
func (d DashAudioStreams) Best() *DashAudioStream
Best returns the DashAudioStream with the highest bitrate.
func (DashAudioStreams) Len ¶
func (d DashAudioStreams) Len() int
func (DashAudioStreams) Less ¶
func (d DashAudioStreams) Less(a, b int) bool
func (DashAudioStreams) Swap ¶
func (d DashAudioStreams) Swap(a, b int)
func (DashAudioStreams) Worst ¶
func (d DashAudioStreams) Worst() *DashAudioStream
Worst returns the DashAudioStream with the lowest bitrate.
type DashFormat ¶
type DashFormat struct { SeparateAv bool `json:"separate_av"` DefaultCdn string `json:"default_cdn"` Cdns struct { AkfireInterconnectQuic struct { URL string `json:"url"` Origin string `json:"origin"` AvcURL string `json:"avc_url"` } `json:"akfire_interconnect_quic"` FastlySkyfire struct { URL string `json:"url"` Origin string `json:"origin"` AvcURL string `json:"avc_url"` } `json:"fastly_skyfire"` } `json:"cdns"` }
func (*DashFormat) Url ¶
func (s *DashFormat) Url() string
Url returns the URL for the video stream.
type DashSegment ¶
type DashStream ¶
type DashStream struct { ID string `json:"id"` URL string `json:"url"` BaseURL string `json:"base_url"` Format string `json:"format"` MimeType string `json:"mime_type"` Codecs string `json:"codecs"` Bitrate int `json:"bitrate"` AvgBitrate int `json:"avg_bitrate"` Duration float64 `json:"duration"` MaxSegmentDuration int `json:"max_segment_duration"` InitSegment string `json:"init_segment"` Segments []*DashSegment `json:"segments"` }
func (*DashStream) Reader ¶
func (s *DashStream) Reader(httpClient *http.Client) (io.ReadCloser, int64, error)
Readers returns an io.ReadCloser for reading streaming data.
type DashStreams ¶
type DashStreams struct { ClipID string `json:"clip_id"` BaseURL string `json:"base_url"` Video DashVideoStreams `json:"video"` Audio DashAudioStreams `json:"audio"` }
type DashVideoStream ¶
type DashVideoStream struct { Framerate float64 `json:"framerate"` Width int `json:"width"` Height int `json:"height"` DashStream }
type DashVideoStreams ¶
type DashVideoStreams []*DashVideoStream
func (DashVideoStreams) Best ¶
func (d DashVideoStreams) Best() *DashVideoStream
Best returns the DashVideoStream with the highest bitrate.
func (DashVideoStreams) Len ¶
func (d DashVideoStreams) Len() int
func (DashVideoStreams) Less ¶
func (d DashVideoStreams) Less(a, b int) bool
func (DashVideoStreams) Swap ¶
func (d DashVideoStreams) Swap(a, b int)
func (DashVideoStreams) Worst ¶
func (d DashVideoStreams) Worst() *DashVideoStream
Worst returns the DashVideoStream with the lowest bitrate.
type ErrUnexpectedStatusCode ¶
type ErrUnexpectedStatusCode int
func (ErrUnexpectedStatusCode) Error ¶
func (err ErrUnexpectedStatusCode) Error() string
type GroupItem ¶
type GroupItem struct { Name string `json:"name"` Link string `json:"link"` Pictures struct { Sizes []PictureSize `json:"sizes"` } `json:"pictures"` Metadata struct { Connections struct { Users struct { Total int `json:"total"` } `json:"users"` Videos struct { Total int `json:"total"` } `json:"videos"` } `json:"connections"` } `json:"metadata"` }
type HlsFormat ¶
type HlsFormat struct { SeparateAv bool `json:"separate_av"` DefaultCdn string `json:"default_cdn"` Cdns struct { AkfireInterconnectQuic struct { URL string `json:"url"` Origin string `json:"origin"` AvcURL string `json:"avc_url"` } `json:"akfire_interconnect_quic"` FastlySkyfire struct { URL string `json:"url"` Origin string `json:"origin"` AvcURL string `json:"avc_url"` } `json:"fastly_skyfire"` } `json:"cdns"` }
type Metadata ¶
type Metadata struct { ID int `json:"id"` Title string `json:"title"` Description string `json:"description"` URL string `json:"url"` UploadDate string `json:"upload_date"` ThumbnailSmall string `json:"thumbnail_small"` ThumbnailMedium string `json:"thumbnail_medium"` ThumbnailLarge string `json:"thumbnail_large"` UserID int `json:"user_id"` UserName string `json:"user_name"` UserURL string `json:"user_url"` UserPortraitSmall string `json:"user_portrait_small"` UserPortraitMedium string `json:"user_portrait_medium"` UserPortraitLarge string `json:"user_portrait_large"` UserPortraitHuge string `json:"user_portrait_huge"` Likes int `json:"stats_number_of_likes"` Plays int `json:"stats_number_of_plays"` Comments int `json:"stats_number_of_comments"` Duration int `json:"duration"` Width int `json:"width"` Height int `json:"height"` Tags string `json:"tags"` EmbedPrivacy string `json:"embed_privacy"` }
type PeopleItem ¶
type PeopleItem struct { Name string `json:"name"` Link string `json:"link"` Location string `json:"location"` Pictures struct { Sizes []PictureSize `json:"sizes"` } `json:"pictures"` Metadata struct { Connections struct { Followers struct { Total int `json:"total"` } `json:"followers"` Videos struct { Total int `json:"total"` } `json:"videos"` } `json:"connections"` } `json:"badge"` }
type PictureSize ¶
type ProgressiveFormat ¶
type ProgressiveFormats ¶
type ProgressiveFormats []*ProgressiveFormat
func (ProgressiveFormats) Best ¶
func (p ProgressiveFormats) Best() *ProgressiveFormat
Best returns the ProgressiveFormat with the hightest resolution.
func (ProgressiveFormats) Len ¶
func (p ProgressiveFormats) Len() int
func (ProgressiveFormats) Less ¶
func (p ProgressiveFormats) Less(a, b int) bool
func (ProgressiveFormats) Swap ¶
func (p ProgressiveFormats) Swap(a, b int)
func (ProgressiveFormats) Worst ¶
func (p ProgressiveFormats) Worst() *ProgressiveFormat
Worst returns the ProgressiveFormat with the lowest resolution.
type SearchCategory ¶
type SearchCategory string
const ( AnyCategory SearchCategory = "" TrailersCategory SearchCategory = "trailers" NarrativeCategory SearchCategory = "narrative" DocumentaryCategory SearchCategory = "documentary" ExperimentalCategory SearchCategory = "experimental" AnimationCategory SearchCategory = "animation" EducationalCategory SearchCategory = "educational" AdsAndCommercialsCategory SearchCategory = "adsandcommercials" MusicCategory SearchCategory = "music" BrandedContentCategory SearchCategory = "brandedcontent" SportsCategory SearchCategory = "sports" TravelCategory SearchCategory = "travel" CameraTechniquesCategory SearchCategory = "cameratechniques" ComedyCategory SearchCategory = "comedy" EventsCategory SearchCategory = "events" FashionCategory SearchCategory = "fashion" FoodCategory SearchCategory = "food" IdentsAndAnimatedLogosCategory SearchCategory = "identsandanimatedlogos" IndustryCategory SearchCategory = "industry" IndustrionalsCategory SearchCategory = "instructionals" JournalismCategory SearchCategory = "journalism" PersonalCategory SearchCategory = "personal" ProductCategory SearchCategory = "product" TalksCategory SearchCategory = "talks" TitleAndCreditsCategory SearchCategory = "titlesandcredits" VideoSchoolCategory SearchCategory = "videoschool" WeedingCategory SearchCategory = "wedding" )
type SearchClient ¶
type SearchClient struct { PerPage int Filter SearchFilter Order SortOrder Direction SortDirection Category SearchCategory Header map[string][]string HTTPClient *http.Client // contains filtered or unexported fields }
func NewSearchClient ¶
func NewSearchClient() *SearchClient
NewSearchClient creates a new SearchClient with default parameters.
func (*SearchClient) Search ¶
func (c *SearchClient) Search(query string, page int) (*SearchResult, error)
Search returns the result from the requested page.
type SearchData ¶
type SearchData []struct { Type string `json:"type"` Video *VideoItem `json:"clip,omitempty"` People *PeopleItem `json:"people,omitempty"` Channel *ChannelItem `json:"channel,omitempty"` Group *GroupItem `json:"group,omitempty"` }
func (SearchData) Channels ¶
func (d SearchData) Channels() []*ChannelItem
func (SearchData) Groups ¶
func (d SearchData) Groups() []*GroupItem
func (SearchData) People ¶
func (d SearchData) People() []*PeopleItem
func (SearchData) Videos ¶
func (d SearchData) Videos() []*VideoItem
type SearchFilter ¶
type SearchFilter string
const ( VideoFilter SearchFilter = "clip" PeopleFilter SearchFilter = "people" ChannelFilter SearchFilter = "channel" GroupFilter SearchFilter = "group" )
type SearchResult ¶
type SearchResult struct { Total int `json:"total"` Page int `json:"page"` PerPage int `json:"per_page"` Data SearchData `json:"data"` }
type SortDirection ¶
type SortDirection string
const ( AscDirection SortDirection = "asc" DescDirection SortDirection = "desc" )
type Video ¶
func NewVideoFromId ¶
NewVideo creates a new Video from video ID.
func (*Video) Formats ¶
func (v *Video) Formats() (*VideoFormats, error)
Formats returns the video formats. Progressive formats contain direct video+audio streams up to 1080p. Hls format contains an URL to .m3u8 playlist with all possible streams. Dash format contains a JSON URL that can be parsed using GetDashStreams.
func (*Video) GetDashStreams ¶
func (v *Video) GetDashStreams(dashUrl string) (*DashStreams, error)
GetDashStreams returns DASH streams of the video.
type VideoFormats ¶
type VideoFormats struct { Progressive ProgressiveFormats `json:"progressive"` Dash *DashFormat `json:"dash"` Hls *HlsFormat `json:"hls"` }
type VideoItem ¶
type VideoItem struct { Name string `json:"name"` Link string `json:"link"` Duration int `json:"duration"` CreatedTime time.Time `json:"created_time"` Privacy struct { View string `json:"view"` } `json:"privacy"` Pictures struct { Sizes []PictureSize `json:"sizes"` } `json:"pictures"` Metadata struct { Connections struct { Comments struct { Total int `json:"total"` } `json:"comments"` Likes struct { Total int `json:"total"` } `json:"likes"` } `json:"connections"` } `json:"metadata"` User struct { Name string `json:"name"` Link string `json:"link"` Location string `json:"location"` Pictures struct { Sizes []PictureSize `json:"sizes"` } `json:"pictures"` } `json:"user"` }