mirror of
https://github.com/LuanRT/googlevideo.git
synced 2026-06-13 00:32:11 +00:00
chore: update onesie example
This commit is contained in:
@@ -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<OnesieRequest> {
|
||||
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<OnesieRequ
|
||||
poToken: poToken ? base64ToU8(poToken) : undefined,
|
||||
playbackCookie: undefined,
|
||||
clientInfo: {
|
||||
clientName: 7,
|
||||
clientVersion: innertube.session.context.client.clientVersion
|
||||
clientName: parseInt(Constants.CLIENTS.TV.NAME_ID),
|
||||
clientVersion: clonedInnerTubeContext.client.clientVersion
|
||||
}
|
||||
},
|
||||
bufferedRanges: [],
|
||||
@@ -169,7 +168,8 @@ async function getBasicInfo(innertube: Innertube, videoId: string): Promise<YT.V
|
||||
queryParams.push(`id=${onesieRequest.encodedVideoId}`);
|
||||
queryParams.push('&opr=1');
|
||||
queryParams.push('&por=1');
|
||||
queryParams.push('rn=1');
|
||||
queryParams.push('&rn=1');
|
||||
queryParams.push('&cmo:sensitive_content=yes');
|
||||
|
||||
url += `&${queryParams.join('&')}`;
|
||||
|
||||
|
||||
24
examples/onesie-request/package-lock.json
generated
24
examples/onesie-request/package-lock.json
generated
@@ -9,7 +9,7 @@
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"youtubei.js": "github:LuanRT/YouTube.js"
|
||||
"youtubei.js": "^11.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@bufbuild/protobuf": {
|
||||
@@ -26,9 +26,10 @@
|
||||
}
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.12.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz",
|
||||
"integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==",
|
||||
"version": "8.14.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz",
|
||||
"integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
@@ -37,12 +38,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/jintr": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/jintr/-/jintr-2.1.1.tgz",
|
||||
"integrity": "sha512-89cwX4ouogeDGOBsEVsVYsnWWvWjchmwXBB4kiBhmjOKw19FiOKhNhMhpxhTlK2ctl7DS+d/ethfmuBpzoNNgA==",
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/jintr/-/jintr-3.0.2.tgz",
|
||||
"integrity": "sha512-5g2EBudeJFOopjAX4exAv5OCCW1DgUISfoioCsm1h9Q9HJ41LmnZ6J52PCsqBlQihsmp0VDuxreAVzM7yk5nFA==",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/LuanRT"
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"acorn": "^8.8.0"
|
||||
}
|
||||
@@ -64,14 +66,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/youtubei.js": {
|
||||
"version": "10.4.0",
|
||||
"resolved": "git+ssh://git@github.com/LuanRT/YouTube.js.git#7a3932682112a0d76c04f65ae35445fc35403a00",
|
||||
"version": "11.0.1",
|
||||
"resolved": "https://registry.npmjs.org/youtubei.js/-/youtubei.js-11.0.1.tgz",
|
||||
"integrity": "sha512-ZsbOd+5XF2Ofi3FrLMfYd+f9g9H8xswlouFhjhOqbwT68dMJtX6CRGsHNj5VTFCR/+L/865x1lnUlllB2dDDTA==",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/LuanRT"
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@bufbuild/protobuf": "^2.0.0",
|
||||
"jintr": "^2.1.1",
|
||||
"jintr": "^3.0.2",
|
||||
"tslib": "^2.5.0",
|
||||
"undici": "^5.19.1"
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"youtubei.js": "github:LuanRT/YouTube.js"
|
||||
"youtubei.js": "^11.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user