MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    MM-concert-calendar

    Scheduled Pinned Locked Moved Troubleshooting
    1 Posts 1 Posters 182 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R Offline
      RIKKO14
      last edited by RIKKO14

      Hello,
      I am trying to install the MM-concert-calendar module.
      after runing query: https://api.songkick.com/api/3.0/search/locations.json?query=YOUR_CITY_HERE&apikey=YOUR_SONGKICK_API
      i have this:

      {"resultsPage": {"status": "ok", "results": {"location": [{"city": {"lat": 49.1833, "lng": - 0.35, "country": 
      {"displayName ":" France "}," displayName ":" Caen "}," metroArea ": {" lat ": 49.1833," lng ": - 0.35," country ": 
      {" displayName ":" France "}," uri ":" http://www.songkick.com/metro_areas/28855-france-caen?
      utm_source=59898&utm_medium=partner "," displayName ":" Caen "," id ": 28855}}]}," perPage ": 50, "page": 1, "totalEntries": 1}}
      

      i open open concertcalendar.js but i don’t find the property named in the concertcalendar.js
      :

      /* Magic Mirror
       * Module: ConcertCalendar
       *
       * By Marc Pratllusà https://github.com/muilpp
       * based on a Script from Benjamin Angst http://www.beny.ch
       * MIT Licensed.
       */
      
      Module.register("concertcalendar",{
      
      	// Define module defaults
      	defaults: {
      		maximumArtist: 150, // Number of bands to check if they are on tour
      		concertsPerPage: 8,
      		updateInterval: 60 * 60 * 24 * 1000, // Once a day.
      		paginationInterval: 20 * 1000, // Every twenty seconds.
      		animationSpeed: 2000,
      		fade: true,
      		fadePoint: 0.25, // Start on 1/4th of the list.
      		initialLoadDelay: 0, // start delay seconds.
      
      		apiBase: 'http://localhost:8282/concerts',
      		area: "28714", //your songkick area here (Barcelona, Spain by default)
      		user: "",.     //your lastfm username here
      
      		titleReplace: {
      			"Upcoming Concerts Calendar ": ""
      		},
      	},
      
      	// Define required scripts.
      	getStyles: function() {
      		return ["concertcalendar.css", "font-awesome.css"];
      	},
      
      	// Define required scripts.
      	getScripts: function() {
      		return ["moment.js"];
      	},
      
      	// Define start sequence.
      	start: function() {
      		Log.info("Starting module: " + this.name);
      
      		// Set locale.
      		moment.locale(config.language);
      
      		this.concerts = [];
      		this.visibleConcerts = [];
      		this.loaded = false;
      		this.paginationTimer = null;
      		this.paginationIndex = 0;
      
      		this.scheduleUpdate(this.config.initialLoadDelay);
      		this.paginationUpdate();
      
      		this.updateTimer = null;
      
      	},
      
      	// Override dom generator.
      	getDom: function() {
      		var wrapper = document.createElement("div");
      		var table = document.createElement("table");
      		table.className = "small";
      
      		for (var t in this.visibleConcerts) {
      			var concert = this.visibleConcerts[t];
      
      			var row = document.createElement("tr");
      			table.appendChild(row);
      
      			var concertArtistCell = document.createElement("td");
      			concertArtistCell.className = "from";
      			concertArtistCell.innerHTML = concert.artist;
      			row.appendChild(concertArtistCell);
      
      			var concertCityCell = document.createElement("td");
      			concertCityCell.innerHTML = " - " + concert.city.trim()+", ";
      			concertCityCell.className = "align-right trainto";
      			row.appendChild(concertCityCell);
      
      			var concertDate = document.createElement("td");
      			concertDate.innerHTML = concert.concertDate;
      			concertDate.className = "align-right trainto";
      			row.appendChild(concertDate);
      		}
      
      		return table;
      	},
      
      	/* updateTimetable()
      	 * Calls processConcerts on succesfull response.
      	 */
      	updateTimetable: function() {
      		var url = this.config.apiBase + this.getParams();
      		var self = this;
      		var retry = true;
      
      		var concertRequest = new XMLHttpRequest();
      		concertRequest.open("GET", url, true);
      		concertRequest.onreadystatechange = function() {
      			if (this.readyState === 4) {
      				if (this.status === 200) {
      					self.processConcerts(JSON.parse(this.response));
      				} else if (this.status === 401) {
      					self.config.id = "";
      					self.updateDom(self.config.animationSpeed);
      
      					Log.error(self.name + ": Incorrect, 401 reponse...");
      					retry = false;
      				} else {
      					Log.error(self.name + ": Could not load concerts.");
      				}
      
      				if (retry) {
      					self.scheduleUpdate((self.loaded) ? -1 : self.config.retryDelay);
      				}
      			}
      		};
      		concertRequest.send();
      	},
      
      	/* getParams(compliments)
      	 * Generates an url with api parameters based on the config.
      	 *
      	 * return String - URL params.
      	 */
      	getParams: function() {
      		var params = "/";
                      params += this.config.area;
                      params += "/" + this.config.user;
                      params += "?limit=" + this.config.maximumArtist;
      
      		return params;
      	},
      
      	/* processConcerts(data)
      	 * Uses the received data to set the various values.
      	 *
      	 * argument data object - Weather information received form openweather.org.
      	 */
      	processConcerts: function(data) {
      
      		this.concerts = [];
      
      		data.forEach((concert) => {
      			var city = concert.City.split(",");
      
      			if (city.length > 0) {
      				cityToAdd = city[0];
      				if (city[0].length > 9)
      					cityToAdd = city[0].substring(0,9)+"..";
      
      				artistToAdd = concert.Artist;
      				if (artistToAdd.length > 10)
      					artistToAdd = artistToAdd.substring(0,10)+"..";
      
      				var date = new Date(concert.Date);
      				this.concerts.push({
      					artist: artistToAdd.trim(),
      					city: cityToAdd.trim(),
      					concertDate: date.getDate()+"/"+(date.getMonth()+1)
      				});
      			}
      		});
      
      		this.loaded = true;
      		concertsToShow = this.concerts.slice(0,this.config.concertsPerPage);
      		this.visibleConcerts = this.visibleConcerts.concat(concertsToShow);
      		this.updateDom(this.config.animationSpeed);
      	},
      
      	paginate: function() { 
      		this.paginationIndex = this.paginationIndex + this.config.concertsPerPage;
      
      		if (this.concerts.length > this.paginationIndex) {
      			this.visibleConcerts = this.concerts.slice(this.paginationIndex, this.paginationIndex+this.config.concertsPerPage);
      		} else {
      			this.visibleConcerts = this.concerts.slice(0,this.config.concertsPerPage);
      			this.paginationIndex = 0;
      		}
      
      		this.updateDom(this.config.animationSpeed);
      	},
      		/* scheduleUpdate()
      	 * Schedule next update.
      	 *
      	 * argument delay number - Milliseconds before next update. If empty, this.config.updateInterval is used.
      	 */
      	scheduleUpdate: function(delay) {
      		var nextLoad = this.config.updateInterval;
      		if (typeof delay !== "undefined" && delay >= 0) {
      			nextLoad = delay;
      		}
      
      		var self = this;
      		clearTimeout(this.updateTimer);
      		this.updateTimer = setTimeout(function() {
      			self.updateTimetable();
      		}, nextLoad);
      	},
      
      	paginationUpdate: function() {
      		var self = this;
      		setInterval(function() {
      			self.paginate();
      		}, this.config.paginationInterval);
      	},
      
      });
      
      

      and add my username in the property right below it.

      If not, is there a simpler module to have concerts close to home in France?
      I tried with MMM-Events but my city, Caen in France (city of more than 100,000 inhabitants), is too small for the eventful API: on the eventfull website concerts are displayed but with the API concerts are not are not found, by contacting eventful I understood that I would have to buy an API which I do not want and moreover Eventful forgets a lot of concerts for my city.
      Thank you for your help.

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Enjoying MagicMirror? Please consider a donation!
      MagicMirror created by Michael Teeuw.
      Forum managed by Sam, technical setup by Karsten.
      This forum is using NodeBB as its core | Contributors
      Contact | Privacy Policy