Skip to content

Commit

Permalink
handle new changes from youtube.js v12
Browse files Browse the repository at this point in the history
  • Loading branch information
unixfox committed Dec 9, 2024
1 parent 1c1b4cc commit 5aba65b
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 9 deletions.
1 change: 1 addition & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"hono/bearer-auth": "jsr:@hono/hono@^4.6.5/bearer-auth",
"youtubei.js": "https://raw.githubusercontent.com/LuanRT/YouTube.js/refs/tags/v12.0.0-deno/deno.ts",
"youtubei.js/Utils": "https://raw.githubusercontent.com/LuanRT/YouTube.js/refs/tags/v12.0.0-deno/deno/src/utils/Utils.ts",
"youtubei.js/NavigationEndpoint": "https://raw.githubusercontent.com/LuanRT/YouTube.js/refs/tags/v12.0.0-deno/deno/src/parser/classes/NavigationEndpoint.ts",
"jsdom": "npm:[email protected]",
"bgutils": "https://esm.sh/[email protected]",
"estree": "https://esm.sh/@types/[email protected]",
Expand Down
203 changes: 201 additions & 2 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 17 additions & 7 deletions src/lib/helpers/youtubePlayerReq.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Innertube, ApiResponse } from "youtubei.js";
import { Store } from "@willsoto/node-konfig-core";
import NavigationEndpoint from "youtubei.js/NavigationEndpoint";

export const youtubePlayerReq = async (innertubeClient: Innertube, videoId: string, konfigStore: Store): Promise<ApiResponse> => {
const innertubeClientOauthEnabled = konfigStore.get(
Expand All @@ -10,11 +11,20 @@ export const youtubePlayerReq = async (innertubeClient: Innertube, videoId: stri
if (innertubeClientOauthEnabled)
innertubeClientUsed = "TV";

return await innertubeClient.actions.execute('/player', {
video_id: videoId,
// @ts-ignore Unable to import type InnerTubeClient
client: innertubeClientUsed,
sts: innertubeClient.session.player?.sts,
po_token: innertubeClient.session.po_token
});
const watch_endpoint = new NavigationEndpoint({ watchEndpoint: { videoId: videoId } });

return await watch_endpoint.call(innertubeClient.actions, {
playbackContext: {
contentPlaybackContext: {
vis: 0,
splay: false,
lactMilliseconds: '-1',
signatureTimestamp: innertubeClient.session.player?.sts
}
},
serviceIntegrityDimensions: {
poToken: innertubeClient.session.po_token
},
innertubeClientUsed
});
};

0 comments on commit 5aba65b

Please sign in to comment.