Skip to content

Commit e37a8de

Browse files
committed
youtube: provide own JS interpreter
since the data should be side-effect free, this should be fine for now, but maybe it might be a good idea to look into a proper sandboxed environment in the future.
1 parent 35197b9 commit e37a8de

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

api/src/processing/services/youtube.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ import { env } from "../../config.js";
77
import { getCookie } from "../cookie/manager.js";
88
import { getYouTubeSession } from "../helpers/youtube-session.js";
99

10+
// https://github.com/LuanRT/YouTube.js/pull/1052
11+
Platform.shim.eval = async (data, env) => {
12+
const properties = [];
13+
14+
if (env.n) {
15+
properties.push(`n: exportedVars.nFunction("${env.n}")`)
16+
}
17+
18+
if (env.sig) {
19+
properties.push(`sig: exportedVars.sigFunction("${env.sig}")`)
20+
}
21+
22+
const code = `${data.output}\nreturn { ${properties.join(', ')} }`;
23+
24+
return new Function(code)();
25+
}
26+
1027
const PLAYER_REFRESH_PERIOD = 1000 * 60 * 15; // ms
1128

1229
let innertube, lastRefreshedAt;

0 commit comments

Comments
 (0)