Namespace for utility functions related to YouTube formats.
- Since:
- 2.0.0
- Source:
Methods
(static) hasAudio(fmtObj) → {boolean}
Determines if a given YouTube format object contains audio content.
Parameters:
| Name | Type | Description |
|---|---|---|
fmtObj |
YTFormatObject | ParsedYTFormatObject | A YouTube format object. |
- Since:
- 2.0.0
- Source:
Returns:
true if contains audio content, false otherwise.
- Type
- boolean
(static) hasVideo(fmtObj) → {boolean}
Determines if a given YouTube format object contains video content.
Parameters:
| Name | Type | Description |
|---|---|---|
fmtObj |
YTFormatObject | ParsedYTFormatObject | A YouTube format object. |
- Since:
- 2.0.0
- Source:
Returns:
true if contains video content, false otherwise.
- Type
- boolean
(static) parseFormatObject(fmtObj) → {ParsedYTFormatObject}
Parses a YouTube format object and returns a new object with normalized and enhanced properties.
This function ensures that the format object is properly structured, converts specific properties
to more usable types (e.g., mimeType to an instance of MIMEType, lastModified to an instance
of ), and parses numeric string values into
integers for consistency.DateFormatter
Transformation Details
mimeType: Converted to aMIMETypeinstance.initRangeandindexRange: Converted to objects withstartandendproperties as integers, if they are valid plain objects.lastModified: Converted to ainstance based on the provided microsecond timestamp.DateFormattercontentLength,approxDurationMs, andaudioSampleRate: Parsed into integers if originally strings.
If a property is not defined or improperly formatted, the original value from the input object is retained.
Parameters:
| Name | Type | Description |
|---|---|---|
fmtObj |
YTFormatObject | The format object to parse. Must be a plain object with properties matching the expected YouTube format structure. |
- Since:
- 2.0.0
- Source:
Throws:
-
Throws an error if the input is not a plain object.
- Type
- InvalidTypeError
Returns:
A new YouTube format object with normalized properties.
- Type
- ParsedYTFormatObject