Read the statement by Michael Teeuw here.
txt file for MMM embedyoutube
-
hello everybody
Did someone try to create a text file to put videos id to work with the module embedyoutube? i try to have a text file on my office pc , shared with my raspberry to avoid to write videos id on config.js.
It will great to have this like the module imageslideshow which is perfect with samba to integrate differents photos on a office’s folder.
Thanks -
Why would you create a txt file when you can create a json file and parse it? Much easier.
-
@cowboysdude
you’re right but it’s not for me but for a friend who want a magicmirror. He doesn’t have knowlegde about javascript and to minimalize some error i wanted to work with a text file on his computer, shared with his raspberry…more easy for him, his wife and children :) -
@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