diff --git a/deno/package.json b/deno/package.json index 85250e6f..425e1400 100644 --- a/deno/package.json +++ b/deno/package.json @@ -1,6 +1,6 @@ { "name": "youtubei.js", - "version": "6.1.0", + "version": "6.2.0", "description": "A wrapper around YouTube's private API. Supports YouTube, YouTube Music, YouTube Kids and YouTube Studio (WIP).", "type": "module", "types": "./dist/src/platform/lib.d.ts", diff --git a/deno/src/core/Session.ts b/deno/src/core/Session.ts index 387e617c..3379029c 100644 --- a/deno/src/core/Session.ts +++ b/deno/src/core/Session.ts @@ -217,10 +217,17 @@ export default class Session extends EventEmitterLike { ) { let session_data: SessionData; + const session_args = { lang, location, time_zone: tz, device_category, client_name, enable_safety_mode, visitor_data }; + if (generate_session_locally) { - session_data = this.#generateSessionData({ lang, location, time_zone: tz, device_category, client_name, enable_safety_mode, visitor_data }); + session_data = this.#generateSessionData(session_args); } else { - session_data = await this.#retrieveSessionData({ lang, location, time_zone: tz, device_category, client_name, enable_safety_mode, visitor_data }, fetch); + try { + // This can fail if the data changes or the request is blocked for some reason. + session_data = await this.#retrieveSessionData(session_args, fetch); + } catch (err) { + session_data = this.#generateSessionData(session_args); + } } return { ...session_data, account_index }; diff --git a/deno/src/parser/classes/misc/Format.ts b/deno/src/parser/classes/misc/Format.ts index 93a36ccb..2e51eb62 100644 --- a/deno/src/parser/classes/misc/Format.ts +++ b/deno/src/parser/classes/misc/Format.ts @@ -104,7 +104,7 @@ export default class Format { this.language = xtags?.find((x: string) => x.startsWith('lang='))?.split('=')[1] || null; this.is_dubbed = audio_content === 'dubbed'; this.is_descriptive = audio_content === 'descriptive'; - this.is_original = audio_content === 'original' || !this.is_dubbed || !this.is_descriptive; + this.is_original = audio_content === 'original' || (!this.is_dubbed && !this.is_descriptive); if (Reflect.has(data, 'audioTrack')) { this.audio_track = {