youtube

package
v1.11.5 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: OSL-3.0 Imports: 9 Imported by: 3

README

YouTube

Download from YouTube

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 (
	Origin = "https://www.youtube.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseJS

type BaseJS struct {
	Cache  string
	Create string
}

func NewBaseJS

func NewBaseJS() (BaseJS, error)

func (BaseJS) Get

func (b BaseJS) Get() 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 Video

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

func NewVideo

func NewVideo(id string) (Video, error)

NewVideo fetches video metadata

func (Video) Author

func (v Video) Author() string

func (Video) Countries

func (v Video) Countries() []string

func (Video) Description

func (v Video) Description() string

func (Video) Formats

func (v Video) Formats() []Format

func (Video) NewFormat

func (v Video) NewFormat(itag int) (Format, error)

func (Video) PublishDate

func (v Video) PublishDate() string

func (Video) Title

func (v Video) Title() string

func (Video) ViewCount

func (v Video) ViewCount() int

type VideoRenderer added in v1.11.2

type VideoRenderer struct {
	VideoID string
}

Jump to

Keyboard shortcuts

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