MagicMirror² v2.4.1 is available! For more information about this release, check out this topic.
Please read the release notes carefully since this update requires adjustments to your Raspberry Pi configuration!

Fifa World Cup overview



  • So, as far as I can see, we don’t have any proper FIFA World Cup module yet, do we? And it starts TOMORROW!
    I would have loved to see a solution showing some kind of iframe with the overview over the complete screen. Or at least show the playing plan in the center frame.

    But I can’t program one. It’s a pity…



  • I would welcome a Word Cup module, too!



  • I will try to do one. And there’s an API for it.
    http://www.worldcupapi.site/



  • please make it look like mmm-myscoreboard lol, i love colors



  • Here is an alternative. Install MMM-Myscoreboard and the code is below for the WC 2018. I’ll work on it on the weekend. I won’t get time during week days.

    {
      			module: "MMM-MyScoreboard",
      			position: "top_right",
      			classes: "default everyone",
      			header: "FIFA Weltmeisterschaft",
      			config: {
        			showLeagueSeparators: true,
        			colored: true,
        			viewStyle: "mediumLogos",
        				sports: [
          					
          					
            				{
            				league: "FIFAWC",
            				},
            				
    					
        					]
    
      			}
    		},
    

    alt text



  • @conkhidot said in Fifa World Cup overview:

    Here is an alternative. Install MMM-Myscoreboard and the code is below for the WC 2018. I’ll work on it on the weekend. I won’t get time during week days.

    {
      			module: "MMM-MyScoreboard",
      			position: "top_right",
      			classes: "default everyone",
      			header: "FIFA Weltmeisterschaft",
      			config: {
        			showLeagueSeparators: true,
        			colored: true,
        			viewStyle: "mediumLogos",
        				sports: [
          					
          					
            				{
            				league: "FIFAWC",
            				},
            				
    					
        					]
    
      			}
    		},
    

    alt text

    Okay, I will try it tomorrow evening! Thanks


  • Module Developer

    Hi to all,

    i found a different solution: https://github.com/LukeSkywalker92/MMM-SoccerLiveScore with some modifications.

    node_helper.js:
    change the hyperlinks (or only the …/ta/… part of the links in node_helper.js to …/em4/…)
    Example, Line 52:
    Change

    url: 'https://www.ta4-data.de/ta/data/competitions',
    

    to

    url: 'https://www.ta4-data.de/em4/data/competitions',
    

    Do the replacements on the 5 hyperlinks in node_helper, and here you go.

    config.js
    The league id for WM ist 4000

    {
    			module: "MMM-SoccerLiveScore",
    			position: "top_left",
    			header: "Live-Scores",
    			config: {
    				leagues: [4000],
            			showNames: true,
            			showLogos: true,
            			displayTime: 60 * 1000,
            			showTables: true
    				}
    		},
    

    Pictures:
    0_1529014299763_wm2018_1.JPG
    0_1529014318658_wm2018_2.JPG

    AxLED



  • looks nice.

    If i would be interested in this football crap, i would definetely install it on ther mirror 😉



  • @axled It doesn’t work for me 😛

    0|mm | Whoops! There was an uncaught exception…
    0|mm | SyntaxError: Unexpected token p in JSON at position 4
    0|mm | at JSON.parse (:null:null)
    0|mm | at Request._callback (/home/pi/Magicmirror/modules/MMM-SoccerLiveScore/node_helper.js:115:29)
    0|mm | at Request.self.callback (/home/pi/Magicmirror/modules/node_modules/request/request.js:186:22)
    0|mm | at emitTwo (events.js:106:13)
    0|mm | at Request.emit (events.js:194:7)
    0|mm | at Request. (/home/pi/Magicmirror/modules/node_modules/request/request.js:1163:10)
    0|mm | at emitOne (events.js:96:13)
    0|mm | at Request.emit (events.js:191:7)
    0|mm | at IncomingMessage. (/home/pi/Magicmirror/modules/node_modules/request/request.js:1085:12)
    0|mm | at Object.onceWrapper (events.js:293:19)
    0|mm | at emitNone (events.js:91:20)
    0|mm | at IncomingMessage.emit (events.js:188:7)
    0|mm | at endReadableNT (_stream_readable.js:975:12)
    0|mm | at _combinedTickCallback (internal/process/next_tick.js:80:11)
    0|mm | at process._tickCallback (internal/process/next_tick.js:104:9)


  • Module Developer

    @conkhidot
    here is the code of my modified node_helper.js

    /* global Module */
    
    /* Magic Mirror
     * Module: MMM-SoccerLiveScore
     *
     * By Luke Scheffler https://github.com/LukeSkywalker92
     * MIT Licensed.
     */
    
    var NodeHelper = require('node_helper');
    var request = require('request');
    
    module.exports = NodeHelper.create({
        start: function () {
            console.log('MMM-SoccerLiveScore helper started...')
        },
    
        getTeamLogo: function (teamId) {
            var self = this;
            var options = {
                method: 'GET',
                url: 'https://www.ta4-images.de/ta/images/teams/' + teamId + '/64',
                headers: {
                    'Host': 'www.ta4-images.de',
                    'Accept': '*/*',
                    'Accept-Language': 'de-de',
                    'Connection': 'keep-alive',
                    'Accept-Encoding': 'gzip, deflate',
                    'User-Agent': 'TorAlarm/20161206 CFNetwork/808.1.4 Darwin/16.1.0'
                },
                encoding: null
            };
    
    
            request(options, function (error, response, body) {
                if (error) throw new Error(error);
                var image = new Buffer(body).toString('base64');
                self.sendSocketNotification('LOGO', {
                    teamId: teamId,
                    image: image
                });
    
            });
    
    
        },
    
        getLeagueIds: function (leagues, showLogos) {
            var self = this;
            var options = {
                method: 'POST',
                //url: 'https://www.ta4-data.de/ta/data/competitions',
                url: 'https://www.ta4-data.de/em4/data/competitions',
                headers: {
                    'Host': 'ta4-data.de',
                    'Content-Type': 'application/x-www-form-urlencoded',
                    'Connection': 'keep-alive',
                    'Accept': '*/*',
                    'User-Agent': 'TorAlarm/20161202 CFNetwork/808.1.4 Darwin/16.1.0',
                    'Accept-Language': 'de-de',
                    'Accept-Encoding': 'gzip',
                    'Content-Length': '49',
                },
                body: '{"lng":"de-DE","device_type":0,"decode":"decode"}',
                form: false
            };
    
            request(options, function (error, response, body) {
                var competitions = JSON.parse(body).competitions;
                var leagueIds = [];
                for (var i = 0; i < leagues.length; i++) {
                    for (var j = 0; j < competitions.length; j++) {
                        if (competitions[j].id == leagues[i]) {
                            if (showLogos) {
                                if (competitions[j].has_table) {
                                    self.getTeams(competitions[j].id);
                                    self.getTable(competitions[j].id);
                                } else {
                                    self.getLogosFromScores(competitions[j].id);
                                }
                            }
                            leagueIds.push(competitions[j].id)
                            self.sendSocketNotification('LEAGUES', {
                                name: competitions[j].name,
                                id: competitions[j].id
                            });
                        }
                    }
                }
                for (var i = 0; i < leagueIds.length; i++) {
                    self.getScores(leagueIds[i]);
                }
            });
        },
    
        getTeams: function (leagueId) {
            var self = this;
            var options = {
                method: 'POST',
                //url: 'https://www.ta4-data.de/ta/data/competitions/' + leagueId.toString() + '/table',
                url: 'https://www.ta4-data.de/em4/data/competitions/' + leagueId.toString() + '/table',
                headers: {
                    'Host': 'ta4-data.de',
                    'Content-Type': 'application/x-www-form-urlencoded',
                    'Connection': 'keep-alive',
                    'Accept': '*/*',
                    'User-Agent': 'TorAlarm/20161202 CFNetwork/808.1.4 Darwin/16.1.0',
                    'Accept-Language': 'de-de',
                    'Accept-Encoding': 'gzip',
                    'Content-Length': '49',
                },
                body: '{"lng":"de-DE","device_type":0,"decode":"decode"}',
                form: false
            };
            request(options, function (error, response, body) {
                var teamIds = [];
                var data = JSON.parse(body);
                for (var i = 0; i < data.data.length; i++) {
    	    if (data.data[i].type !== 'table') { continue; }
                    for (var j = 0; j < data.data[i].table.length; j++) {
                        teamIds.push(data.data[i].table[j].team_id);
                    }
                }
                self.getLogos(teamIds);
            });
        },
    
        getTable: function (leagueId) {
            var self = this;
            var options = {
                method: 'POST',
                //url: 'https://www.ta4-data.de/ta/data/competitions/' + leagueId.toString() + '/table',
                url: 'https://www.ta4-data.de/em4/data/competitions/' + leagueId.toString() + '/table',
                headers: {
                    'Host': 'ta4-data.de',
                    'Content-Type': 'application/x-www-form-urlencoded',
                    'Connection': 'keep-alive',
                    'Accept': '*/*',
                    'User-Agent': 'TorAlarm/20161202 CFNetwork/808.1.4 Darwin/16.1.0',
                    'Accept-Language': 'de-de',
                    'Accept-Encoding': 'gzip',
                    'Content-Length': '49',
                },
                body: '{"lng":"de-DE","device_type":0,"decode":"decode"}',
                form: false
            };
            request(options, function (error, response, body) {
                var teamIds = [];
                var data = JSON.parse(body);
                var refreshTime = data.refresh_time*1000;
                data = data.data;
    	    for(var i = 0; i < data.length; i++) {
    		    if (data[i].type === 'table') {
    			self.sendSocketNotification('TABLE', {
    			    leagueId: leagueId,
    			    table: data[i].table
    			});
    			setTimeout(function () {
    			    self.getTable(leagueId);
    			}, refreshTime);
    		        return;
    		    }
    	    }
            });
        },
    
        getLogos: function (teamIds) {
            var self = this;
            var logos = [];
            for (var i = 0; i < teamIds.length; i++) {
                self.getTeamLogo(teamIds[i]);
            }
        },
    
        getScores: function (leagueId) {
            var self = this;
            var options = {
                method: 'POST',
                //url: 'https://www.ta4-data.de/ta/data/competitions/' + leagueId.toString() + '/matches/round/0',
                url: 'https://www.ta4-data.de/em4/data/competitions/' + leagueId.toString() + '/matches/round/0',
                headers: {
                    'Host': 'ta4-data.de',
                    'Content-Type': 'application/x-www-form-urlencoded',
                    'Connection': 'keep-alive',
                    'Accept': '*/*',
                    'User-Agent': 'TorAlarm/20161202 CFNetwork/808.1.4 Darwin/16.1.0',
                    'Accept-Language': 'de-de',
                    'Accept-Encoding': 'gzip',
                    'Content-Length': '49',
                },
                body: '{"lng":"de-DE","device_type":0,"decode":"decode"}',
                form: false
            }
    
            request(options, function (error, response, body) {
                var data = JSON.parse(body);
                var refreshTime = data.refresh_time * 1000;
                var standings = data.data;
                self.sendSocketNotification('STANDINGS', {
                    leagueId: leagueId,
                    standings: standings
                });
                setTimeout(function () {
                    self.getScores(leagueId);
                }, refreshTime);
            });
        },
    
        getLogosFromScores: function (leagueId) {
            var self = this;
            var options = {
                method: 'POST',
                //url: 'https://www.ta4-data.de/ta/data/competitions/' + leagueId.toString() + '/matches/round/0',
                url: 'https://www.ta4-data.de/em4/data/competitions/' + leagueId.toString() + '/matches/round/0',
                headers: {
                    'Host': 'ta4-data.de',
                    'Content-Type': 'application/x-www-form-urlencoded',
                    'Connection': 'keep-alive',
                    'Accept': '*/*',
                    'User-Agent': 'TorAlarm/20161202 CFNetwork/808.1.4 Darwin/16.1.0',
                    'Accept-Language': 'de-de',
                    'Accept-Encoding': 'gzip',
                    'Content-Length': '49',
                },
                body: '{"lng":"de-DE","device_type":0,"decode":"decode"}',
                form: false
            }
    
            request(options, function (error, response, body) {
                var data = JSON.parse(body);
                var standings = data.data;
                for (var i = 0; i < standings.length; i++) {
                    if (standings[i].matches !== undefined) {
                        for (var j = 0; j < standings[i].matches.length; j++) {
                            self.getTeamLogo(standings[i].matches[j].team1_id);
                            self.getTeamLogo(standings[i].matches[j].team2_id);
                        }
                    }
                }
            });
        },
    
        socketNotificationReceived: function (notification, payload) {
            if (notification === 'CONFIG') {
                this.getLeagueIds(payload.leagues, payload.showLogos);
            }
        }
    
    });
    
    

    AxLED