yt

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

README

ytpriv 💾

A fast tool for exporting YouTube data using their undocumented JSON APIs.

No API keys or logins required, and no stability guarantees given.

If you find it useful, please give it a star!

Please only use this tool to the extent permitted by the YouTube ToS.

Installation

From source

Requires a Go 1.14+ toolchain.

Run go install ./cmd/ytpriv to install to $(go env GOPATH)/bin/ytpriv.

Features

ytpriv [command]
  channel     Scrape a channel
  livestream  Scrape a livestream
  playlist    Scrape a playlist
  video       Scrape a video
Channel
ytpriv channel [command]
  overview    Get overview of channel
  videos      Get full list of videos of channel
  videos_page Get videos page of channel
Livestream
ytpriv livestream [command]
  chat        Follow the live chat
Playlist
ytpriv playlist [command]
  videos      Get full list of videos in playlist
  videos_page Get page of videos of playlist
Video
ytpriv video [command]
  comments    Scrape comments of videos
  detail      Get details about a video

Attributions

Developed by @terorie

Using the amazing Go ecosystem including:

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRateLimit = errors.New("reCAPTCHA triggered")
View Source
var ErrVideoUnavailable = errors.New("video unavailable")
View Source
var MissingData = errors.New("missing data")
View Source
var ServerError = errors.New("server error")

Functions

func ExtractChannelID

func ExtractChannelID(chanURL string) (string, error)

ExtractChannelID returns the channel ID from a channel URL.

func ExtractNumber

func ExtractNumber(s string) (uint64, error)

ExtractNumber extracts an integer from a locale-formatted string. "137,802 views" => 137802

func ExtractVideoID

func ExtractVideoID(vidURL string) (string, error)

ExtractVideoID returns the video ID from a video URL.

func InitialCommentContinuation

func InitialCommentContinuation(v *types.Video) *types.CommentContinuation

func ParseChannelOverview

func ParseChannelOverview(res *fasthttp.Response) (*types.ChannelOverview, error)

func ParseChannelVideosPage

func ParseChannelVideosPage(res *fasthttp.Response) (*types.ChannelVideosPage, error)

func ParseChannelVideosStart

func ParseChannelVideosStart(res *fasthttp.Response) (*types.ChannelVideosPage, error)

func ParseCommentPage

func ParseCommentPage(res *fasthttp.Response, cont *types.CommentContinuation) (page types.CommentPage, err error)

func ParseDuration

func ParseDuration(d string) (uint64, error)

ParseDuration parses a duration string. "PT6M57S" => 6 min 57 s

func ParseLivechatReplay

func ParseLivechatReplay(res *fasthttp.Response) (msgs []*types.LivechatMessage, cont string, err error)

func ParsePlaylist

func ParsePlaylist(res *fasthttp.Response) (*types.Playlist, error)

func ParsePlaylistPage

func ParsePlaylistPage(res *fasthttp.Response) (*types.PlaylistPage, error)

func ParseVideo

func ParseVideo(res *fasthttp.Response) (*types.Video, error)

ParseVideo returns the video from a video response.

func ParseVideoBody

func ParseVideoBody(buf []byte, res *fasthttp.Response) (*types.Video, error)

Types

type ChannelOverviewRequest

type ChannelOverviewRequest struct {
	*Client
	*fasthttp.Request
}

func (ChannelOverviewRequest) Do

type ChannelVideosPageRequest

type ChannelVideosPageRequest struct {
	*Client
	*fasthttp.Request
}

func (ChannelVideosPageRequest) Do

func (ChannelVideosPageRequest) GetRequest

func (r ChannelVideosPageRequest) GetRequest() *fasthttp.Request

type ChannelVideosStartRequest

type ChannelVideosStartRequest struct {
	*Client
	*fasthttp.Request
}

func (ChannelVideosStartRequest) Do

func (ChannelVideosStartRequest) GetRequest

func (r ChannelVideosStartRequest) GetRequest() *fasthttp.Request

type Client

type Client struct {
	HTTP *fasthttp.Client
}

Client accesses the YouTube private API.

func NewClient

func NewClient() *Client

func (*Client) GetVideoSubtitleList

func (c *Client) GetVideoSubtitleList(videoID string) (tracks *XMLSubTrackList, err error)

func (*Client) RequestChannelOverview

func (c *Client) RequestChannelOverview(channelID string) ChannelOverviewRequest

func (*Client) RequestChannelVideosPage

func (c *Client) RequestChannelVideosPage(cont string) ChannelVideosPageRequest

RequestChannelVideosPage requests a page of videos on a channel, given a continuation.

func (*Client) RequestChannelVideosStart

func (c *Client) RequestChannelVideosStart(channelID string) ChannelVideosStartRequest

func (*Client) RequestCommentPage

func (c *Client) RequestCommentPage(continuation *types.CommentContinuation) CommentPageRequest

RequestCommentPage requests a page of comments given a continuation.

func (*Client) RequestLivechat

func (c *Client) RequestLivechat(continuation string) LivechatRequest

RequestLivechat fetches the continuation of a live chat.

func (*Client) RequestLivechatReplay

func (c *Client) RequestLivechatReplay(continuation string) LivechatReplayRequest

func (*Client) RequestPlaylistPage

func (c *Client) RequestPlaylistPage(id string) PlaylistPageRequest

RequestPlaylistPage fetches a page of a playlist.

func (*Client) RequestPlaylistStart

func (c *Client) RequestPlaylistStart(id string) PlaylistStartRequest

RequestPlaylistStart fetches the first page of a playlist.

func (*Client) RequestVideo

func (c *Client) RequestVideo(videoID string) VideoRequest

RequestVideo requests a video by ID.

type CommentPageRequest

type CommentPageRequest struct {
	*Client
	*fasthttp.Request
	Continuation *types.CommentContinuation
}

func (CommentPageRequest) Do

func (r CommentPageRequest) Do() (page types.CommentPage, err error)

type LivechatContinuation

type LivechatContinuation struct {
	Timeout      int
	Continuation string
}

func ParseLivechat

func ParseLivechat(res *fasthttp.Response) (msgs []*types.LivechatMessage, cont LivechatContinuation, err error)

type LivechatReplayRequest

type LivechatReplayRequest struct {
	*Client
	*fasthttp.Request
}

func (LivechatReplayRequest) Do

type LivechatRequest

type LivechatRequest struct {
	*Client
	*fasthttp.Request
}

func (LivechatRequest) Do

type PlaylistPageRequest

type PlaylistPageRequest struct {
	*Client
	*fasthttp.Request
}

func (PlaylistPageRequest) Do

type PlaylistStartRequest

type PlaylistStartRequest struct {
	*Client
	*fasthttp.Request
}

func (PlaylistStartRequest) Do

type VideoRequest

type VideoRequest struct {
	*Client
	*fasthttp.Request
}

VideoRequest requests a video.

func (VideoRequest) Do

func (r VideoRequest) Do() (*types.Video, error)

Do executes the request.

type XMLSubTrackList

type XMLSubTrackList struct {
	Tracks []struct {
		LangCode string `xml:"lang_code,attr"`
		Lang     string `xml:"lang_translated,attr"`
	} `xml:"track"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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