Skip to content
gatecrasher777 edited this page Aug 3, 2021 · 4 revisions

ytcog wiki

Video/Download options

An object with the following properties:

Required:

id:  (11 character string) the video id.

Optional:

cookie:        (string) your current YouTube cookie (optional but recommended).  

userAgent:     (string) your browser's user agent string (optional - if omitted the library will pick one for you).  

published:     (number) Optional published timestamp (used internally).   

path: (string) path to your download folder - defaults to the current directory.

filename:      (string) your custom filename, do not include an extension. The default filename format is author_title_videoId_resolution.container.  

container:     (string) your desired media container: 'any' allows either pure mp4 (h264/aac) or pure webm (vp9/opus), 'mp4' allows only pure mp4 (h264/aac), 'webm' allows only pure webm (vp9/opus) and 'mkv' allows mp4, webm, mkv (vp9/acc) or mkv (mp4/opus) (default). 

videoQuality:  (string) your desired video quality: 'highest', '1080p' (default), '720p', '480p', 'medium', '360p', '240p', '144p', 'lowest', 'none' (audio only).  

audioQuality:  (string) your desired audio quality: 'high', 'medium' (default), 'low', 'none' (video only).  

mediaBitrate:  (string) when comparing bitrates of streams of equal resolution/quality choose 'highest' (default) or 'lowest'.  

videoFormat:   (number) choose a specific video stream (default: -1 uses above options to rank and select video streams).  

audioFormat:   (number) choose a specific audio stream (default: -1 uses above options to rank and select audio streams).  

progress:      (function) provide a download progress callback.

search options

An object with the following properties:

Required:

query:         (string) your search term.  

Optional:

period:        (string) the focus period of the search: 'hour', 'day' (default), 'week', 'month', 'year' or 'any'.  

order:         (string) the order in which YouTube delivers the results:  'relevance' (default), 'age', 'views', 'rating'.  

duration:      (string) the length of returned videos: any (default), short (<4 mins), long (>20 mins).  

quantity:      (number) the desired number of results. If available the actual number of results will match or exceed this number (default: 100).    

Channel options

Required:

id:            (24 character string commencing with 'UC') the channel id;  

Optional:

order:         (string) the order in which YouTube delivers the results: 'new' (default), 'old', 'views', 'about' (collects channel metadata).  

quantity:      (number) the desired number of videos. If available the actual number of results will match or exceed this number. (default: 60)  

General class methods

To return an object of fetched metadata:

let info = object.info(exclusions);

where exclusions is an array of field names to ignore.

To update class options before performing another fetch on an existing object:

object.updateOptions(newOptions);

General object properties

object.status               The result of the last fetch(), continued() or download() operations: Either OK,NOK or ERROR
object.reason               The reason for status NOK or ERROR.
object.updated              Timestamp of last fetch.
object.data                 The raw YouTube data collected - a string or array of strings for search/channel results

Collected metadata and media properties

session.context             Information YouTube collects about you. Required by all innertube requests.
session.key                 The innertube api key. Required by all innertube requests. 
session.sts                 Signature timestamp of the current player. 
session.id_token            An identifier not currently used by ytcog but can be used for direct watch html requests as a 'x-youtube-identity-token' header.
session_token               A YouTube session identifier not currently used by ytcog but which is used in some direct post requests.
session.playerUrl           Url of the current player associated with the session. 
session.loggedIn            Boolean of whether you are considered to be logged in or out of YouTube. It is recommended to be logged in.

search.videos               Array of video objects fetched by fetch() and continued() methods.
search.quantity             The number of video results collected
search.page                 The maximum page number of collected data.

channel.videos              Array of video objects fetched by fetch() and continued() methods.
channel.views               Number of channel views
channel.subscribers         Number of subscribers
channel.joined              Timestamp of when the channel began
channel.profiled            Timestamp of last profile (order:'about') fetch
channel.latest              Timestamp of latest video published collected.
channel.author              Displayed name of channel
channel.description         Description of channel
channel.thumbnail           Thumbnail url of the channel logo
channel.country             Country of origin of channel
channel.tags                Array of tags to identify the channel contents
channel.quantity            The number of video results collected
channel.page                The maximum page number of collected data. 

video.channel               The video's channel id
video.duration              The duration of the video in seconds.
video.expiry                The lifespan in seconds of the video streams collected
video.views                 The number of views received by the video
video.rating                The rating of the video (1 to 5)
video.published             Timestamp of published time (if known or 0)
video.downloaded            Timestamp of when you finished downloading the video (or 0).
video.canEmbed              The video csan be watched embedded on 3rd party html page.
video.isLive                The video is a live event.
video.title                 The title of the video.
video.category              The YouTube category of the video (ie sport, games, people & blogs etc.)
video.description           The description of the video.
video.author                The display name of the video author.
video.channelThumb          Thumbnail url of the channel logo
video.country               Country of origin of the channel
video.fn                    The filepath of the downloaded video (or an empty string)
video.keywords              An array of keywords to identify the video contents
video.storyBoards           A user friendly extraction of the storyboard images 
video.videoStreams          A user friendly extraction of the video streams with urls deciphered/encoded ready for download.
video.audioStreams          A user friendly extraction of the audio streams with urls deciphered/encoded ready for download.
video.formats               An array of the original json streams
video.cancelled             Whether you have cancelled the current download.
video.streamInfo            A convenient object that gives index numbers and concise stream information for easy stream selection.
video.hasMedia              A boolean to check if media streams are available.
video.timeToExpiry          The number of seconds left before the media streams expire.
Clone this wiki locally