MagicMirror² v2.14.0 is available! For more information about this release, check out this topic.

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.

  • Project Sponsor Module Developer

    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
        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 list

    i 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


    into this


    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");
        var list_of_images=text.toString().split(/\r\n|\n/); // windows or linux line ends
    node doit.js

    | changed to use ‘:’ instead of = , easier cut/paste jnto config.js

Log in to reply