youtube

package module
v0.0.0-...-93be91d Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MIT Imports: 14 Imported by: 0

README

youtube

youtube

Installation

The minimum requirement of Go is 1.20.

go get github.com/gravitymir/youtube

Please apply -u flag to update in the future.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec() error

Exec d

Types

type Details

type Details struct {
	VideoID          string   `json:"videoId"`
	Title            string   `json:"title"`
	LengthSeconds    string   `json:"lengthSeconds"`
	Keywords         []string `json:"keywords"`
	ChannelID        string   `json:"channelId"`
	IsOwnerViewing   bool     `json:"isOwnerViewing"`
	ShortDescription string   `json:"shortDescription"`
	IsCrawlable      bool     `json:"isCrawlable"`
	Thumbnail        struct {
		Thumbnails []struct {
			URL    string `json:"url"`
			Width  int    `json:"width"`
			Height int    `json:"height"`
		} `json:"thumbnails"`
	} `json:"thumbnail"`
	AllowRatings      bool   `json:"allowRatings"`
	ViewCount         string `json:"viewCount"`
	Author            string `json:"author"`
	IsPrivate         bool   `json:"isPrivate"`
	IsUnpluggedCorpus bool   `json:"isUnpluggedCorpus"`
	IsLiveContent     bool   `json:"isLiveContent"`
}

type Format

type Format struct {
	Itag             int    `json:"itag"`
	URL              string `json:"url"`
	MimeType         string `json:"mimeType"`
	Bitrate          int    `json:"bitrate"`
	Width            int    `json:"width"`
	Height           int    `json:"height"`
	LastModified     string `json:"lastModified"`
	ContentLength    string `json:"contentLength,omitempty"`
	Quality          string `json:"quality"`
	Fps              int    `json:"fps"`
	QualityLabel     string `json:"qualityLabel"`
	ProjectionType   string `json:"projectionType"`
	AverageBitrate   int    `json:"averageBitrate,omitempty"`
	AudioQuality     string `json:"audioQuality"`
	ApproxDurationMs string `json:"approxDurationMs"`
	AudioSampleRate  string `json:"audioSampleRate"`
	AudioChannels    int    `json:"audioChannels"`
}

type Info

type Info struct {
	VideoID          string   `json:"videoId"`
	Title            string   `json:"title"`
	LengthSeconds    string   `json:"lengthSeconds"`
	Keywords         []string `json:"keywords"`
	ShortDescription string   `json:"shortDescription"`
	Author           string   `json:"author"`
}

type SubtitlesTrack

type SubtitlesTrack struct {
	BaseURL        string
	Name           string
	VssID          string
	LanguageCode   string
	Kind           string
	IsTranslatable bool
}

type YouTube

type YouTube struct {
	VideoID string
	Status  string // OK ERROR LOGIN_REQUIRED LIVE_STREAM_OFFLINE UNPLAYABLE CONTENT_CHECK_REQUIRED
	Reason  string
	Details
	VideoAndAudio   []Format
	VideoFormats    []Format
	AudioFormats    []Format
	SubtitlesTracks []SubtitlesTrack
	Subtitles       struct {
		Text []struct {
			Text  string `xml:",chardata"`
			Start string `xml:"start,attr"`
			Dur   string `xml:"dur,attr"`
		} `xml:"text"`
	}
	ResponseToYouTubeBodyData []byte
	ResponseSubtitlesBodyData []byte
	// contains filtered or unexported fields
}

func Init

func Init(linkOrId string) (yt *YouTube, err error)

Init YouTube struct make Get request to web page YouTube with video ID

func (*YouTube) Download

func (yt *YouTube) Download(format Format, filePath string) (err error)

Download try download2 file from YouTube

func (*YouTube) GetDetailsPretty

func (yt *YouTube) GetDetailsPretty() (details []byte, err error)

GetDetailsPretty g

func (*YouTube) GetSubtitlesJson

func (yt *YouTube) GetSubtitlesJson(track SubtitlesTrack) (subtitles string, err error)

GetSubtitlesJson subtitles in string JSON

func (*YouTube) GetSubtitlesJsonPretty

func (yt *YouTube) GetSubtitlesJsonPretty(track SubtitlesTrack) (subtitles string, err error)

GetSubtitlesJsonPretty return subtitles in string JSON with 4 spaces for better humans reading pretty style JSON print

func (*YouTube) GetSubtitlesPlainText

func (yt *YouTube) GetSubtitlesPlainText(track SubtitlesTrack) (subtitles string, err error)

GetSubtitlesPlainText get subtitles into only plain text, without timestamps

func (*YouTube) GetSubtitlesXML

func (yt *YouTube) GetSubtitlesXML(track SubtitlesTrack) (subtitles string, err error)

GetSubtitlesXML get subtitles into XML format

func (*YouTube) SaveDetailsPretty

func (yt *YouTube) SaveDetailsPretty(filePath string) (err error)

SaveDetailsPretty g

func (*YouTube) SaveSubtitlesJsonPretty

func (yt *YouTube) SaveSubtitlesJsonPretty(track SubtitlesTrack, filePath string) (err error)

SaveSubtitlesJsonPretty save subtitles to file in pretty format

func (*YouTube) SaveSubtitlesXML

func (yt *YouTube) SaveSubtitlesXML(track SubtitlesTrack, filePath string) (err error)

SaveSubtitlesXML save subtitles to file in XML format, plain format

func (*YouTube) SaveThumbnailJPG

func (yt *YouTube) SaveThumbnailJPG(filePath string) (err error)

SaveThumbnail g

Jump to

Keyboard shortcuts

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