diff options
Diffstat (limited to 'lib/helpers.js')
-rwxr-xr-x | lib/helpers.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/helpers.js b/lib/helpers.js index 620e7cf..9c69e7a 100755 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -50,13 +50,13 @@ var helpers = { extractShowInfo: function(show, callback) { var that = this; - console.log("extractShowInfo " + show.show + " " + show.imdb_id); + console.log("extractShowInfo " + show.show + " " + show.imdb); var thisShow = {}; var thisEpisodes = []; var thisEpisode = {}; var numSeasons = 0; - var imdb = show.imdb_id; + var imdb = show.imdb; eztv.getAllEpisodes(show, function(err, data) { thisShow = data; @@ -104,7 +104,7 @@ var helpers = { }, function(err, res) { // Only change "lastUpdated" date if there are new episodes - Show.find({imdb_id: imdb}, function(err, show) { + Show.find({imdb_id: show.imdb}, function(err, show) { if(err) return callback(err, null); if(show.episodes != thisEpisodes) { Show.update({ imdb_id: imdb }, @@ -207,9 +207,9 @@ var helpers = { var slug = show.slug; try { console.log("Extracting "+ show.show); - Show.findOne({slug: slug}, function(err, doc){ + Show.find({slug: slug}, function(err, doc){ - if(err || !doc) { + if(err || doc.length == 0) { console.log("New Show"); try { trakt.request('show', 'summary', {title: slug}, function(err, data) { @@ -238,7 +238,7 @@ var helpers = { }); newShow.save(function(err, newDocs) { - show.imdb_id = data.imdb_id; + show.imdb = data.imdb_id; helpers.extractShowInfo(show, function(err, show) { return callback(err, show); }); @@ -259,7 +259,7 @@ var helpers = { var now = +new Date(); if ( (now - doc.last_updated) > TTL ) { console.log("TTL expired, updating info"); - show.imdb_id = doc.imdb_id; + show.imdb = doc.imdb_id; //TODO: Change this to just get new rating or something helpers.extractShowInfo(show, function(err, show) { return callback(err, show); |