Пример #1
0
        if (docs.length > 0 ) docs = docs[0];
        res.json(202, docs);
    });
});

server.listen(process.env.PORT || 5000, function() {
    console.log('%s listening at %s', server.name, server.url);
    refreshDatabase();
});


// cronjob
try {
    var CronJob = require('cron').CronJob;
    var job = new CronJob('00 00 00 * * *', function(){
        refreshDatabase();
      }, function () {
        // This function is executed when the job stops
      },
      true
    );
    console.log("Cron job started");
} catch(ex) {
    console.log("cron pattern not valid");
}

// trakt error catcher
trakt.on('error', function(err){
    console.log(err);
});
Пример #2
0
    							date_based: false,
    							first_aired: '',
    							watched : {watched: false},
    							torrents: []
    						};
    						thisEpisode.torrents = [];
    						thisEpisode.torrents[0] = episode.torrent;
    						thisEpisode.torrents[episode.quality] = episode.torrent;
    						episodes.push(thisEpisode);
    						logger.info('Blank episode added to : '+ show.title);
    					}
    				});
    			}
    			Show.update({imdb_id: doc.imdb_id}, {$set: {episodes: episodes}}, function(err, doc){
    				return callback(null, episode);
    			});
    		});
    	}
    });
},


}

module.exports = helpers;

// trakt error catcher
trakt.on('error', function(err){
  logger.error("Trakt Error: "+ err);
});