Skip to content

Commit

Permalink
Added handling of missing 'games' tag
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbethge authored Jul 18, 2024
1 parent 150d884 commit f40bb7e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions providers/SNET.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,17 @@ module.exports = {
getLeague: function(league, teams) {
console.log( "[MMM-MyScoreboard] " + moment().format("D-MMM-YY HH:mm") + " getLeague: " + league + ", " + teams );
var self = this;

var filteredGames = this.scoresObj.data.games.filter(function(game) {
return(game.league.toUpperCase() == league.toUpperCase() &&
(teams == null || teams.indexOf(game.home_team.short_name.toUpperCase()) != -1 ||
teams.indexOf(game.visiting_team.short_name.toUpperCase()) != -1) );
});

if(this.scoresObj.data.games) {
var filteredGames = this.scoresObj.data.games.filter(function(game) {
return(game.league.toUpperCase() == league.toUpperCase() &&
(teams == null || teams.indexOf(game.home_team.short_name.toUpperCase()) != -1 ||
teams.indexOf(game.visiting_team.short_name.toUpperCase()) != -1) );
});
}
else {
console.log( "[MMM-MyScoreboard] " + moment().format("D-MMM-YY HH:mm") + " getLeague: no games today");
}


/*
Expand Down

0 comments on commit f40bb7e

Please sign in to comment.