Read the statement by Michael Teeuw here.
txt file for MMM embedyoutube
-
@chassain-0 just read a file, line by line? any comment markers? (#, //, ;);
something like this?
list_of_images: [], read_video_ids: function(){ let self=this var reader = new FileReader(); reader.onload = function(progressEvent){ // Entire file console.log(this.result); self.list_of_images=this.result.split(/\r\n|\n/); // windows or linux line ends }; reader.readAsText( self.config.filename); }
-
@sdetweil
line by line exactly…
line 1 is for video_id without “”
line 2 without “” to have second video for params video listi can read line to line but i need to integrate line 1in config/js to :
video_id:“line 1”,
and line2, line 3,… to ;
video_list :[“line2”, “line3”,…] -
@chassain-0 with or without quotes?
the code above
will turn this
"line1" "line2" "line3"
into this
self.list_of_images=["line1","line2","line3"]
change the variable names
u can do that live, not have to put them in config.js, just read the file
-
@sdetweil ok thanks i will try this option.
here a little example of config embedyoutube
Module.register("MMM-EmbedYoutube", { defaults: { autoplay: false, mute: true, color: "red", controls : false, disablekb: false, fs: true, height: 315, width: 560, loop: false, modestbranding: false, rel : false, showinfo : false, video_id : "", playlist: "", video_list: [] }, getDom: function () { var wrapper = document.createElement("div"); // Parameter var params = ""; var videoList = ""; if (this.config.video_list && this.config.video_list.length > 0) { videoList = "&playlist="; for (var i = 0; i < this.config.video_list.length; i++) { videoList += this.config.video_list[i]; if (i + 1 < this.config.video_list.length) videoList += ","; } }
-
u just want the item so u can cut/paste it into the config?
even smaller, doit.js
var fs = require("fs"); var text = fs.readFileSync("./textfile"); console.log("file="+text); var list_of_images=text.toString().split(/\r\n|\n/); // windows or linux line ends console.log("video_list:"+JSON.stringify(list_of_images));
node doit.js file=line1 line2 line3 line4 line5 video_list:["line1","line2","line3","line4","line5"]
| changed to use ‘:’ instead of = , easier cut/paste jnto config.js