Namespace: InfoUtils

utils/info-utils~InfoUtils

A namespace utility to working with YouTube video information object.

Since:
  • 2.0.0
Source:

Methods

(static) getAuthor(vInfo) → {AuthorInfo}

Extracts and normalizes author information from the provided video info object.

Parameters:
Name Type Description
vInfo ytdl.videoInfo

The video information object.

Since:
  • 2.0.0
Source:
Throws:

If the vInfo is not a plain object.

Type
InvalidTypeError
Returns:

An object containing normalized author details.

Type
AuthorInfo

(static) getCaptions(vInfo) → {Array.<object>}

Extracts and returns the available captions of the video.

Parameters:
Name Type Description
vInfo ytdl.videoInfo

The video information object.

Since:
  • 2.0.0
Source:
Throws:

If the vInfo is not a plain object.

Type
InvalidTypeError
Returns:

An array of caption track objects.

Type
Array.<object>

(static) getCategory(vInfo) → {string|null}

Extracts and returns the category of the video.

Parameters:
Name Type Description
vInfo ytdl.videoInfo

The video information object.

Since:
  • 2.0.0
Source:
Throws:

If the vInfo is not a plain object.

Type
InvalidTypeError
Returns:

The category of the video, or null if not available.

Type
string | null

(static) getDescription(vInfo) → {string|null}

Extracts and returns the description of the video.

Parameters:
Name Type Description
vInfo ytdl.videoInfo

The video information object.

Since:
  • 2.0.0
Source:
Throws:

If the vInfo is not a plain object.

Type
InvalidTypeError
Returns:

The description of the video, or null if not available.

Type
string | null

(static) getDuration(vInfo) → {number}

Extracts and returns the duration of a video in seconds.

Parameters:
Name Type Description
vInfo ytdl.videoInfo

The video information object.

Since:
  • 2.0.0
Source:
Throws:

If the vInfo is not a plain object.

Type
InvalidTypeError
Returns:

The duration of the video in seconds. Returns 0 if the duration is not available.

Type
number

(static) getFormats(vInfo, filteropt) → {Array.<YTFormatObject>}

Extracts and returns the available formats of the video, optionally filtered by type.

Filter Types

Name Description
'all' Returns all the video formats and pass the filtering process.
'both' Returns the video formats that have both video and audio content.
'audio' | 'audioonly' Returns the video formats that have audio content only.
'video' | 'videoonly' Returns the video formats that have video content only.
Parameters:
Name Type Attributes Default Description
vInfo ytdl.videoInfo

The video information object.

filter 'all' | 'both' | 'audio' | 'audioonly' | 'video' | 'videoonly' <optional>
'all'

The filter type.

Since:
  • 2.0.0
Source:
Throws:

If the vInfo is not a plain object or the filter type is invalid.

Type
InvalidTypeError
Returns:

An array of format objects.

Type
Array.<YTFormatObject>

(static) getKeywords(vInfo) → {Array.<string>}

Extracts and returns the keywords of the video.

Parameters:
Name Type Description
vInfo ytdl.videoInfo

The video information object.

Since:
  • 2.0.0
Source:
Throws:

If the vInfo is not a plain object.

Type
InvalidTypeError
Returns:

An array of keywords, or an empty array if not available.

Type
Array.<string>

(static) getLikes(vInfo) → {number|null}

Extracts and returns the like count of the video.

Parameters:
Name Type Description
vInfo ytdl.videoInfo

The video information object.

Since:
  • 2.0.0
Source:
Throws:

If the vInfo is not a plain object.

Type
InvalidTypeError
Returns:

The like count of the video, or null if not available.

Type
number | null

(static) getPublishDate(vInfo) → {string|null}

Extracts and returns the publish date of the video.

Parameters:
Name Type Description
vInfo ytdl.videoInfo

The video information object.

Since:
  • 2.0.0
Source:
Throws:

If the vInfo is not a plain object.

Type
InvalidTypeError
Returns:

The publish date of the video, or null if not available.

Type
string | null

(static) getSubs(vInfo) → {number|null}

An alias for getSubscribers function.

It extracts the subscriber count of the video's author, or returns null if the subscriber count is not available.

Parameters:
Name Type Description
vInfo ytdl.videoInfo

The video information object.

Since:
  • 2.0.0
Source:
Returns:

The subscriber count of the video, or null if not available.

Type
number | null

(static) getSubscribers(vInfo) → {number|null}

Extracts and returns the subscriber count of the video's author.

Parameters:
Name Type Description
vInfo ytdl.videoInfo

The video information object.

Since:
  • 2.0.0
Source:
Throws:

If the vInfo is not a plain object.

Type
InvalidTypeError
Returns:

The subscriber count of the author, or null if not available.

Type
number | null

(static) getTitle(vInfo) → {string|null}

Extracts and returns the title of the video from the provided video info object.

Parameters:
Name Type Description
vInfo ytdl.videoInfo

The video information object.

Since:
  • 2.0.0
Source:
Throws:

If the vInfo is not a plain object.

Type
InvalidTypeError
Returns:

The title of the video, or null if not available.

Type
string | null

(static) getUploadDate(vInfo) → {string|null}

Extracts and returns the upload date of the video.

Parameters:
Name Type Description
vInfo ytdl.videoInfo

The video information object.

Since:
  • 2.0.0
Source:
Throws:

If the vInfo is not a plain object.

Type
InvalidTypeError
Returns:

The upload date of the video, or null if not available.

Type
string | null

(static) getViewers(vInfo) → {number|null}

Extracts and returns the view count of the video.

Parameters:
Name Type Description
vInfo Object

The video information object.

Since:
  • 2.0.0
Source:
Throws:

If the vInfo is not a plain object.

Type
InvalidTypeError
Returns:

The view count of the video, or null if not available.

Type
number | null

(static) getViews(vInfo) → {number|null}

An alias for getViewers function.

It extracts the view count of the video, or returns null if the view count is not available.

Parameters:
Name Type Description
vInfo ytdl.videoInfo

The video information object.

Since:
  • 2.0.0
Source:
Returns:

The view count of the video, or null if not available.

Type
number | null

(static) isAgeRestricted(vInfo) → {boolean}

Checks whether the video content from the given video info have age-restriction.

Parameters:
Name Type Description
vInfo ytdl.videoInfo

The video information object.

Since:
  • 2.0.0
Source:
Returns:

true if the video content is age-restricted, false otherwise.

Type
boolean

(static) isPrivate(vInfo) → {boolean}

Checks whether the video content from the given video info is private.

Parameters:
Name Type Description
vInfo ytdl.videoInfo

The video information object.

Since:
  • 2.0.0
Source:
Returns:

true if the video content is private, false otherwise.

Type
boolean