youtube

package
v1.36.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2021 License: OSL-3.0 Imports: 12 Imported by: 3

README

YouTube

Is maxres1 always available? No:

Is sd1 always available? No:

If hq1 always available? Yes:

http://i.ytimg.com/vi/hq2KgzKETBw/hq1.jpg

Clients

Need Android:

client MeJVWBSsPAY
Android pass
Embed fail
Mweb fail

Need Embed:

client QWlNyzzwgcc
Android fail
Embed pass
Mweb fail

Need Mweb:

client aN76CmldknI publishDate
Android fail
Embed fail
Mweb pass

Cover art

Device OAuth

How to get X-Goog-Api-Key

Make a request like this:

GET / HTTP/2
Host: www.youtube.com

in the response you should see something like this:

"INNERTUBE_API_KEY":"AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8"

https://cloud.google.com/apis/docs/system-parameters

How to get client_id and client_secret

Set User-Agent to [1]:

Mozilla/5.0 (ChromiumStylePlatform) Cobalt/Version

Then visit:

https://www.youtube.com/tv

Next open your browser menu, and click Web Developer, Network or similar. Then go back to the page, and click "Sign in", then "Sign in with a web browser". On the next page, dont bother with any of the instructions, just go back to Developer Tools, and after about five seconds you should see a JSON request like this:

POST /o/oauth2/token HTTP/1.1
Host: www.youtube.com

{"client_id":"861556708454-d6dlm3lh05idd8npek18k6be8ba3oc68.apps.googleusercontent.com",
"client_secret":"SboVhoG9s0rNafixCSGGKXAT",
"code":"AH-1Ng14qVvEj76OeM_h14Mgklgyhchbyc67MhULhCKPY6K-0DTYJqaKng2ULVFTmTzU...",
"grant_type":"http://oauth.net/grant_type/device/1.0"}
  1. https://github.com/youtube/cobalt/blob/master/src/cobalt/browser/user_agent_string.cc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Android = Client{Name: "ANDROID", Version: "16.05"}
	Embed   = Client{Name: "ANDROID", Screen: "EMBED", Version: "16.05"}
	Mweb    = Client{Name: "MWEB", Version: "2.19700101"}
)
View Source
var Key = Auth{"X-Goog-Api-Key", "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8"}
View Source
var Pictures = PictureSlice{
	{120, 90, 68, "default", jpg},
	{120, 90, 90, "1", jpg},
	{120, 90, 90, "2", jpg},
	{120, 90, 90, "3", jpg},
	{120, 90, 68, "default", webP},
	{120, 90, 90, "1", webP},
	{120, 90, 90, "2", webP},
	{120, 90, 90, "3", webP},
	{320, 180, 180, "mqdefault", jpg},
	{320, 180, 320, "mq1", jpg},
	{320, 180, 320, "mq2", jpg},
	{320, 180, 320, "mq3", jpg},
	{320, 180, 180, "mqdefault", webP},
	{320, 180, 320, "mq1", webP},
	{320, 180, 320, "mq2", webP},
	{320, 180, 320, "mq3", webP},
	{480, 360, 270, "0", jpg},
	{480, 360, 270, "hqdefault", jpg},
	{480, 360, 360, "hq1", jpg},
	{480, 360, 360, "hq2", jpg},
	{480, 360, 360, "hq3", jpg},
	{480, 360, 270, "0", webP},
	{480, 360, 270, "hqdefault", webP},
	{480, 360, 360, "hq1", webP},
	{480, 360, 360, "hq2", webP},
	{480, 360, 360, "hq3", webP},
	{640, 480, 360, "sddefault", jpg},
	{640, 480, 480, "sd1", jpg},
	{640, 480, 480, "sd2", jpg},
	{640, 480, 480, "sd3", jpg},
	{640, 480, 360, "sddefault", webP},
	{640, 480, 480, "sd1", webP},
	{640, 480, 480, "sd2", webP},
	{640, 480, 480, "sd3", webP},
	{1280, 720, 720, "hq720", jpg},
	{1280, 720, 720, "maxres1", jpg},
	{1280, 720, 720, "maxres2", jpg},
	{1280, 720, 720, "maxres3", jpg},
	{1280, 720, 720, "maxresdefault", jpg},
	{1280, 720, 720, "hq720", webP},
	{1280, 720, 720, "maxres1", webP},
	{1280, 720, 720, "maxres2", webP},
	{1280, 720, 720, "maxres3", webP},
	{1280, 720, 720, "maxresdefault", webP},
}
View Source
var Verbose = mech.Verbose

Functions

func Valid added in v1.33.2

func Valid(id string) error

youtube.com/watch?v=hi8ryzFqrAE

Types

type Auth added in v1.20.3

type Auth struct {
	Key   string
	Value string
}

type Client added in v1.16.9

type Client struct {
	Name    string `json:"clientName"`
	Screen  string `json:"clientScreen,omitempty"`
	Version string `json:"clientVersion"`
}

type Exchange added in v1.20.3

type Exchange struct {
	Access_Token  string
	Error         string
	Refresh_Token string
}

func (*Exchange) Refresh added in v1.20.3

func (x *Exchange) Refresh() error

type Format

type Format struct {
	Bitrate       bitrate
	ContentLength contentLength `json:"contentLength,string"`
	Height        int
	Itag          int
	MimeType      string
	URL           string
}

func (Format) Write

func (f Format) Write(w io.Writer) error

type FormatSlice added in v1.17.8

type FormatSlice []Format

func (FormatSlice) Filter added in v1.17.8

func (f FormatSlice) Filter(keep func(Format) bool) FormatSlice

func (FormatSlice) Sort added in v1.17.8

func (f FormatSlice) Sort(less ...func(a, b Format) bool)

type Item added in v1.24.9

type Item struct {
	CompactVideoRenderer *struct {
		LengthText text
		Title      text
		VideoID    string
	}
}

func (Item) VideoID added in v1.24.9

func (i Item) VideoID() string

type OAuth added in v1.20.4

type OAuth struct {
	Device_Code      string
	User_Code        string
	Verification_URL string
}

func NewOAuth added in v1.20.4

func NewOAuth() (*OAuth, error)

func (OAuth) Exchange added in v1.20.4

func (o OAuth) Exchange() (*Exchange, error)

type Param added in v1.28.2

type Param struct {
	SortBy int `protobuf:"varint,1"`
	Filter struct {
		UploadDate      int `protobuf:"varint,1"`
		Type            int `protobuf:"varint,2"`
		Duration        int `protobuf:"varint,3"`
		HD              int `protobuf:"varint,4"`
		Subtitles       int `protobuf:"varint,5"`
		CreativeCommons int `protobuf:"varint,6"`
		ThreeD          int `protobuf:"varint,7"`
		Live            int `protobuf:"varint,8"`
		Purchased       int `protobuf:"varint,9"`
		FourK           int `protobuf:"varint,14"`
		ThreeSixty      int `protobuf:"varint,15"`
		Location        int `protobuf:"varint,23"`
		HDR             int `protobuf:"varint,25"`
		VR180           int `protobuf:"varint,26"`
	} `protobuf:"bytes,2"`
}

func (*Param) Channel added in v1.28.2

func (p *Param) Channel()

"EgIQAg=="

func (*Param) CreativeCommons added in v1.28.2

func (p *Param) CreativeCommons()

"EgIwAQ=="

func (Param) Encode added in v1.28.2

func (p Param) Encode() (string, error)

func (*Param) FourK added in v1.28.2

func (p *Param) FourK()

"EgJwAQ=="

func (*Param) FourToTwentyMinutes added in v1.28.2

func (p *Param) FourToTwentyMinutes()

"EgIYAw=="

func (*Param) HD added in v1.28.2

func (p *Param) HD()

"EgIgAQ=="

func (*Param) HDR added in v1.28.2

func (p *Param) HDR()

"EgPIAQE="

func (*Param) LastHour added in v1.28.2

func (p *Param) LastHour()

"EgIIAQ=="

func (*Param) Live added in v1.28.2

func (p *Param) Live()

"EgJAAQ=="

func (*Param) Location added in v1.28.2

func (p *Param) Location()

"EgO4AQE="

func (*Param) Movie added in v1.28.2

func (p *Param) Movie()

"EgIQBA=="

func (*Param) OverTwentyMinutes added in v1.28.2

func (p *Param) OverTwentyMinutes()

"EgIYAg=="

func (*Param) Playlist added in v1.28.2

func (p *Param) Playlist()

"EgIQAw=="

func (*Param) Purchased added in v1.28.2

func (p *Param) Purchased()

"EgJIAQ=="

func (*Param) Rating added in v1.28.2

func (p *Param) Rating()

"CAE="

func (*Param) Relevance added in v1.28.2

func (p *Param) Relevance()

""

func (*Param) Subtitles added in v1.28.2

func (p *Param) Subtitles()

"EgIoAQ=="

func (*Param) ThisMonth added in v1.28.2

func (p *Param) ThisMonth()

"EgIIBA=="

func (*Param) ThisWeek added in v1.28.2

func (p *Param) ThisWeek()

"EgIIAw=="

func (*Param) ThisYear added in v1.28.2

func (p *Param) ThisYear()

"EgIIBQ=="

func (*Param) ThreeD added in v1.28.2

func (p *Param) ThreeD()

"EgI4AQ=="

func (*Param) ThreeSixty added in v1.28.2

func (p *Param) ThreeSixty()

"EgJ4AQ=="

func (*Param) Today added in v1.28.2

func (p *Param) Today()

"EgIIAg=="

func (*Param) UnderFourMinutes added in v1.28.2

func (p *Param) UnderFourMinutes()

"EgIYAQ=="

func (*Param) UploadDate added in v1.28.2

func (p *Param) UploadDate()

"CAI="

func (*Param) VR180 added in v1.28.2

func (p *Param) VR180()

"EgPQAQE="

func (*Param) Video added in v1.28.2

func (p *Param) Video()

"EgIQAQ=="

func (*Param) ViewCount added in v1.28.2

func (p *Param) ViewCount()

"CAM="

type Picture added in v1.21.9

type Picture struct {
	Width     int
	Height    int
	SubHeight int
	Base      string
	Format    pictureFormat
}

func (Picture) Address added in v1.21.9

func (p Picture) Address(id string) string

type PictureSlice added in v1.21.9

type PictureSlice []Picture

func (PictureSlice) Filter added in v1.21.9

func (p PictureSlice) Filter(keep func(Picture) bool) PictureSlice

func (PictureSlice) Sort added in v1.21.9

func (p PictureSlice) Sort(less ...func(a, b Picture) bool)

type Player added in v1.13.0

type Player struct {
	Microformat struct {
		PlayerMicroformatRenderer struct {
			AvailableCountries []string
			PublishDate        string
		}
	}
	PlayabilityStatus struct {
		Reason string
		Status string
	}
	StreamingData struct {
		AdaptiveFormats FormatSlice
		// just including this so I can bail if video is Dash Manifest
		DashManifestURL string
	}
	VideoDetails struct {
		Author           string
		ShortDescription string
		Title            string
		ViewCount        float64 `json:"viewCount,string"`
	}
}

func NewPlayer added in v1.13.0

func NewPlayer(id string, head Auth, body Client) (*Player, error)

func (Player) Author added in v1.13.0

func (p Player) Author() string

func (Player) Countries added in v1.13.0

func (p Player) Countries() []string

func (Player) Date added in v1.24.9

func (p Player) Date() string

func (Player) Description added in v1.13.0

func (p Player) Description() string

func (Player) Title added in v1.13.0

func (p Player) Title() string
type Search struct {
	Contents struct {
		SectionListRenderer struct {
			Contents []struct {
				ItemSectionRenderer *struct {
					Contents []Item
				}
			}
		}
	}
}

func NewSearch added in v1.11.2

func NewSearch(query string) (*Search, error)

func (Search) Items added in v1.24.9

func (s Search) Items() []Item

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL