You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
core.get('/youtube-converter/download',asyncfunction(req,res,next){constqueryObject=url.parse(req.url,true).query;varvideo=queryObject.url;varquality=queryObject.quality;varfilename=queryObject.name;if(filename==''){filename='youtubetomp4-download';}if(!video.includes('youtube.com/watch?v=')){res.status(403)res.header({'Content-Type': 'text/html'});res.send("<hr><h1 style='text-align:center'>Invalid Youtube Link: "+video+"</h1><hr>");console.log('Invalid Youtube String: '+video);return;}constyoutube=awaitnewInnertube();varstream;if(quality!='mp3'){stream=youtube.download(video.split('=')[1],{format: 'mp4',// Optional, ignored when type is set to audio and defaults to mp4, and I recommend to leave it as it isquality: quality,// if a video doesn't have a specific quality it'll fall back to 360p, also ignored when type is set to audiotype: 'videoandaudio'// can be “video”, “audio” and “videoandaudio”});res.header('Content-Disposition','attachment;filename="'+filename+'.mp4"');res.header('Content-Type',['application/octet-stream','video/mp4']);}else{stream=youtube.download(video.split('=')[1],{type: 'mp3',quality: quality,// if a video doesn't have a specific quality it'll fall back to 360p, also ignored when type is set to audiotype: 'audio'// can be “video”, “audio” and “videoandaudio”});res.header('Content-Disposition','attachment;filename="'+filename+'.mp3"');res.header('Content-Type',['application/octet-stream','video/mp3']);}varstart;stream.on('info',(info)=>{res.stream(stream,info.contentLength);})stream.on('start',(info)=>{start=newDate();console.log('Downloading: '+video.split('=')[1]);});stream.on('end',()=>{varend=newDate();varseconds=(end.getTime()-start.getTime())/1000;console.log(video.split('=')[1]+': '+seconds+' second(s)');})stream.on('error',(error)=>{res.removeHeader('Content-Disposition');res.removeHeader('Content-Type');res.header('Content-Type','text/html');res.write('<head><title>Please Try Again...</title></head><body><h1> Error Converting Video </h1><p>'+JSON.stringify(error)+'</body>');res.end();});});
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have been using the youtube converter for a while now, but for some reason, it stopped working. I didn't change any of my code or anything. Here is the problem. The download works, but the mp4 file outcome is blank/corrupted. Here is an example:
https://user-images.githubusercontent.com/42550108/167036901-592f69c0-62ad-4398-81bb-de4f0255a925.mp4
Although I don't think it's my code, here:
Beta Was this translation helpful? Give feedback.
All reactions