diff --git a/play-dl/YouTube/search.ts b/play-dl/YouTube/search.ts index 251d955..100e547 100644 --- a/play-dl/YouTube/search.ts +++ b/play-dl/YouTube/search.ts @@ -11,10 +11,9 @@ enum SearchType { Channel = 'EgIQAg%253D%253D', } -export async function search(search :string, options? : ParseSearchInterface): Promise<(Video | Channel | PlayList)[]> { +export async function search(search :string, options : ParseSearchInterface = {}): Promise<(Video | Channel | PlayList)[]> { let url = 'https://www.youtube.com/results?search_query=' + search.replaceAll(' ', '+') - if(!options) options = { type : "video"} - if(!options.type) options.type = "video" + options.type ??= "video" if(!url.match('&sp=')){ url += '&sp=' switch(options?.type){ diff --git a/play-dl/YouTube/utils/request.ts b/play-dl/YouTube/utils/request.ts index 9164d9e..5b2c13a 100644 --- a/play-dl/YouTube/utils/request.ts +++ b/play-dl/YouTube/utils/request.ts @@ -7,7 +7,7 @@ interface RequestOpts extends RequestOptions{ method? : "GET" | "POST" } -async function https_getter(req_url : string, options : RequestOpts = {}): Promise{ +function https_getter(req_url : string, options : RequestOpts = {}): Promise{ return new Promise((resolve, reject) => { let s = new URL(req_url) options.method ??= "GET"