Skip to content

Fix downloader plugin#4069

Merged
ArjixWasTaken merged 2 commits into
pear-devs:masterfrom
trevin-j:master
Nov 26, 2025
Merged

Fix downloader plugin#4069
ArjixWasTaken merged 2 commits into
pear-devs:masterfrom
trevin-j:master

Conversation

@trevin-j

@trevin-j trevin-j commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

TLDR; the only way to fix the downloader is to upgrade youtubei.js to version 16 and specify a js interpreter.

As this comment says, the current hardcoded player id (from #3973) doesn't work anymore. At the moment, the downloader plugin won't work.

I upgraded youtubei.js to version 16, added in the snippet shown here (specifying a js interpreter), and got the downloads to work again.

Changes:

  • Remove hard-coded player_id
    • The specific player_id is blocked now
  • Update youtubei.js dependency to version 16 (fixes download issues)
  • Specify js interpreter for sig function stuff

* Remove hard-coded player_id
  * The specific player_id is blocked now
* Update youtubei.js dependency to version 16 (fixes download issues)
* Specify js interpreter for sig function stuff
);
const ffmpegMutex = new Mutex();

Platform.shim.eval = async (data: Types.BuildScriptResult, env: Record<string, Types.VMPrimative>) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Replace data:·Types.BuildScriptResult,·env:·Record<string,·Types.VMPrimative> with ⏎··data:·Types.BuildScriptResult,⏎··env:·Record<string,·Types.VMPrimative>,⏎

Suggested change
Platform.shim.eval = async (data: Types.BuildScriptResult, env: Record<string, Types.VMPrimative>) => {
Platform.shim.eval = async (
data: Types.BuildScriptResult,
env: Record<string, Types.VMPrimative>,
) => {

);
const ffmpegMutex = new Mutex();

Platform.shim.eval = async (data: Types.BuildScriptResult, env: Record<string, Types.VMPrimative>) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <@typescript-eslint/require-await> reported by reviewdog 🐶
Async arrow function has no 'await' expression.

Platform.shim.eval = async (data: Types.BuildScriptResult, env: Record<string, Types.VMPrimative>) => {
const properties = [];

if(env.n) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Insert ·

Suggested change
if(env.n) {
if (env.n) {

const properties = [];

if(env.n) {
properties.push(`n: exportedVars.nFunction("${env.n}")`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Insert ;

Suggested change
properties.push(`n: exportedVars.nFunction("${env.n}")`)
properties.push(`n: exportedVars.nFunction("${env.n}")`);

const properties = [];

if(env.n) {
properties.push(`n: exportedVars.nFunction("${env.n}")`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <stylistic/semi> reported by reviewdog 🐶
Missing semicolon.

Suggested change
properties.push(`n: exportedVars.nFunction("${env.n}")`)
properties.push(`n: exportedVars.nFunction("${env.n}")`);


const code = `${data.output}\nreturn { ${properties.join(', ')} }`;

return new Function(code)();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <@typescript-eslint/no-unsafe-return> reported by reviewdog 🐶
Unsafe return of a value of type any.


const code = `${data.output}\nreturn { ${properties.join(', ')} }`;

return new Function(code)();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <@typescript-eslint/no-implied-eval> reported by reviewdog 🐶
Implied eval. Do not use the Function constructor to create functions.


const code = `${data.output}\nreturn { ${properties.join(', ')} }`;

return new Function(code)();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <@typescript-eslint/no-unsafe-call> reported by reviewdog 🐶
Unsafe call of a(n) Function typed value.

const code = `${data.output}\nreturn { ${properties.join(', ')} }`;

return new Function(code)();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Insert ;

Suggested change
}
};

const code = `${data.output}\nreturn { ${properties.join(', ')} }`;

return new Function(code)();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <stylistic/semi> reported by reviewdog 🐶
Missing semicolon.

Suggested change
}
};

@rabid-sausage

Copy link
Copy Markdown

I can confirm this works, manually applied the changes and built a working version and can now download without issue.
Myself prior to reading this, I got as far as upgrading youtubei.js to 16 and including meriyah, but could not wok out what to do with the required script, where to insert it, but can see from what you have done it was actually rather simple (still do not know what the script does). The Player ID fix was a quick get-around a bigger problem, found that out on other groups who first offered the Player ID solution.

Thanks for you effort and showing what you have done.

It will be interesting to see if this get pushed in to the next build, as it looks like some parties like youtubei.js, projects that use their code and others which operate similar are now not including this type of function in pre-compiled downloads, requiring individual users to manually insert/adjust the code and build a working copy themselves to gain this and other functions. Maybe a method avoiding getting in to trouble directly.

@LyonDR

LyonDR commented Nov 21, 2025

Copy link
Copy Markdown

I can confirm this works, manually applied the changes and built a working version and can now download without issue. Myself prior to reading this, I got as far as upgrading youtubei.js to 16 and including meriyah, but could not wok out what to do with the required script, where to insert it, but can see from what you have done it was actually rather simple (still do not know what the script does). The Player ID fix was a quick get-around a bigger problem, found that out on other groups who first offered the Player ID solution.

Thanks for you effort and showing what you have done.

It will be interesting to see if this get pushed in to the next build, as it looks like some parties like youtubei.js, projects that use their code and others which operate similar are now not including this type of function in pre-compiled downloads, requiring individual users to manually insert/adjust the code and build a working copy themselves to gain this and other functions. Maybe a method avoiding getting in to trouble directly.

Can you pass me your app, please?

@ArjixWasTaken

ArjixWasTaken commented Nov 26, 2025

Copy link
Copy Markdown
Member

LGTM, thanks for your contribution!

@ArjixWasTaken ArjixWasTaken merged commit 4fba3ff into pear-devs:master Nov 26, 2025
1 check failed
@its-iris

its-iris commented Nov 29, 2025

Copy link
Copy Markdown
Contributor

I know the eval example is from the youtubei.js repo but wouldn't it be better to run the code using node:vm with an empty context like here ? It's still not good enough to run untrusted code but it should be the best option without an extra dependency.

@ArjixWasTaken

Copy link
Copy Markdown
Member

@its-iris would you like to open a PR?

@LyonDR

LyonDR commented Dec 1, 2025

Copy link
Copy Markdown

Can someone explained how to do that like step by step for noobs?

I recommend asking chatgpt 😅 That's what I did.

You send him the link to this PR and ask him to guide you on how to apply the fix.

@JellyBrick JellyBrick added bug Something isn't working dependencies Pull requests that update a dependency file labels Feb 1, 2026
@JellyBrick

Copy link
Copy Markdown
Member

I know the eval example is from the youtubei.js repo but wouldn't it be better to run the code using node:vm with an empty context like here ? It's still not good enough to run untrusted code but it should be the best option without an extra dependency.

I've tried several approaches, but BGUtils doesn't work properly in a node:vm environment. (It might look like it's working, but the values aren't valid)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants