youtube

package
v1.13.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: OSL-3.0 Imports: 6 Imported by: 4

README

YouTube

youtubei

type Android struct {
   Media
}

type Web struct {
   Date
}

watch

desktop:

curl -o index.html https://www.youtube.com/watch?v=UpNXI3_ctAc

Next:

<script nonce="GWQS4dROIhbOWa4QpveqWw">var ytInitialPlayerResponse = {"respons...
...ta":false,"viewCount":"11059","category":"Music","publishDate":"2020-10-02"...
...1"}},"adSlotLoggingData":{"serializedSlotAdServingDataEntry":""}}}]};</script>

Next:

<script nonce="GWQS4dROIhbOWa4QpveqWw">var ytInitialPlayerResponse = {"respons...
...u0026sp=sig\u0026url=https://r4---sn-q4flrner.googlevideo.com/videoplayback...
...1"}},"adSlotLoggingData":{"serializedSlotAdServingDataEntry":""}}}]};</script>

mobile good:

Never Gonna Reach Me
curl -o index.html -A iPad https://m.youtube.com/watch?v=UpNXI3_ctAc

mobile bad:

Goon Gumpas
curl -o index.html -A iPad https://m.youtube.com/watch?v=NMYIVsdGfoo

So, we are looking for this:

/watch?v=XFkzRNyygfk

First result:

<script nonce="TCh7gubawSzSBgq1Zg3rSA">var ytInitialData = {"responseContext"...
...ead creep cover","radiohead fake plastic trees","radiohead kid a"]};</script>

Everything after var ytInitialData = and before ; is valid JSON. The search results are here:

contents	
   twoColumnSearchResultsRenderer	
      primaryContents	
         sectionListRenderer	
            contents	
               0	
                  itemSectionRenderer	
                     contents

careful, first result might be an advertisement.

Free proxy list

https://proxy.webshare.io/register

Documentation

Overview

YouTube

Index

Constants

View Source
const (
	PlayerAPI = "https://www.youtube.com/youtubei/v1/player"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Android added in v1.13.3

type Android struct {
	StreamingData struct {
		AdaptiveFormats []Format
	}
}

func NewAndroid added in v1.13.3

func NewAndroid(id string) (Android, error)

func (Android) Formats added in v1.13.3

func (a Android) Formats() []Format

func (Android) NewFormat added in v1.13.3

func (a Android) NewFormat(itag int) (Format, error)

type Format

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

func (Format) Write

func (f Format) Write(w io.Writer) error
type Search struct {
	Contents struct {
		TwoColumnSearchResultsRenderer struct {
			PrimaryContents primaryContents
		}
	}
}

func NewSearch added in v1.11.2

func NewSearch(query string) (Search, error)

func (Search) VideoRenderers added in v1.11.2

func (s Search) VideoRenderers() []VideoRenderer

type VideoRenderer added in v1.11.2

type VideoRenderer struct {
	VideoID string
}

type Web added in v1.13.3

type Web struct {
	Microformat struct {
		PlayerMicroformatRenderer struct {
			AvailableCountries []string
			PublishDate        string
		}
	}
	VideoDetails struct {
		Author           string
		ShortDescription string
		Title            string
		ViewCount        int `json:"viewCount,string"`
	}
}

func NewWeb added in v1.13.3

func NewWeb(id string) (Web, error)

func (Web) Author added in v1.13.3

func (w Web) Author() string

func (Web) Countries added in v1.13.3

func (w Web) Countries() []string

func (Web) Description added in v1.13.3

func (w Web) Description() string

func (Web) PublishDate added in v1.13.3

func (w Web) PublishDate() string

func (Web) Title added in v1.13.3

func (w Web) Title() string

func (Web) ViewCount added in v1.13.3

func (w Web) ViewCount() int

Jump to

Keyboard shortcuts

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