Skip to content

Session

gatecrasher777 edited this page Sep 9, 2021 · 1 revision

Session

Methods

constructor

const session = ytcog.Session([cookie,userAgent]);

cookie is a browser cookie of a logged-in youtube account (optional). Default: "". userAgent is a browser agent string (optional). By default ytcog will choose one for you.

fetch

fetch() get youtube configuration data and associated player methods. Run once to start a session.

session.fetch();

Properties

Session objects can have the following properties.

session.status       (string) The result of the last fetch(), continued() or download() operations: Either OK,NOK or ERROR
session.reason       (string) The reason for status NOK or ERROR.
session.data         (string) or [(string)] The raw YouTube data fetched.
session.transferred  (number) Cumulative number of bytes of incoming data (compressed with gzip). 
session.debugOn      (boolean) default is false. Set to true to get error information in the console.
session.context      (object) Information YouTube collects about you. Required by all innertube requests.
session.key          (string) The innertube api key. Required by all innertube requests. 
session.sts          (string) Signature timestamp of the current player. 
session.id_token     (string) 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        (string) A YouTube session identifier not currently used by ytcog but which is used in some direct post requests.
session.playerUrl    (string) Url of the current player associated with the session. 
session.player       (Player) the ytcog.Player class object linked to the session.
session.loggedIn     (boolean) Boolean of whether you are considered to be logged in or out of YouTube. It is recommended to be logged in.
Clone this wiki locally