yet_urls
yet_urls extracts a single video stream URL ("the best" quality one) from a YouTube video page. This module has the following exported methods:
WatchUrl
func WatchUrl(videoId string) *url.URL
WatchUrl
provides a URL for a video-id, e.g. http://www.youtube.com/watch?v=video-id1 for "video-id1".
BestStreamingUrl
func BestStreamingUrl(videoId string) (*url.URL, error)
BestStreamingUrl
extracts the URL for "the best" streaming format for a given YouTube video-id.
Here are the key steps to make that happen:
- convert video-id to a full YouTube.com/watch URL
- request page content at that URL
- parse response as HTML document and find required node (
iprScriptTextContent
contains selection criteria)
- decode
ytInitialPlayerResponse
object (to a minimal data struct)
- select "the best" streaming format available (
bestFormatByBitrate
contains selection criteria)
- return URL for that format