def testNMWP(self, **data): nmwp = NMWP() nmwp.test(data.get('NMWP.apikey'), data.get('NMWP.devkey'), data.get('NMWP.priority')) return ''
def testNMWP(self, **data): nmwp = NMWP() nmwp.test(data.get("NMWP.apikey"), data.get("NMWP.devkey"), data.get("NMWP.priority")) return ""
def _search(self, movie, force=False): # Stop caching ffs! Db.expire_all() # Check release date and search for appropriate qualities preReleaseSearch = False dvdReleaseSearch = False now = int(time.time()) # Search all if ETA is unknow, but try update ETA for next time. log.debug('Calculate ETA') checkETA = False if not movie.eta: checkETA = True preReleaseSearch = True dvdReleaseSearch = True else: # Prerelease 1 week before theaters if movie.eta.theater <= now + 604800: preReleaseSearch = True # dvdRelease 6 weeks before dvd release if movie.eta.dvd <= now + 3628800: preReleaseSearch = True dvdReleaseSearch = True # Dvd date is unknown but movie is in theater already if movie.eta.dvd == 0 and movie.eta.theater > now: dvdReleaseSearch = False # Force ETA check if movie.eta.lastCheck < now: checkETA = True # Minimal week interval for ETA check if checkETA and self.config.get('MovieETA', 'enabled'): cherrypy.config.get('searchers').get('etaQueue').put( {'id': movie.id}) for queue in movie.queue: # Movie already found, don't search further if queue.completed: log.debug( '%s already completed for "%s". Not searching for any qualities below.' % (queue.qualityType, movie.name)) return True # only search for active and not completed, minimal 1 min since last search if queue.active and not queue.completed and not self.abort and not self.stop: #skip if no search is set log.debug('Needs a search?') if (not ((preReleaseSearch and queue.qualityType in Qualities.preReleases) or (dvdReleaseSearch and not queue.qualityType in Qualities.preReleases)) ) and not queue.lastCheck < (now - int( self.config.get('Intervals', 'search')) * 7200): continue log.debug('Start searching for movie: %s' % movie.name) highest = self.provider.find(movie, queue) log.debug('End searching for movie: %s' % movie.name) #send highest to SABnzbd & mark as snatched if highest: log.debug('Found highest') #update what I found queue.name = latinToAscii(highest.name) queue.link = highest.detailUrl Db.flush() waitFor = queue.waitFor * (60 * 60 * 24) if queue.markComplete or ( not queue.markComplete and highest.date + waitFor < time.time()): time.sleep(10) # Give these APIs air! if self.config.get( 'NZB', 'sendTo' ) == 'Sabnzbd' and highest.type == 'nzb': success = self.sabNzbd.send(highest, movie.imdb) elif self.config.get( 'NZB', 'sendTo' ) == 'Nzbget' and highest.type == 'nzb': success = self.nzbGet.send(highest) elif self.config.get( 'Torrents', 'sendTo' ) == 'Transmission' and highest.type == 'torrent': success = self.transmission.send( highest, movie.imdb) else: success = self.blackHole(highest) else: success = False log.info('Found %s but waiting for %d hours.' % (highest.name, ((highest.date + waitFor) - time.time()) / (60 * 60))) # Set status if success: log.debug('Success') movie.status = u'snatched' if queue.markComplete else u'waiting' movie.dateChanged = datetime.datetime.now() queue.lastCheck = now queue.completed = True Db.flush() # Add to history h = History() h.movie = movie.id h.value = str(highest.id) + '-' + str(highest.size) h.status = u'snatched' Db.add(h) Db.flush() # Notify PROWL if self.config.get('PROWL', 'onSnatch'): log.debug('PROWL') prowl = PROWL() prowl.notify(highest.name, 'Download Started') # Notify XBMC if self.config.get('XBMC', 'onSnatch'): log.debug('XBMC') xbmc = XBMC() xbmc.notify('Snatched %s' % highest.name) # Notify GROWL if self.config.get('GROWL', 'onSnatch'): log.debug('GROWL') growl = GROWL() growl.notify('Snatched %s' % highest.name, 'Download Started') # Notify Notifo if self.config.get('Notifo', 'onSnatch'): log.debug('Notifo') notifo = Notifo() notifo.notify('%s' % highest.name, "Snatched:") # Notify SNS if self.config.get('SNS', 'onSnatch'): log.debug('SNS') sns = SNS() sns.notify('%s' % highest.name, "Snatched:") # Notify Boxcar if self.config.get('Boxcar', 'onSnatch'): log.debug('Boxcar') boxcar = Boxcar() boxcar.notify('%s' % highest.name, "Snatched:") # Notify NotifyMyAndroid if self.config.get('NMA', 'onSnatch'): log.debug('NotifyMyAndroid') nma = NMA() nma.notify('Download Started', 'Snatched %s' % highest.name) # Notify NotifyMyWindowsPhone if self.config.get('NMWP', 'onSnatch'): log.debug('NotifyMyWindowsPhone') nmwp = NMWP() nmwp.notify('Download Started', 'Snatched %s' % highest.name) # Notify Twitter if self.config.get('Twitter', 'onSnatch'): log.debug('Twitter') twitter = Twitter() twitter.notify('Download Started', 'Snatched %s' % highest.name) return True queue.lastCheck = now Db.flush() return False
def _search(self, movie, force = False): # Stop caching ffs! Db.expire_all() # Check release date and search for appropriate qualities preReleaseSearch = False dvdReleaseSearch = False now = int(time.time()) # Search all if ETA is unknow, but try update ETA for next time. log.debug('Calculate ETA') checkETA = False if not movie.eta: checkETA = True preReleaseSearch = True dvdReleaseSearch = True else: # Prerelease 1 week before theaters if movie.eta.theater <= now + 604800: preReleaseSearch = True # dvdRelease 6 weeks before dvd release if movie.eta.dvd <= now + 3628800: preReleaseSearch = True dvdReleaseSearch = True # Dvd date is unknown but movie is in theater already if movie.eta.dvd == 0 and movie.eta.theater > now: dvdReleaseSearch = False # Force ETA check if movie.eta.lastCheck < now: checkETA = True # Minimal week interval for ETA check if checkETA and self.config.get('MovieETA', 'enabled'): cherrypy.config.get('searchers').get('etaQueue').put({'id':movie.id}) for queue in movie.queue: # Movie already found, don't search further if queue.completed: log.debug('%s already completed for "%s". Not searching for any qualities below.' % (queue.qualityType, movie.name)) return True # only search for active and not completed, minimal 1 min since last search if queue.active and not queue.completed and not self.abort and not self.stop: #skip if no search is set log.debug('Needs a search?') if (not ((preReleaseSearch and queue.qualityType in Qualities.preReleases) or (dvdReleaseSearch and not queue.qualityType in Qualities.preReleases))) and not queue.lastCheck < (now - int(self.config.get('Intervals', 'search')) * 7200): continue log.debug('Start searching for movie: %s' % movie.name) highest = self.provider.find(movie, queue) log.debug('End searching for movie: %s' % movie.name) #send highest to SABnzbd & mark as snatched if highest: log.debug('Found highest') #update what I found queue.name = latinToAscii(highest.name) queue.link = highest.detailUrl Db.flush() waitFor = queue.waitFor * (60 * 60 * 24) if queue.markComplete or (not queue.markComplete and highest.date + waitFor < time.time()): time.sleep(10) # Give these APIs air! if self.config.get('NZB', 'sendTo') == 'Sabnzbd' and highest.type == 'nzb': success = self.sabNzbd.send(highest, movie.imdb) elif self.config.get('NZB', 'sendTo') == 'Nzbget' and highest.type == 'nzb': success = self.nzbGet.send(highest) elif self.config.get('Torrents', 'sendTo') == 'Transmission' and highest.type == 'torrent': success = self.transmission.send(highest, movie.imdb) else: success = self.blackHole(highest) else: success = False log.info('Found %s but waiting for %d hours.' % (highest.name, ((highest.date + waitFor) - time.time()) / (60 * 60))) # Set status if success: log.debug('Success') movie.status = u'snatched' if queue.markComplete else u'waiting' movie.dateChanged = datetime.datetime.now() queue.lastCheck = now queue.completed = True Db.flush() # Add to history h = History() h.movie = movie.id h.value = str(highest.id) + '-' + str(highest.size) h.status = u'snatched' Db.add(h) Db.flush() # Notify PROWL if self.config.get('PROWL', 'onSnatch'): log.debug('PROWL') prowl = PROWL() prowl.notify(highest.name, 'Download Started') # Notify XBMC if self.config.get('XBMC', 'onSnatch'): log.debug('XBMC') xbmc = XBMC() xbmc.notify('Snatched %s' % highest.name) # Notify GROWL if self.config.get('GROWL', 'onSnatch'): log.debug('GROWL') growl = GROWL() growl.notify('Snatched %s' % highest.name, 'Download Started') # Notify Notifo if self.config.get('Notifo', 'onSnatch'): log.debug('Notifo') notifo = Notifo() notifo.notify('%s' % highest.name, "Snatched:") # Notify SNS if self.config.get('SNS', 'onSnatch'): log.debug('SNS') sns = SNS() sns.notify('%s' % highest.name, "Snatched:") # Notify Boxcar if self.config.get('Boxcar', 'onSnatch'): log.debug('Boxcar') boxcar = Boxcar() boxcar.notify('%s' % highest.name, "Snatched:") # Notify NotifyMyAndroid if self.config.get('NMA', 'onSnatch'): log.debug('NotifyMyAndroid') nma = NMA() nma.notify('Download Started', 'Snatched %s' % highest.name) # Notify NotifyMyWindowsPhone if self.config.get('NMWP', 'onSnatch'): log.debug('NotifyMyWindowsPhone') nmwp = NMWP() nmwp.notify('Download Started', 'Snatched %s' % highest.name) # Notify Twitter if self.config.get('Twitter', 'onSnatch'): log.debug('Twitter') twitter = Twitter() twitter.notify('Download Started', 'Snatched %s' % highest.name) return True queue.lastCheck = now Db.flush() return False