-
Notifications
You must be signed in to change notification settings - Fork 826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to extract nCode from base.js #1301
Comments
Quick fix is to change
At line 58 in lib/sig.js |
Thanks it saved my day |
I have update the code as described in the thread let functionName = utils.between(body, At line 58 in lib/sig.js. But still I am getting error with code: 403. |
That is issue #1295 and I think it is specific to blocking direct watch URL requests. In my projects I use the innertube API and have not experienced any 403 messages. |
thank u, bro |
Solutions are discuss in #1295 |
Instead of let functionName = utils.between(body, 'c=a.get(b))&&(c=', '(c)'); |
Again not working |
It seems that they keep changing it. Now the expression looks like that: ... b=a.j.n||null)&&(b=oDa[0](b), ... So, probably some kind of a more semantic approach should be devised. |
like this ?
|
Without the |
Please write the full code here again:- @corwin-of-amber
|
this is working |
Hello @StepsOnes This one not working Here is my code Please check it if I am wrong share with correct code. const extractNCode = () => { |
It's working for me const extractNCode = () => {
let functionName = utils.between(body, 'b=a.j.n||null)&&(b=', '(b)');
if (functionName.includes('[')) functionName = utils.between(body, `var ${functionName.split('[')[0]}=[`, `]`);
if (functionName && functionName.length) {
const functionStart = `${functionName}=function(a)`;
const ndx = body.indexOf(functionStart);
if (ndx >= 0) {
const subBody = body.slice(ndx + functionStart.length);
const functionBody = `var ${functionStart}${utils.cutAfterJS(subBody)};${functionName}(ncode);`;
functions.push(functionBody);
}
}
}; |
I am checking it. it's not working properly. I think YouTube is asking for a captcha to download and convert video. @StepsOnes |
Rather than trying to find the obfuscated n function name from elsewhere in the player code, this looks for the n code function directly.
|
Can i use this code? |
Replaces lines 57-69 in lib/sig.js Doesn't fix 403 issues, though, which is another YouTube barrier entirely. |
Showing 502 bad gateway error |
A bracket was missing. Please try again. |
Its working very slow sometime not fetch data. Any better solution? |
YouTube now requires POST requests with a specific byte array payload in order to download longer high quality files. For me, this is still a work in progress. Maybe someone else has found a solution. |
But do you have any code-level solution where I can change my API code? Its better than previous code. |
it doesn't work again |
which it wont. And it will keep breaking time and time again. That is why it is better to locate the function directly. The method I posted above still works. |
Downloaded current version
The output is
and in the directory listing:
So yes, my function works. When I use the videoId (4jnaYhnmYlo) in your example:
|
Still not working youtube again fix it |
This work for me, but i modified the functionBody to: Thanks for the solution. |
Not working i am trying still got an error |
What is the error that is presented to you? An 403? |
Yes showing 403 error progress bar not working still stuck on progress bar |
Here is code which you provided See if i do mistake let me know @JoaoEmanuell const extractNCode = () => { |
I did notice that sending the Range header (e.g. |
So what should we do now? @corwin-of-amber |
I am not sure as it does not seem like node-ytdl-core is even maintained. I am trying to trace what https://github.com/yt-dlp/yt-dlp is doing. Their approach seems to be robust, and they have cached ncode functions (probably hosted somewhere). |
I really don't understand why this isn't working, but distube works fine. |
Yes, these guys are using the player API, which is also what yt-dlp is doing. Probably a more stable approach, so perhaps we should just declare distubejs as the "canonical" YouTube downloader for Node.js. |
This library is f*****ed up last 1 month not working. i will not recommended |
I'm currently working on the same thing too |
Hmm... Were you able to download and watch the video? If so, please share your code. I tried it few days ago but urls returned 403 error |
My code is a adaptation of react-native-ytdl. I tested the code in node, but not work (403 error), however the code works in react native, i really don't know why this occurs. Tip: change the "Logger.debug" for "console.log" In the future, i go adapt the distube to react native, when the node-ytdl-core doesnt's work anymore. |
Okay, good. Are you currently making use of ytdl-core or distube ? |
As a base I'm using ytdl-core but a large part of the sig (like the part of extracting functions) was adapted from distube, I combined part of the two to make it work in react native. |
One of the variants to bypass 403 is downloading in chunks.
|
Are you able to stream the downloadable video url on a browser? |
Yes, of course. This a example of code:
This code works great. However, keep in mind that the audio might be separate. |
Wow, it's working perfectly now. Now, if i want to download audio and video, i'll repeat same process then merge it with ffmpeg |
Yes, it will make the code a bit more complex, but that's exactly how you need to proceed. |
Okay, thank you so much . Check, i just started following you |
Since last evening the ytdl isn't working, it's showing all the formats and video info , but the the video urls aren't working , i checked the code and it seems like after YouTube got updated , the ncode extraction isn't working.
The text was updated successfully, but these errors were encountered: