diff options
author | emartin <emartin@transperfect.com> | 2014-06-03 11:41:46 +0100 |
---|---|---|
committer | emartin <emartin@transperfect.com> | 2014-06-03 11:41:46 +0100 |
commit | c906c522aef97aa19fbfabf273811f0ead6909eb (patch) | |
tree | 6e8a5bae1c77b376f9546a4cbcc9bf6dfe8c0ea8 /lib/helpers.js | |
parent | e0df2a95d8013755eee4ceb9ff67bac1c65609d6 (diff) | |
download | popcorn-api-c906c522aef97aa19fbfabf273811f0ead6909eb.zip popcorn-api-c906c522aef97aa19fbfabf273811f0ead6909eb.tar.gz popcorn-api-c906c522aef97aa19fbfabf273811f0ead6909eb.tar.bz2 |
Revert "Fixed issue with API not updating existing shows with new episodes"
This reverts commit e0df2a95d8013755eee4ceb9ff67bac1c65609d6.
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); |