From a6eb8821cba9d3c993c6add58e01715b40bf2a85 Mon Sep 17 00:00:00 2001 From: Luan Date: Sat, 2 Nov 2024 02:52:10 -0300 Subject: [PATCH] chore: update onesie example --- examples/onesie-request/main.ts | 16 +++++++-------- examples/onesie-request/package-lock.json | 24 +++++++++++++---------- examples/onesie-request/package.json | 2 +- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/examples/onesie-request/main.ts b/examples/onesie-request/main.ts index b1e5c99..74abbe1 100644 --- a/examples/onesie-request/main.ts +++ b/examples/onesie-request/main.ts @@ -1,4 +1,4 @@ -import Innertube, { UniversalCache } from 'youtubei.js'; +import Innertube, { Constants, UniversalCache } from 'youtubei.js'; import { type Context, Endpoints, YT } from 'youtubei.js'; import GoogleVideo, { base64ToU8, PART, Protos, QUALITY } from '../../dist/src/index.js'; import { decryptResponse, encryptRequest } from './utils.js'; @@ -62,12 +62,11 @@ type OnesieRequest = { async function prepareOnesieRequest(args: OnesieRequestArgs): Promise { const { videoId, poToken, clientConfig, innertube } = args; const { clientKeyData, encryptedClientKey, onesieUstreamerConfig } = clientConfig; - - const clonedInnerTubeContext: Context = JSON.parse(JSON.stringify(innertube.session.context)); + const clonedInnerTubeContext: Context = structuredClone(innertube.session.context); // Change or remove these if you want to use a different client. I chose TVHTML5 purely for testing. - clonedInnerTubeContext.client.clientName = 'TVHTML5'; - clonedInnerTubeContext.client.clientVersion = '7.20240717.18.00'; + clonedInnerTubeContext.client.clientName = Constants.CLIENTS.TV.NAME; + clonedInnerTubeContext.client.clientVersion = Constants.CLIENTS.TV.VERSION; const playerRequestJson = { context: clonedInnerTubeContext, @@ -126,8 +125,8 @@ async function prepareOnesieRequest(args: OnesieRequestArgs): Promise