ytdl-web/ytdl/data.go

442 lines
13 KiB
Go

package ytdl
type Metdata struct {
// Video identifier.
ID string `json:"id"`
// Video title, unescaped. Set to an empty string if video has
// no title as opposed to "None" which signifies that the
// extractor failed to obtain a title
Title *string `json:"title"`
// A list of dictionaries for each format available, ordered
// from worst to best quality.
Formats []Format `json:"formats"`
// Final video URL.
Url string `json:"url"`
// Video filename extension.
Ext string `json:"ext"`
// The video format, defaults to ext (used for --get-format)
Format string `json:"format"`
// True if a direct video file was given (must only be set by GenericIE)
Direct *bool `json:"direct"`
// A secondary title of the video.
AltTitle *string `json:"alt_title"`
// An alternative identifier for the video, not necessarily
// unique, but available before title. Typically, id is
// something like "4234987", title "Dancing naked mole rats",
// and display_id "dancing-naked-mole-rats"
DisplayID *string `json:"display_id"`
Thumbnails []Thumbnail `json:"thumbnails"`
// Full URL to a video thumbnail image.
Thumbnail *string `json:"thumbnail"`
// Full video description.
Description *string `json:"description"`
// Full name of the video uploader.
Uploader *string `json:"uploader"`
// License name the video is licensed under.
License *string `json:"license"`
// The creator of the video.
Creator *string `json:"creator"`
// UNIX timestamp of the moment the video was uploaded
Timestamp *int64 `json:"timestamp"`
// Video upload date in UTC (YYYYMMDD).
// If not explicitly set, calculated from timestamp
UploadDate *string `json:"upload_date"`
// UNIX timestamp of the moment the video was released.
// If it is not clear whether to use timestamp or this, use the former
ReleaseTimestamp *int64 `json:"release_timestamp"`
// The date (YYYYMMDD) when the video was released in UTC.
// If not explicitly set, calculated from release_timestamp
ReleaseDate *string `json:"release_date"`
// UNIX timestamp of the moment the video was last modified.
ModifiedTimestamp *int64 `json:"modified_timestamp"`
// The date (YYYYMMDD) when the video was last modified in UTC.
// If not explicitly set, calculated from modified_timestamp
ModifiedDate *string `json:"modified_date"`
// Nickname or id of the video uploader.
UploaderId *string `json:"uploader_id"`
// Full URL to a personal webpage of the video uploader.
UploaderUrl *string `json:"uploader_url"`
// Full name of the channel the video is uploaded on.
// Note that channel fields may or may not repeat uploader
// fields. This depends on a particular extractor.
Channel *string `json:"channel"`
// Id of the channel.
ChannelId *string `json:"channel_id"`
// Full URL to a channel webpage.
ChannelUrl *string `json:"channel_url"`
// Number of followers of the channel.
ChannelFollowerCount *int `json:"channel_follower_count"`
// Physical location where the video was filmed.
Location *string `json:"location"`
// The available subtitles as a dictionary in the format
// {tag: subformats}. "tag" is usually a language code, and
// "subformats" is a list sorted from lower to higher
// preference
Subtitles map[string][]Subtitle `json:"subtitles"`
// Like 'subtitles'; contains automatically generated
// captions instead of normal subtitles
AutomaticCaptions map[string][]Subtitle `json:"automatic_captions"`
// Length of the video in seconds, as an integer or float.
Duration *float64 `json:"duration"`
// How many users have watched the video on the platform.
ViewCount *int64 `json:"view_count"`
// How many users are currently watching the video on the platform.
ConcurrentViewCount *int64 `json:"concurrent_view_count"`
// Number of positive ratings of the video
LikeCount *int64 `json:"like_count"`
// Number of negative ratings of the video
DislikeCount *int64 `json:"dislike_count"`
// Number of reposts of the video
RepostCount *int64 `json:"repost_count"`
// Average rating give by users, the scale used depends on the webpage
AverageRating *float64 `json:"average_rating"`
// Number of comments on the video
CommentCount *int64 `json:"comment_count"`
// A list of comments
Comments []Comment `json:"comments"`
// Age restriction for the video, as an integer (years)
AgeLimit *int `json:"age_limit"`
// The URL to the video webpage, if given to yt-dlp it
// should allow to get the same result again. (It will be set
// by YoutubeDL if it's missing)
WebpageUrl *string `json:"webpage_url"`
// A list of categories that the video falls in
Categories []string `json:"categories"`
// A list of tags assigned to the video
Tags []string `json:"tags"`
// A list of the video cast
Cast []string `json:"cast"`
// Whether this video is a live stream that goes on instead of a fixed-length video.
IsLive *bool `json:"is_live"`
// Whether this video was originally a live stream.
WasLive *bool `json:"was_live"`
// None (=unknown), 'is_live', 'is_upcoming', 'was_live', 'not_live',
// or 'post_live' (was live, but VOD is not yet processed)
// If absent, automatically set from is_live, was_live
LiveStatus *string `json:"live_status"`
// Time in seconds where the reproduction should start, as
// specified in the URL.
StartTime *int64 `json:"start_time"`
// Time in seconds where the reproduction should end, as
// specified in the URL.
EndTime *int64 `json:"end_time"`
Chapters []Chapter `json:"chapters"`
}
type Format struct {
// The mandatory URL representing the media:
// for plain file media - HTTP URL of this file,
// for RTMP - RTMP URL,
// for HLS - URL of the M3U8 media playlist,
// for HDS - URL of the F4M manifest,
// for DASH
// - HTTP URL to plain file media (in case of
// unfragmented media)
// - URL of the MPD manifest or base URL
// representing the media if MPD manifest
// is parsed from a string (in case of
// fragmented media)
// for MSS - URL of the ISM manifest.
Url string `json:"url"`
// Will be calculated from URL if missing
Ext string `json:"ext"`
// A human-readable description of the format
// ("mp4 container with h264/opus").
// Calculated from the format_id, width, height.
// and format_note fields if missing.
Format string `json:"format"`
// A short description of the format
// ("mp4_h264_opus" or "19").
// Technically optional, but strongly recommended.
FormatID string `json:"format_id"`
// Additional info about the format
// ("3D" or "DASH video")
FormatNote string `json:"format_note"`
// Width of the video, if known
Width int `json:"width"`
// Height of the video, if known
Height int `json:"height"`
// Aspect ratio of the video, if known
// Automatically calculated from width and height
AspectRatio float64 `json:"aspect_ratio"`
// Textual description of width and height
// Automatically calculated from width and height
Resolution string `json:"resolution"`
// The dynamic range of the video. One of:
// "SDR" (None), "HDR10", "HDR10+, "HDR12", "HLG, "DV"
DynamicRange string `json:"dynamic_range"`
// Average bitrate of audio and video in KBit/s
Tbr float64 `json:"tbr"`
// Average audio bitrate in KBit/s
Abr float64 `json:"abr"`
// Average video bitrate in KBit/s
Vbr float64 `json:"vbr"`
// Name of the audio codec in use
ACodec string `json:"acodec"`
// Name of the video codec in use
VCodec string `json:"vcodec"`
// Number of audio channels
AudioChannels int `json:"audio_channels"`
// Frame rate
Fps float64 `json:"fps"`
// Name of the container format
Container string `json:"container"`
// The number of bytes, if known in advance
Filesize *int `json:"filesize"`
// An estimate for the number of bytes
FilesizeApprox *int `json:"filesize_approx"`
// The protocol that will be used for the actual
// download, lower-case. One of "http", "https" or
// one of the protocols defined in downloader.PROTOCOL_MAP
Protocol string `json:"protocol"`
// Base URL for fragments. Each fragment's path
// value (if present) will be relative to
// this URL.
FragmentBaseUrl *string `json:"fragment_base_url"`
// A list of fragments of a fragmented media.
// Each fragment entry must contain either an url
// or a path. If an url is present it should be
// considered by a client. Otherwise both path and
// fragment_base_url must be present.
Fragments []Fragment `json:"fragments"`
// Is a live format that can be downloaded from the start.
IsFromStart bool `json:"is_from_start"`
// Order number of this format. If this field is
// present and not None, the formats get sorted
// by this field, regardless of all other values.
// -1 for default (order by other properties),
// -2 or smaller for less than default.
// < -1000 to hide the format (if there is
// another one which is strictly better)
Preference *int `json:"preference"`
// Language code, e.g. "de" or "en-US".
Language string `json:"language"`
// Is this in the language mentioned in
// the URL?
// 10 if it's what the URL is about,
// -1 for default (don't know),
// -10 otherwise, other values reserved for now.
LanguagePreference int `json:"language_preference"`
// Order number of the video quality of this
// format, irrespective of the file format.
// -1 for default (order by other properties),
// -2 or smaller for less than default.
Quality float64 `json:"quality"`
// Order number for this video source
// (quality takes higher priority)
// -1 for default (order by other properties),
// -2 or smaller for less than default.
SourcePreference int `json:"source_preference"`
// A dictionary of additional HTTP headers to add to the request.
HttpHeaders map[string]string `json:"http_header"`
// If given and not 1, indicates that the
// video's pixels are not square.
// width : height ratio as float.
StretchedRatio *float64 `json:"stretched_ratio"`
// The server does not support resuming the (HTTP or RTMP) download.
NoResume bool `json:"no_resume"`
// The format has DRM and cannot be downloaded.
HasDrm bool `json:"has_drm"`
// A query string to append to each
// fragment's URL, or to update each existing query string
// with. Only applied by the native HLS/DASH downloaders.
ExtraParamToSegmentUrl string `json:"extra_param_to_segment_url"`
// A dictionary of HLS AES-128 decryption information
// used by the native HLS downloader to override the
// values in the media playlist when an '#EXT-X-KEY' tag
// is present in the playlist
HlsAes *HlsAes `json:"hls_aes"`
}
type Fragment struct {
// fragment's URL
Url string `json:"url"`
// fragment's path relative to fragment_base_url
Path string `json:"path"`
Duration *float64 `json:"duration"`
Filesize *int `json:"filesize"`
}
type HlsAes struct {
// The URI from which the key will be downloaded
Uri string `json:"uri"`
// The key (as hex) used to decrypt fragments.
// If `key` is given, any key URI will be ignored
Key string `json:"key"`
// The IV (as hex) used to decrypt fragments
Iv string `json:"iv"`
}
type Thumbnail struct {
// Thumbnail format ID
ID *string `json:"id"`
Url string `json:"url"`
// Quality of the image
Preference *int `json:"preference"`
Width *int `json:"width"`
Height *int `json:"height"`
Filesize *int `json:"filesize"`
// HTTP headers for the request
HttpHeaders map[string]string `json:"http_headers"`
}
type Subtitle struct {
// Will be calculated from URL if missing
Ext string `json:"ext"`
// The subtitles file contents
Data string `json:"data"`
// A URL pointing to the subtitles file
Url string `json:"url"`
// Name or description of the subtitles
Name string `json:"name"`
// A dictionary of additional HTTP headers to add to the request.
HttpHeaders map[string]string `json:"http_headers"`
}
type Comment struct {
// human-readable name of the comment author
Author *string `json:"author"`
// user ID of the comment author
AuthorID *string `json:"author_id"`
// The thumbnail of the comment author
AuthorThumbnail *string `json:"author_thumbnail"`
// Comment ID
ID *string `json:"id"`
// Comment as HTML
HTML *string `json:"html"`
// Plain text of the comment
Text *string `json:"text"`
// UNIX timestamp of comment
Timestamp *int64 `json:"timestamp"`
// ID of the comment this one is replying to.
// Set to "root" to indicate that this is a
// comment to the original video.
Parent string `json:"parent"`
// Number of positive ratings of the comment
LikeCount *int64 `json:"like_count"`
// Number of negative ratings of the comment
DislikeCount *int64 `json:"dislike_count"`
// Whether the comment is marked as
// favorite by the video uploader
IsFavorited bool `json:"is_favorited"`
// Whether the comment is made by
// the video uploader
AuthorIsUploader bool `json:"author_is_uploader"`
}
type Chapter struct {
// The start time of the chapter in seconds
StartTime int64 `json:"start_time"`
// The end time of the chapter in seconds
EndTime int64 `json:"end_time"`
Title *string `json:"title"`
}