video

package
v0.0.0-...-7565d26 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SidebarEntryTypeVideo sidebarEntryType = iota
	SidebarEntryTypePlaylist
	SidebarEntryTypeRadio
)
View Source
const WebKey = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8"

Youtube web client api key

View Source
const YoutubeVideoDateLayout = "Jan 2, 2006"

Used for parsing youtube video upload date to golang time.Time

Variables

This section is empty.

Functions

func FetchDecryptFunction

func FetchDecryptFunction(mediaUrlJs string) (decryptFunctions []decryptFunc, err error)

TODO: fix & cleanup TODO: add caching

Types

type Comment

type Comment struct {
	NewChannelID  string
	CommentID     string
	Content       string
	PublishedTime string // "5 days ago"
	Likes         int
	PinnedBy      string // "Pinned by Username"
	IsPinned      bool
	IsHearted     bool
	WasEdited     bool // if the comment was edited
	RepliesAmount int
	Avatars       []scraper.YoutubeImage
	// contains filtered or unexported fields
}

func (*Comment) HasSubComments

func (c *Comment) HasSubComments() bool

HasSubComments returns if the comment has any replies

func (*Comment) NextSubCommentPage

func (c *Comment) NextSubCommentPage() (comments []Comment, err error)

NextSubCommentPage returns comment replies in chunks. Check with HasSubComments if there are replies

type ExtractMediaOutput

type ExtractMediaOutput struct {
	Formats []MediaFormat `rjson:"streamingData.formats"`

	// Best quality formats are here, but the video and audio tracks will be separate
	AdaptiveFormats []MediaFormat `rjson:"streamingData.adaptiveFormats"`
}

func ExtractMediaFormats

func ExtractMediaFormats(id string) (output ExtractMediaOutput, err error)

type FullVideo

type FullVideo struct {
	VideoID        string
	Title          string
	Description    string
	Views          int // Displays number of video views exept in a livestream where it will display number of viewers
	IsLive         bool
	WasLive        bool      // if this video was live in the past
	Date           time.Time // video upload date
	Likes          int
	CommentsCount  int
	Category       string // video category
	IsUnlisted     bool
	VideoPremiered bool // if the video was premiered in the past

	Username           string
	ChannelID          string
	NewChannelID       string
	ChannelSubscribers int
	ChannelAvatars     []scraper.YoutubeImage

	ChannelIsVerified       bool
	ChannelIsVerifiedArtist bool
}

FullVideo has the full metadata unlike Video which is fetched from Video lists

type MediaFormat

type MediaFormat struct {
	Bitrate int `rjson:"bitrate"`
	Width   int `rjson:"width"`
	Height  int `rjson:"height"`

	Url             string `rjson:"url"`
	MimeType        string `rjson:"mimeType"` // e.g "audio/mp4; codecs=\"mp4a.40.2\"" or "video/mp4; codecs=\"av01.0.00M.08\""
	QualityLabel    string `rjson:"qualityLabel"`
	SignatureCipher string `rjson:"signatureCipher"` // DRM

	// Videos can have dubs
	AudioTrack struct {
		DisplayName    string `rjson:"displayName"`
		AudioIsDefault bool   `rjson:"audioIsDefault"`
	} `rjson:"audioTrack"`
}

func (*MediaFormat) GetMediaUrl

func (m *MediaFormat) GetMediaUrl(v *VideoScraper) (out string, err error)

GetMediaUrl is a generic function to get the media url, doesnt matter if it has DRM or not

type SidebarEntry

type SidebarEntry struct {
	Type  sidebarEntryType
	Entry any
}

func (SidebarEntry) IsPlaylist

func (s SidebarEntry) IsPlaylist() bool

func (SidebarEntry) IsRadio

func (s SidebarEntry) IsRadio() bool

func (SidebarEntry) IsVideo

func (s SidebarEntry) IsVideo() bool

type SidebarPlaylist

type SidebarPlaylist struct {
	PlaylistID string
	Title      string

	Username     string
	ChannelId    string
	NewChannelID string

	VideosAmount     int
	ThumbnailVideoID string
	Thumbnails       []scraper.YoutubeImage
}

type SidebarRadio

type SidebarRadio struct {
	PlaylistID     string
	Title          string
	SecondaryTitle string

	VideosAmount     int
	ThumbnailVideoID string
	Thumbnails       []scraper.YoutubeImage
}

type SidebarVideo

type SidebarVideo struct {
	VideoID      string
	Title        string
	Username     string
	ChannelID    string
	NewChannelID string
	Date         string
	Views        int
	Viewers      int
	Length       string
	Thumbnails   []scraper.YoutubeImage

	AuthorIsVerified, AuthorIsVerifiedArtist bool
	HasNewBadge, HasCCBadge, Has4kBadge      bool

	IsLive, WasLive bool
}

type VideoScraper

type VideoScraper struct {
	VideoInfo             FullVideo // Initial info about the video
	InitialSidebarEntries []SidebarEntry
	// contains filtered or unexported fields
}

func NewVideoScraper

func NewVideoScraper(id string) (v VideoScraper, err error)

func VideoScraperFromExport

func VideoScraperFromExport(export VideoScraperExport) (v VideoScraper, err error)

func (VideoScraper) Export

func (v VideoScraper) Export() VideoScraperExport

func (*VideoScraper) ExtractMediaFormats

func (v *VideoScraper) ExtractMediaFormats() (output ExtractMediaOutput, err error)

func (*VideoScraper) NextNewestCommentsPage

func (v *VideoScraper) NextNewestCommentsPage() (comments []Comment, err error)

NextNewestCommentsPage returns comments in chunks sorted by newest

func (*VideoScraper) NextSidebarVideosPage

func (v *VideoScraper) NextSidebarVideosPage() (sidebarEntries []SidebarEntry, err error)

func (*VideoScraper) NextTopCommentsPage

func (v *VideoScraper) NextTopCommentsPage() (comments []Comment, err error)

NextTopCommentsPage returns comments in chunks sorted by most popular

type VideoScraperExport

type VideoScraperExport struct {
	MediaUrlJs string
	Url        string

	CommentsNewestPassedInitial bool
	CommentsNewestToken         string

	CommentsTopPassedInitial bool
	CommentsTopToken         string

	SidebarToken string
}

Jump to

Keyboard shortcuts

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