Simplify type check in the YouTube info functions
This commit is contained in:
parent
174b6e8cee
commit
a04f52c44d
@ -100,8 +100,7 @@ export function extractID(url: string): string {
|
|||||||
* @returns Video Basic Info {@link InfoData}.
|
* @returns Video Basic Info {@link InfoData}.
|
||||||
*/
|
*/
|
||||||
export async function video_basic_info(url: string, options: InfoOptions = {}): Promise<InfoData> {
|
export async function video_basic_info(url: string, options: InfoOptions = {}): Promise<InfoData> {
|
||||||
if (url === null || url === undefined || typeof url !== 'string')
|
if (typeof url !== 'string') throw new Error('url parameter is not a URL string or a string of HTML');
|
||||||
throw new Error('url parameter is not a URL string or a string of HTML');
|
|
||||||
let body: string;
|
let body: string;
|
||||||
if (options.htmldata) {
|
if (options.htmldata) {
|
||||||
body = url;
|
body = url;
|
||||||
@ -207,8 +206,7 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
|
|||||||
* @returns Deciphered Video Info {@link StreamInfoData}.
|
* @returns Deciphered Video Info {@link StreamInfoData}.
|
||||||
*/
|
*/
|
||||||
export async function video_stream_info(url: string, options: InfoOptions = {}): Promise<StreamInfoData> {
|
export async function video_stream_info(url: string, options: InfoOptions = {}): Promise<StreamInfoData> {
|
||||||
if (url === null || url === undefined || typeof url !== 'string')
|
if (typeof url !== 'string') throw new Error('url parameter is not a URL string or a string of HTML');
|
||||||
throw new Error('url parameter is not a URL string or a string of HTML');
|
|
||||||
let body: string;
|
let body: string;
|
||||||
if (options.htmldata) {
|
if (options.htmldata) {
|
||||||
body = url;
|
body = url;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user