I use node youtube-dl modul with Meteor.js to get information about youtube videos, bc I'm learning to work with Meteor server side, but I get this error I can't solve for half a day. Since youtube-dl is npm modul, can Meteor work with those without further customization?
Client code:
if (Meteor.isClient) {
Template.front.events({
'click #buttondl': function () {
// if submited link to input
if (inputdl.value != '') {
var link = inputdl.value;
Meteor.call('information', link);
}
}
});
}
Server code:
if (Meteor.isServer) {
Meteor.methods({
information: function (link) {
var youtubedl = Meteor.require('youtube-dl');
var url = youtubedl(link);
youtubedl.getInfo(url, function(err, info) {
if (err) throw err;
console.log('id:', info.id);
console.log('title:', info.title);
console.log('url:', info.url);
console.log('thumbnail:', info.thumbnail);
console.log('description:', info.description);
console.log('filename:', info._filename);
console.log('duration:', info.duration);
console.log('format_id:', info.format_id);
});
}
});
}
And the error I'm getting:
W20150709-14:35:19.472(-4)? (STDERR) events.js:72
W20150709-14:35:19.472(-4)? (STDERR) throw er; // Unhandled 'error' event
W20150709-14:35:19.472(-4)? (STDERR) ^
W20150709-14:35:19.477(-4)? (STDERR) Error: Command failed: File "/Users/matejhlavacka/node_modules/youtube-dl/bin/youtube-dl", line 2
W20150709-14:35:19.478(-4)? (STDERR) SyntaxError: Non-ASCII character '\xc4' in file /Users/matejhlavacka/node_modules/youtube-dl/bin/youtube-dl on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
W20150709-14:35:19.478(-4)? (STDERR)
W20150709-14:35:19.478(-4)? (STDERR) at ChildProcess.exithandler (child_process.js:658:15)
W20150709-14:35:19.478(-4)? (STDERR) at ChildProcess.emit (events.js:98:17)
W20150709-14:35:19.478(-4)? (STDERR) at maybeClose (child_process.js:766:16)
W20150709-14:35:19.478(-4)? (STDERR) at Socket.<anonymous> (child_process.js:979:11)
W20150709-14:35:19.478(-4)? (STDERR) at Socket.emit (events.js:95:17)
W20150709-14:35:19.479(-4)? (STDERR) at Pipe.close (net.js:466:12)
EDIT:
I finally solved it. Instead of node-youtube-dl I used basic python youtube-dl and this tutorial on how to execute unix command with Meteor.
Sample code for getting video description on server is the following:
Meteor.methods({
information: function (link) {
exec = Npm.require('child_process').exec;
runCommand = function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if(error !== null) {
console.log('exec error: ' + error);
}
}
exec("youtube-dl --get-description " + link, runCommand);
}
});
It fails probably because you have a python version that is too old, as documented in the youtube-dl FAQ you need python 2.6 or higher. Upgrading python should solve the issue.
Related
I'm just trying to save an mp4 to a different mp4 (before I even start playing around with the different compression settings). What exactly is going wrong here?
const ffmpeg = require('ffmpeg');
try {
var process = new ffmpeg('./original.mp4');
process.then(function (video) {
video
.save('./new.mp4', function (error, file) {
if (!error) {
console.log('Video file: ' + file);
} else {
console.log(error)
}
});
}, function (err) {
console.log('Error: ' + err);
});
} catch (e) {
console.log(e.code);
console.log(e.msg);
}
I get the following error:
Error: Command failed: ffmpeg -i ./original.mp4 ./new.mp4
/bin/sh: ffmpeg: command not found
at ChildProcess.exithandler (child_process.js:390:12)
at ChildProcess.emit (events.js:400:28)
at maybeClose (internal/child_process.js:1055:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) {
killed: false,
code: 127,
signal: null,
cmd: 'ffmpeg -i ./original.mp4 ./new.mp4'
}
It seems that the library you're using tries to call an ffmpeg executable but cannot find it.
I am trying to use https://www.npmjs.com/package/passbook to generate iOS passbook using lambda. The package has the following snippet to sign the manifest:
var sign = execFile("openssl", args, { stdio: "pipe" }, function(error, stdout, stderr) {
var trimmedStderr = stderr.trim();
// Windows outputs some unhelpful error messages, but still produces a valid signature
if (error || (trimmedStderr && trimmedStderr.indexOf('- done') < 0)) {
callback(new Error(error || stderr));
} else {
var signature = stdout.split(/\n\n/)[3];
callback(null, new Buffer(signature, "base64"));
}
});
But when I executed it on AWS Lambda (NodeJs 10), I got the following error:
Error: spawn openssl ENOENT
at /var/task/node_modules/passbook/lib/pass.js:361:16
at exithandler (child_process.js:301:5)
at ChildProcess.errorhandler (child_process.js:313:5)
at ChildProcess.emit (events.js:189:13)
at ChildProcess.EventEmitter.emit (domain.js:441:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
I am thinking the AMI image used does not have openssl installed. Does anyone know if openssl installed and where it is located?
I'm using node.js to run a python script through the web browser. below is the ScriptRunner.js code.
var PythonShell = require('python-shell');
var path = require('path');
exports.runScript = function() {
var options = {
scriptPath: 'D:\L4Project\working code\finalproject\routes'
};
PythonShell.run('sensitive2.py',options, function (err, results) {
if (err) throw err;
console.log('results: %j', results);
});
}
when I run the script in browser it returns error message like below.
D:\L4Project\working code\finalproject\routes\scriptRunner.js:10
if (err) throw err;
^
outes\sensitive2.py': [Errno 22] Invalid argumentg codeinalproject at PythonShell.parseError (D:\L4Project\working code\finalproject\node_modules\python-shell\index.js:191:17)
at terminateIfNeeded (D:\L4Project\working code\finalproject\node_modules\python-shell\index.js:98:28)
at ChildProcess.<anonymous> (D:\L4Project\working code\finalproject\node_modules\python-shell\index.js:89:9)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
I have googles lot and nothing worked. Can Somebody help me to solve the problem?
I'm trying to parse a local CSV file,and the parse process in Meteor bootstrap
var csvStore = new FS.Store.FileSystem("csv", {
path: "countrycode.csv", //optional, default is "/cfs/files" path within app container
// transformWrite: myTransformWriteFunction, //optional
// transformRead: myTransformReadFunction, //optional
// maxTries: 1 //optional, default 5
});
var Csv = new FS.Collection("csv", {
stores: [csvStore]
});
Papa.parse(Csv, {
complete: function(results) {
console.log("Finished:", results.data);
}
});
error msg
=> Exited with code: 8
W20151220-11:33:05.127(8)? (STDERR)
W20151220-11:33:05.130(8)? (STDERR) /Users/apple/.meteor/packages/meteor-tool/.1.1.10.1b51q9m++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20151220-11:33:05.130(8)? (STDERR) throw(ex);
W20151220-11:33:05.131(8)? (STDERR) ^
W20151220-11:33:05.172(8)? (STDERR) TypeError: Object [object Object] has no method 'substr'
W20151220-11:33:05.173(8)? (STDERR) at guessLineEndings (packages/harrison_papa-parse/baby-parse.js:488:1)
W20151220-11:33:05.173(8)? (STDERR) at ParserHandle.parse (packages/harrison_papa-parse/baby-parse.js:291:1)
W20151220-11:33:05.173(8)? (STDERR) at Object.CsvToJson [as parse] (packages/harrison_papa-parse/baby-parse.js:79:1)
W20151220-11:33:05.173(8)? (STDERR) at server/bootstrap.js:54:7
why the forums.meteor.com cannot visited
the connected error
in there GFW ,to visit forums.meteor.com can use vpn,now it is ok.
like this url : http://aberration.meteor.com
meteor host deny to upload, so chose a local
I have the following folder structure:
Inside of CacheModule.js i have the following code:
socket.on('saveUserCache', function (obj, user_id) {
var jsonOutput = JSON.stringify(obj);
if (!fs.existsSync('./cacheObjects/' + user_id)) {
fs.mkdirSync('./cacheObjects/' + user_id, 0777, function (err) {
if (err) {
console.log(err);
}
});
}
fs.writeFile('./cacheObjects/' + user_id + '/cache.json', jsonOutput, function (err) {
if (err) throw err;
console.log('It\'s saved!');
});
});
The idea behind this is to check if the users folder exists (if not) create a new folder and then write to a file.
However im getting the following error:
Error: ENOENT: no such file or directory, mkdir './cacheObjects/125'
at Error (native)
at Object.fs.mkdirSync (fs.js:794:18)
at Socket.<anonymous> (/var/www/project/app_server/costum_modules/CacheModule.js:10:16)
at emitTwo (events.js:87:13)
at Socket.emit (events.js:172:7)
at Socket.onevent (/var/www/project/app_server/node_modules/socket.io/lib/socket.js:330:8)
at Socket.onpacket (/var/www/project/app_server/node_modules/socket.io/lib/socket.js:290:12)
at Client.ondecoded (/var/www/project/app_server/node_modules/socket.io/lib/client.js:193:14)
at Decoder.Emitter.emit (/var/www/project/app_server/node_modules/socket.io/node_modules/socket.io-parser/node_modules/component-emitter/index.js:134:20)
at Decoder.add (/var/www/project/app_server/node_modules/socket.io/node_modules/socket.io-parser/index.js:247:12)
at Client.ondata (/var/www/project/app_server/node_modules/socket.io/lib/client.js:175:18)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at Socket.onPacket (/var/www/project/app_server/node_modules/socket.io/node_modules/engine.io/lib/socket.js:99:14)
at emitOne (events.js:82:20)
at WebSocket.emit (events.js:169:7)
Can anyone tell me why this is happening. it looks like its sending mkdir with the string. Also i have given the right permissions (so it is not lacking permissions)