eashish93 / youtube-downloader-app Goto Github PK
View Code? Open in Web Editor NEWSource code for youtube-downloader app. Step by step tutorial at:
Home Page: https://hackprogramming.com
License: MIT License
Source code for youtube-downloader app. Step by step tutorial at:
Home Page: https://hackprogramming.com
License: MIT License
Forgive me if i'm missing something obvious here, however i'm having some issues setting this up and not sure if it's something my end or not.
When i submit a video, it's shows Not Found 404 after re-directing to /video.
NotFoundError: Not Found
at app.use.res.locals.message (/youtube/app.js:27:8)
at Layer.handle [as handle_request] (/youtube/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/youtube/node_modules/express/lib/router/index.js:317:13)
at /youtube/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/youtube/node_modules/express/lib/router/index.js:335:12)
at next (/youtube/node_modules/express/lib/router/index.js:275:10)
at /youtube/node_modules/express/lib/router/index.js:635:15
at next (/youtube/node_modules/express/lib/router/index.js:260:14)
at Function.handle (/youtube/node_modules/express/lib/router/index.js:174:3)
at router (/youtube/node_modules/express/lib/router/index.js:47:12)
Here is my Index,js
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
module.exports = router;
// default endpoint
router.get('/', function(req, res) {
res.render('index', { title: 'Youtube Downloader'$
// new endpoint
});
router.post('/video', function(req, res, next) {
res.render('listvideo', {});
})
// ... other code
// utility function to convert bytes to human reada$
function bytesToSize(bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return '0 Byte';
var i = parseInt(Math.floor(Math.log(bytes) / Ma$
return Math.round(bytes / Math.pow(1024, i), 2) $
};
var ytdl = require('youtube-dl');
router.post('/video', function(req, res, next) {
var url = req.body.url,
formats = [];
ytdl.getInfo(url, ['--youtube-skip-dash-manifes$
if(err) return res.render('listvideo', {err$
// push all video formats for download (ski$
info.formats.forEach(function(item) {
if(item.format_note !== 'DASH audio' &&$
item.filesize = item.filesize ? byt$
formats.push(item);
}
});
res.render('listvideo', {meta: {id: info.id$
})
})
Thanks
if you have linux system you need to type this comand in your terminal
sudo apt install node-express-generator
After pasting the link in textbox and pressing get links encountered an error.
internal/child_process.js:325
throw errnoException(err, 'spawn');
^
Error: spawn UNKNOWN
at _errnoException (util.js:1041:11)
at ChildProcess.spawn (internal/child_process.js:325:11)
at exports.spawn (child_process.js:493:9)
at exports.execFile (child_process.js:208:15)
at call (C:\Users\user\Desktop\ndejs\youtube-downloader-app-master\node_modules\youtube-dl\lib\youtube-dl.js:163:5)
at Function.getInfo (C:\Users\user\Desktop\ndejs\youtube-downloader-app-master\node_modules\youtube-dl\lib\youtube-dl.js:285:5)
at Request._callback (C:\Users\user\Desktop\ndejs\youtube-downloader-app-master\routes\index.js:28:18)
at Request.self.callback (C:\Users\user\Desktop\ndejs\youtube-downloader-app-master\node_modules\request\request.js:186:22)
at emitTwo (events.js:125:13)
at Request.emit (events.js:213:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node ./bin/www
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
router.get('/', function(req, res) {
^
ReferenceError: router is not defined
at Object. (C:\Users\jacky\Desktop\blue site\youtube\routes\index.js:2:1)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object. (C:\Users\jacky\Desktop\blue site\youtube\app.js:7:19)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node ./bin/www
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\jacky\AppData\Roaming\npm-cache_logs\2020-10-07T17_52_56_078Z-debug.log
if(pattern.test(resp.request.uri.href)) {
^
TypeError: Cannot read property 'request' of undefined
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.