From b7c04214907da8c6715fdc0d56215eeacb7b9e20 Mon Sep 17 00:00:00 2001 From: Luan Date: Mon, 23 Dec 2024 22:29:08 -0300 Subject: [PATCH] chore(Innertube#getSearchSuggestions): Use `fetch_function` instead of `fetch` It is not an InnerTube request. --- src/Innertube.ts | 7 ++++++- src/core/Session.ts | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Innertube.ts b/src/Innertube.ts index a115c5f8..392835ed 100644 --- a/src/Innertube.ts +++ b/src/Innertube.ts @@ -257,7 +257,12 @@ export default class Innertube { if (previous_query) url.searchParams.set('pq', previous_query); - const response = await this.#session.http.fetch(url); + const response = await this.#session.http.fetch_function(url, { + headers: { + 'Cookie': this.#session.cookie || '' + } + }); + const text = await response.text(); const data = JSON.parse(text.replace('window.google.ac.h(', '').slice(0, -1)); diff --git a/src/core/Session.ts b/src/core/Session.ts index 4d69a3e9..b29663dc 100644 --- a/src/core/Session.ts +++ b/src/core/Session.ts @@ -225,6 +225,7 @@ export default class Session extends EventEmitter { public api_version: string; public account_index: number; public po_token?: string; + public cookie?: string; constructor(context: Context, api_key: string, api_version: string, account_index: number, player?: Player, cookie?: string, fetch?: FetchFunction, cache?: ICache, po_token?: string) { super(); @@ -239,6 +240,7 @@ export default class Session extends EventEmitter { this.context = context; this.player = player; this.po_token = po_token; + this.cookie = cookie; } on(type: 'auth', listener: OAuth2AuthEventHandler): void;