yt

package module
v1.1.0 Latest Latest
Warning

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

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

README

ytwrk 💾

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

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

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

Features

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

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)

"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)

"PT6M57S" => 6 min 57 s

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)

res is optional

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) RequestLivechatContinuation

func (c *Client) RequestLivechatContinuation(continuation string) LivechatContinuationRequest

RequestLivechatContinuation fetches the continuation of a live chat.

func (*Client) RequestLivechatStart

func (c *Client) RequestLivechatStart(videoID string) LivechatStartRequest

RequestLivechatStart fetches the beginning of a live chat.

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 ParseLivechatPage

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

func ParseLivechatStart

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

type LivechatContinuationRequest

type LivechatContinuationRequest struct {
	*Client
	*fasthttp.Request
}

func (LivechatContinuationRequest) Do

type LivechatStartRequest

type LivechatStartRequest struct {
	*Client
	*fasthttp.Request
}

func (LivechatStartRequest) 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