node for max - youtube video example
Hi,
i m starting to learn node for max. I jumped into the dedicated repository on the githhub (https://github.com/Cycling74/n4m-examples) and started to play around example.
I m struggling with the example "watch youtube". I think i've followed the set up recommandations, installed the npm module, and run the script. I also watched the tutorial about this particular example. But cant get it working and this is frustrating, because i dont understand my misunderstanding (the js file is exactly the same as in the tutorial): I only get error message : "error fetching video" (no need to mention that i have of course replace the video url several times to test different option).
Does someone know if this example is still up to date? Do we need to install a specific package? (i believe no)
What am i missing?
thx for the help!
just tried it myself and have no luck. i think the script needs to be updated. originally, it used this:
https://www.npmjs.com/package/ytdl-core
(^on that page, describes how YouTube constantly updates their API, so it might need reworking again)
i believe it's simply a matter of tweaking the script to return container formats that are supported by jit.movie (e.g. mp4).
you can pass a filter function as an argument to chooseFormat to ensure this, and whatever other qualifications you'd like:
let format = ytdl.chooseFormat(info.formats, { filter: format => format.quality === 'hd720' && format.hasAudio && format.container === 'mp4'});
I've attached an updated node project that adds the above filter in and seems to work well with the current youtube API. note that it will fail to download if the filter requirements are not met in the passed in URL.
i believe it's simply a matter of tweaking the script to return container formats that are supported by jit.movie (e.g. mp4)
Ha, wasn't sure how simple that might be 😅 (still constantly learning javascript, c++, python, etc. etc. )
Thank you so much for the assist here, Rob!
This works well and is a handy patch. Thanks Rob.