Documentation
¶
Index ¶
- type CompactVideoRenderer
- func (cr *CompactVideoRenderer) GetChannel() string
- func (cr *CompactVideoRenderer) GetDuration() string
- func (cr *CompactVideoRenderer) GetPublishTime() string
- func (cr *CompactVideoRenderer) GetThumbnails() []Thumbnails
- func (cr *CompactVideoRenderer) GetTitle() string
- func (cr *CompactVideoRenderer) GetUrl() string
- func (cr *CompactVideoRenderer) GetUrlSuffix() string
- func (cr *CompactVideoRenderer) GetUrlThumbnail() string
- func (cr *CompactVideoRenderer) GetViews() string
- type Description
- type GoTube
- type LengthText
- type LongBylineText
- type NavigationEndpoint
- type Owner
- type PublishedTimeText
- type SearchOptions
- type SimpleText
- type Thumbnail
- type Thumbnails
- type Title
- type VideoActions
- type VideoData
- func (vd *VideoData) GetChannel() string
- func (vd *VideoData) GetDescription() string
- func (vd *VideoData) GetDuration() string
- func (vd *VideoData) GetLikeCount() string
- func (vd *VideoData) GetPublishTime() string
- func (vd *VideoData) GetRelativeDate() string
- func (vd *VideoData) GetShortView() string
- func (vd *VideoData) GetSubscriberCount() string
- func (vd *VideoData) GetTitle() string
- func (vd *VideoData) GetUrl() string
- func (vd *VideoData) GetUrlSuffix() string
- func (vd *VideoData) GetUrlThumbnail() string
- func (vd *VideoData) GetViews() string
- func (vd *VideoData) ID() string
- type VideoPrimaryInfoRenderer
- type VideoSecondaryInfoRenderer
- type ViewCount
- type ViewCountText
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompactVideoRenderer ¶
type CompactVideoRenderer struct {
ID string `json:"videoId"`
Thumbnail Thumbnail `json:"thumbnail"`
Title Title `json:"title"`
LongBylineText LongBylineText `json:"longBylineText"`
PublishedTimeText PublishedTimeText `json:"publishedTimeText"`
LengthText LengthText `json:"lengthText"`
ViewCountText ViewCountText `json:"viewCountText"`
}
CompactVideoRenderer contains summary information for a video.
func ParseHtmlSearch ¶
func ParseHtmlSearch(response []byte, limit int) ([]CompactVideoRenderer, error)
ParseHtmlSearch extracts video data from the parsed JSON response. It takes the HTML response and a limit for the number of videos to extract.
func (*CompactVideoRenderer) GetChannel ¶
func (cr *CompactVideoRenderer) GetChannel() string
GetChannel returns the name of the channel.
func (*CompactVideoRenderer) GetDuration ¶
func (cr *CompactVideoRenderer) GetDuration() string
GetDuration extracts the video duration.
func (*CompactVideoRenderer) GetPublishTime ¶
func (cr *CompactVideoRenderer) GetPublishTime() string
GetPublishTime extracts the video publish time.
func (*CompactVideoRenderer) GetThumbnails ¶
func (cr *CompactVideoRenderer) GetThumbnails() []Thumbnails
GetThumbnails retrieves the list of all thumbnail information for the video.
func (*CompactVideoRenderer) GetTitle ¶
func (cr *CompactVideoRenderer) GetTitle() string
GetTitle returns the title of the video.
func (*CompactVideoRenderer) GetUrl ¶
func (cr *CompactVideoRenderer) GetUrl() string
GetUrl constructs the full URL for the video.
func (*CompactVideoRenderer) GetUrlSuffix ¶
func (cr *CompactVideoRenderer) GetUrlSuffix() string
GetUrlSuffix extracts the video URL suffix.
func (*CompactVideoRenderer) GetUrlThumbnail ¶
func (cr *CompactVideoRenderer) GetUrlThumbnail() string
GetThumbnail retrieves the first thumbnail URL from the list of thumbnails associated with the video.
func (*CompactVideoRenderer) GetViews ¶
func (cr *CompactVideoRenderer) GetViews() string
GetViews extracts the video view count.
type Description ¶
type Description struct {
Content string `json:"content"`
}
Description represents a description structure.
type GoTube ¶
type GoTube struct {
// contains filtered or unexported fields
}
GoTube is a wrapper structure to manage default context and timeout for requests.
func NewGoTube ¶
func NewGoTube() *GoTube
NewGoTube creates a new instance of GoTube with a default timeout.
func (GoTube) GetInfoVideo ¶
GetInfoVideo retrieves video information from a given YouTube video URL. It sends an HTTP GET request to the URL, parses the HTML response, and returns a VideoData struct containing the video's information. Note: This function relies on the HTML structure of the YouTube video page. Changes to YouTube's HTML may break this function. Error handling is implemented for network requests, but not for parsing errors within ParseHtmlInfoVideo. Consider adding more robust error handling in the future.
func (GoTube) Search ¶
func (gt GoTube) Search(opt *SearchOptions) ([]CompactVideoRenderer, error)
Search performs a YouTube search using the provided options. It constructs the search URL, sends an HTTP GET request, and prints the raw response body. Note: This function currently doesn't handle pagination or result parsing, it only retrieves the raw HTML.
type LengthText ¶
type LengthText struct {
Accessibility struct {
AccessibilityData struct {
Label string `json:"label"`
} `json:"accessibilityData"`
} `json:"accessibility"`
SimpleText string `json:"simpleText"`
}
LengthText represents the video length, including accessibility information.
type LongBylineText ¶
type LongBylineText struct {
Runs []struct {
Text string `json:"text"`
} `json:"runs"`
}
LongBylineText represents the long channel name or description, including navigation details.
type NavigationEndpoint ¶
type NavigationEndpoint struct {
WebCommandMetadata struct {
Url string `json:"url"`
} `json:"webCommandMetadata"`
} `json:"commandMetadata"`
}
NavigationEndpoint represents the navigation endpoint for the video.
type Owner ¶
type Owner struct {
VideoOwnerRenderer struct {
Title struct {
Runs [1]struct {
Text string `json:"text"`
} `json:"runs"`
} `json:"title"`
SubscriberCountText SimpleText `json:"subscriberCountText"`
} `json:"videoOwnerRenderer"`
}
Owner represents the owner of a video.
type PublishedTimeText ¶
type PublishedTimeText struct {
SimpleText string `json:"simpleText"`
}
PublishedTimeText represents the simple text for the video's publish date.
type SearchOptions ¶
type SearchOptions struct {
SearchTerms string // Search query string
Limit int // Maximum number of results to retrieve
}
OptionsSearch defines the options for a YouTube search query.
type SimpleText ¶
type SimpleText struct {
SimpleText string `json:"simpleText"`
}
SimpleText represents a simple text structure.
type Thumbnail ¶
type Thumbnail struct {
Thumbnails []Thumbnails `json:"thumbnails"`
}
Thumbnail represents thumbnail information for a video. Contains an array of thumbnail URLs with dimensions.
type Thumbnails ¶
type Thumbnails struct {
URL string `json:"url"`
Width int `json:"width"`
Height int `json:"height"`
}
Thumbnail represents thumbnail information for a video. Contains an array of thumbnail URLs with dimensions.
type Title ¶
type Title struct {
Runs []struct {
Text string `json:"text"`
} `json:"runs"`
Accessibility struct {
AccessibilityData struct {
Label string `json:"label"`
} `json:"accessibilityData"`
} `json:"accessibility"`
}
Title represents the title of a video, including accessibility information.
type VideoActions ¶
type VideoActions struct {
MenuRenderer struct {
TopLevelButtons []struct {
SegmentedLikeDislikeButtonViewModel struct {
LikeButtonViewModel struct {
LikeButtonViewModel struct {
ToggleButtonViewModel struct {
ToggleButtonViewModel struct {
DefaultButtonViewModel struct {
ButtonViewModel struct {
Title string `json:"title"`
} `json:"buttonViewModel"`
} `json:"defaultButtonViewModel"`
} `json:"toggleButtonViewModel"`
} `json:"toggleButtonViewModel"`
} `json:"likeButtonViewModel"`
} `json:"likeButtonViewModel"`
} `json:"segmentedLikeDislikeButtonViewModel"`
} `json:"topLevelButtons"`
} `json:"menuRenderer"`
}
VideoActions represents the actions available for a video.
type VideoData ¶
type VideoData struct {
CompactVideoRenderer *CompactVideoRenderer `json:"compactVideoRenderer,omitempty"`
VideoPrimaryInfoRenderer *VideoPrimaryInfoRenderer `json:"videoPrimaryInfoRenderer,omitempty"`
VideoSecondaryInfoRenderer *VideoSecondaryInfoRenderer `json:"videoSecondaryInfoRenderer,omitempty"`
}
VideoData holds detailed video information.
func ParseHtmlInfoVidoe ¶
ParseHtmlInfoVideo extracts detailed video information from the parsed JSON response. It takes the HTML response and returns a VideoData struct containing the video's information.
func (*VideoData) GetChannel ¶
GetChannel returns the name of the channel.
func (*VideoData) GetDescription ¶
GetDescription extracts the video description.
func (*VideoData) GetDuration ¶
GetDuration extracts the video duration.
func (*VideoData) GetLikeCount ¶
GetLikeCount extracts the video like count.
func (*VideoData) GetPublishTime ¶
GetPublishTime extracts the video publish time.
func (*VideoData) GetRelativeDate ¶
GetRelativeDate extracts the video relative date.
func (*VideoData) GetShortView ¶
GetShortView extracts the video short view count.
func (*VideoData) GetSubscriberCount ¶
GetDislikeCount extracts the video dislike count.
func (*VideoData) GetUrlSuffix ¶
GetUrlSuffix extracts the video URL suffix.
func (*VideoData) GetUrlThumbnail ¶
GetThumbnail retrieves the first thumbnail URL from the list of thumbnails associated with the video.
type VideoPrimaryInfoRenderer ¶
type VideoPrimaryInfoRenderer struct {
Title Title `json:"title"`
ViewCount ViewCount `json:"viewCount"`
VideoActions VideoActions `json:"videoActions"`
DateText SimpleText `json:"dateText"`
RelativeDateText SimpleText `json:"relativeDateText"`
}
VideoPrimaryInfoRenderer holds primary information about a video.
type VideoSecondaryInfoRenderer ¶
type VideoSecondaryInfoRenderer struct {
Owner Owner `json:"owner"`
AttributedDescription Description `json:"attributedDescription"`
}
VideoSecondaryInfoRenderer holds secondary information about a video.
type ViewCount ¶
type ViewCount struct {
VideoViewCountRenderer struct {
ViewCount SimpleText `json:"viewCount"`
ShortViewCount SimpleText `json:"shortViewCount"`
} `json:"videoViewCountRenderer"`
}
ViewCount represents the view count of a video.
type ViewCountText ¶
type ViewCountText struct {
SimpleText string `json:"simpleText"`
}
ViewCountText represents the simple text for the video's view count.