Read the statement by Michael Teeuw here.
New to this and have no idea how to implement this module, MMM-RottenTomatoes
-
Hey, I’m building my first magic mirror and so far I have added a weather and commute module. I’m now trying to add a module that will show me information about upcoming movies like box office and ratings. I found the module MMM-RotenTomatoes and have downloaded the rt-scraper and GitHub CLI but I have no idea what to do after that. I have absolutely no idea what to put in that config file for it work. Can anyone help?
https://github.com/AdamMoses-GitHub/MMM-RottenTomatoes/blob/master/MMM-RottenTomatoes.js
-
@Datfatboi all the config is on this page
https://github.com/AdamMoses-GitHub/MMM-RottenTomatoesread the two links in my signature
-
@sdetweil
I guess a better Question would be, in the config file is it supposed to look like this:modules: [ { module: "MMM-RottenTomatoes", position: "top_left", config: { showHeader: "true" showBoxOffice: "true" showOpeningThisWeek: "true" } },
OR something like this:
Module.register("MMM-RottenTomatoes", { // setup the default config options defaults: { // optional showHeader: true, showOpeningThisWeek: true, showBoxOffice: true, showComingSoon: true, limitOpeningThisWeek: 3, limitBoxOffice: 3, limitComingSoon: 3, boxOfficeAfter: true, mergeOpeningAndComingSoon: true, }, // the start function start: function() { // log starting Log.info("Starting module: " + this.name); // set refresh rate to 6 hours this.config.refreshRate = 6 * 60 * 60 * 1000; // set an identier config tag this.config.identifier = this.identifier; // set loaded, error, and the update to init values this.loaded = false; this.errorMessage = null; // set the header to this place if (this.config.showHeader) { this.data.header = 'Rotten Tomatoes'; } if (this.config.limitOpeningThisWeek == 0) this.config.limitOpeningThisWeek = 100; if (this.config.limitBoxOffice == 0) this.config.limitBoxOffice = 100; if (this.config.limitComingSoon == 0) this.config.limitComingSoon = 100; // add this config to the helper functions this.sendSocketNotification('ROTTEN_TOMATOES_REGISTER_CONFIG', this.config); }, // the socket handler socketNotificationReceived: function(notification, payload) { // if an update was received if (notification === "ROTTEN_TOMATOES_UPDATE") { // check this is for this module based on the woeid if (payload.identifier === this.identifier) { // set loaded flag, set the update, and call update dom this.rtData = payload.rtData; this.loaded = true; this.updateDom(); } } // if sent error notice if (notification === "ROTTEN_TOMATOES_TOO_MANY_ERRORS") { this.errorMessage("There was an error."); if (this.updateTimer !== null) clearTimeout(this.updateTimer); this.updateTimer = null; this.updateDom(); } }, // cleanScore: function(theScore) { if (theScore.indexOf('%') == -1) return '--'; else return theScore; }, // cleanTitle: function(theTitle) { if (theTitle.length > 28) return theTitle.slice(0, 28) + '...'; else return theTitle; }, // the get dom handler getDom: function() { // if an error, say so if (this.errorMessage !== null) { var wrapper = document.createElement("div"); wrapper.className = "small"; wrapper.innerHTML = this.errorMessage; return wrapper; } // if nothing loaded yet, put in placeholder text if (!this.loaded) { var wrapper = document.createElement("div"); wrapper.className = "small"; wrapper.innerHTML = "Awaiting Update..."; return wrapper; } var titleSize = 'xsmall'; var movieSize = 'xsmall'; var wrapper = document.createElement("table"); // do opening this week var allOTWandCSRows = [ ]; if (this.config.showOpeningThisWeek) { var otwData = this.rtData.openingThisWeek; var otwTitleTR = document.createElement("tr"); otwTitleTR.className = titleSize; var otwTitleTD = document.createElement("td"); otwTitleTD.innerHTML = "Opening This Week"; if (this.config.mergeOpeningAndComingSoon) otwTitleTD.innerHTML = "Opening / Coming Soon"; otwTitleTD.colSpan = "3"; otwTitleTR.appendChild(otwTitleTD); allOTWandCSRows.push(otwTitleTR); for (var cIndex = 0; (cIndex < otwData.length) && (cIndex < this.config.limitOpeningThisWeek); cIndex++) { var cOTW = otwData[cIndex]; var otwRowTR = document.createElement("tr"); otwRowTR.className = movieSize; var otwRowMeter = document.createElement("td"); otwRowMeter.innerHTML = this.cleanScore(cOTW.meter) + " "; otwRowTR.appendChild(otwRowMeter); var otwRowTitle = document.createElement("td"); otwRowTitle.innerHTML = this.cleanTitle(cOTW.title) + " "; otwRowTitle.align = 'left'; otwRowTR.appendChild(otwRowTitle); var otwRowDate = document.createElement("td"); otwRowDate.innerHTML = " " + cOTW.date; otwRowTR.appendChild(otwRowDate); allOTWandCSRows.push(otwRowTR); } } // do opening this week if (this.config.showOpeningThisWeek) { var csData = this.rtData.comingSoon; var csTitleTR = document.createElement("tr"); csTitleTR.className = titleSize; var csTitleTD = document.createElement("td"); csTitleTD.innerHTML = "Coming Soon"; csTitleTD.colSpan = "3"; csTitleTR.appendChild(csTitleTD); if (!this.config.mergeOpeningAndComingSoon) allOTWandCSRows.push(csTitleTR); for (var cIndex = 0; (cIndex < csData.length) && (cIndex < this.config.limitComingSoon); cIndex++) { var ccs = csData[cIndex]; var csRowTR = document.createElement("tr"); csRowTR.className = movieSize; var csRowMeter = document.createElement("td"); csRowMeter.innerHTML = this.cleanScore(ccs.meter) + " "; csRowTR.appendChild(csRowMeter); var csRowTitle = document.createElement("td"); csRowTitle.innerHTML = this.cleanTitle(ccs.title) + " "; csRowTitle.align = 'left'; csRowTR.appendChild(csRowTitle); var csRowDate = document.createElement("td"); csRowDate.innerHTML = " " + ccs.date; csRowTR.appendChild(csRowDate); allOTWandCSRows.push(csRowTR); } } // do box office var boRows = [ ]; if (this.config.showBoxOffice) { var boData = this.rtData.boxOffice; var boTitleTR = document.createElement("tr"); boTitleTR.className = titleSize; var boTitleTD = document.createElement("td"); boTitleTD.innerHTML = "Box Office"; boTitleTD.width = "250px"; boTitleTD.colSpan = "3"; boTitleTR.appendChild(boTitleTD); boRows.push(boTitleTR); for (var cIndex = 0; (cIndex < boData.length) && (cIndex < this.config.limitBoxOffice); cIndex++) { var cbo = boData[cIndex]; var boRowTR = document.createElement("tr"); boRowTR.className = movieSize; var boRowMeter = document.createElement("td"); boRowMeter.innerHTML = this.cleanScore(cbo.meter) + " "; boRowTR.appendChild(boRowMeter); var boRowTitle = document.createElement("td"); boRowTitle.innerHTML = this.cleanTitle(cbo.title) + " "; boRowTitle.align = 'left'; boRowTR.appendChild(boRowTitle); var boRowGross = document.createElement("td"); boRowGross.innerHTML = " " + cbo.gross; boRowTR.appendChild(boRowGross); boRows.push(boRowTR); } } // build the table var allRows = [ ]; // if set to show box office first, do that if (!this.config.boxOfficeAfter) allRows = allRows.concat(boRows); // add opening this week and coming soon rows allRows = allRows.concat(allOTWandCSRows); // if set to show box office after, do that if (this.config.boxOfficeAfter) allRows = allRows.concat(boRows); // add all rows to the return table wrapper for (var cIndex = 0; cIndex < allRows.length; cIndex++) { wrapper.appendChild(allRows[cIndex]); } // return table wrapper return wrapper; } });
-
@Datfatboi You should only add the following to your config.js
{ module: “MMM-RottenTomatoes”, position: “top_left”, config: { showHeader: “true” showBoxOffice: “true” showOpeningThisWeek: “true” } },
-
@Datfatboi never change the module code ( your second choice)
unless u are fixing a bug or adding some new function.always put info into config.js
now, your lines for config.js are not correct.
{ module: "MMM-RottenTomatoes", position: "top_left", config: { showHeader: "true" showBoxOffice: "true" showOpeningThisWeek: "true" } },
watch out for the quote style… the curved ones are used by MS office apps…
we need the text ones, straight up and downalso u are missing some required trailing commas
look at each line, and follow the rulesgeneral rules for module definition
{} and [] must be matched
the word to the left of : does not need quotes
the thing to the right of : if a number or, true/false does NOT need quotes
otherwise is needs quotes, single or double doesn’t matter as long as start and end quote are the sameif the thing on the next line is a word , then THIS line needs a trailing comma
if the thing on the next line is {, then THIS line needs a trailing commaalso, indentation makes it MUCH easier to see the {} and []