def execute(self): generic_queue.QueueItem.execute(self) logger.log(u"Beginning manual search for " + self.ep_obj.prettyName()) foundEpisode = search.findEpisode(self.ep_obj, manualSearch=True) result = False if not foundEpisode: ui.notifications.message( 'No downloads were found', "Couldn't find a download for <i>%s</i>" % self.ep_obj.prettyName()) logger.log(u"Unable to find a download for " + self.ep_obj.prettyName()) else: # just use the first result for now logger.log(u"Downloading episode from " + foundEpisode.url) result = search.snatchEpisode(foundEpisode) providerModule = foundEpisode.provider if not result: ui.notifications.error('Error while attempting to snatch ' + foundEpisode.name + ', check your logs') elif providerModule == None: ui.notifications.error( 'Provider is configured incorrectly, unable to download') self.success = result
def execute(self): generic_queue.QueueItem.execute(self) logger.log("Searching for download for " + self.ep_obj.prettyName(True)) (bestEpisode, otherEpisodes) = search.findEpisode(self.ep_obj, manualSearch=True) result = False if not bestEpisode: ui.notifications.message('No downloads were found', "Couldn't find a download for <i>%s</i>" % self.ep_obj.prettyName(True)) logger.log(u"Unable to find a download for "+self.ep_obj.prettyName(True)) else: # First attempt to download the best result logger.log(u"Downloading best result from " + bestEpisode.url) result = search.snatchEpisode(bestEpisode) providerModule = bestEpisode.provider if not result and otherEpisodes: # Attempt to download one of the other results (result, snatchedEpisode) = self._tryDownloadAny(otherEpisodes) providerModule = snatchedEpisode.provider if not result: ui.notifications.error('Error while attempting to download result for ' + self.ep_obj.prettyName(True) + ', check your logs') elif providerModule == None: ui.notifications.error('Provider is configured incorrectly, unable to download') self.success = result
def execute(self): generic_queue.QueueItem.execute(self) logger.log("Beginning manual search for " + self.ep_obj.prettyName()) foundEpisode = search.findEpisode(self.ep_obj, manualSearch=True) result = False if not foundEpisode: ui.notifications.message('No downloads were found', "Couldn't find a download for <i>%s</i>" % self.ep_obj.prettyName()) logger.log(u"Unable to find a download for " + self.ep_obj.prettyName()) else: # just use the first result for now logger.log(u"Downloading episode from " + foundEpisode.url) result = search.snatchEpisode(foundEpisode) providerModule = foundEpisode.provider if not result: ui.notifications.error('Error while attempting to snatch ' + foundEpisode.name + ', check your logs') elif providerModule == None: ui.notifications.error('Provider is configured incorrectly, unable to download') self.success = result
def execute(self): generic_queue.QueueItem.execute(self) results = [] for season, episode in self.segment.iteritems(): (release, provider) = failed_history.findRelease(self.show, season, episode) if release: logger.log(u"Marking release as bad: " + release) failed_history.markFailed(self.show, season, episode) failed_history.logFailed(release) failed_history.revertEpisode(self.show, season, episode) epObj = self.show.getEpisode(season, episode) result = search.findEpisode(epObj) if result: results.append(result) # download whatever we find for curResult in results: self.success = search.snatchEpisode(curResult) time.sleep(5) self.finish()
def execute(self): generic_queue.QueueItem.execute(self) if self.ep_obj: failed_history.revertEpisodes(self.show, self.ep_obj.season, [self.ep_obj.episode]) failed_history.logFailed(self.ep_obj.release_name) foundEpisode = search.findEpisode(self.ep_obj, manualSearch=True) result = False if not foundEpisode: ui.notifications.message('No downloads were found', "Couldn't find a download for <i>%s</i>" % self.ep_obj.prettyName()) logger.log(u"Unable to find a download for " + self.ep_obj.prettyName()) else: # just use the first result for now logger.log(u"Downloading episode from " + foundEpisode.url) result = search.snatchEpisode(foundEpisode) providerModule = foundEpisode.provider if not result: ui.notifications.error('Error while attempting to snatch ' + foundEpisode.name+', check your logs') elif providerModule == None: ui.notifications.error('Provider is configured incorrectly, unable to download') self.success = result else: results = [] myDB = db.DBConnection() if not self.show.air_by_date: sqlResults = myDB.select("SELECT episode, release_name FROM tv_episodes WHERE showid = ? AND season = ? AND status IN (" + ",".join([str(x) for x in common.Quality.FAILED]) + ")", [self.show.tvdbid, self.segment]) else: segment_year, segment_month = map(int, self.segment.split('-')) min_date = datetime.date(segment_year, segment_month, 1) # it's easier to just hard code this than to worry about rolling the year over or making a month length map if segment_month == 12: max_date = datetime.date(segment_year, 12, 31) else: max_date = datetime.date(segment_year, segment_month + 1, 1) - datetime.timedelta(days=1) sqlResults = myDB.select("SELECT episode, release_name FROM tv_episodes WHERE showid = ? AND airdate >= ? AND airdate <= ? AND status IN (" + ",".join([str(x) for x in common.Quality.FAILED]) + ")", [self.show.tvdbid, min_date.toordinal(), max_date.toordinal()]) for result in sqlResults: failed_history.revertEpisodes(self.show, self.segment, [result["episode"]]) failed_history.logFailed(result["release_name"]) results = search.findSeason(self.show, self.segment) # download whatever we find for curResult in results: search.snatchEpisode(curResult) time.sleep(5) self.finish()
def _searchBacklogForEp(self, curEp): foundResult = search.findEpisode(curEp) if not foundResult: logger.log("Unable to find NZB for " + curEp.prettyName(True)) else: # just use the first result for now search.snatchEpisode(foundResult)
def searchBacklog(self): if self.amActive == True: logger.log("Backlog is still running, not starting it again", logger.DEBUG) return self.amActive = True self._get_lastBacklog() curDate = datetime.date.today().toordinal() if curDate - self._lastBacklog >= self.cycleTime: logger.log("Searching the database for a list of backlogged episodes to download") myDB = db.DBConnection() sqlResults = myDB.select("SELECT * FROM tv_episodes WHERE status IN (" + str(BACKLOG) + ", " + str(DISCBACKLOG) + ")") if sqlResults == None or len(sqlResults) == 0: logger.log("No episodes were found in the backlog") self._set_lastBacklog(curDate) self.amActive = False return for sqlEp in sqlResults: try: show = helpers.findCertainShow(sickbeard.showList, int(sqlEp["showid"])) except exceptions.MultipleShowObjectsException: logger.log("ERROR: expected to find a single show matching " + sqlEp["showid"], logger.ERROR) continue curEp = show.getEpisode(sqlEp["season"], sqlEp["episode"]) logger.log("Found backlog episode: " + curEp.prettyName(True), logger.DEBUG) foundNZBs = search.findEpisode(curEp) if len(foundNZBs) == 0: logger.log("Unable to find NZB for " + curEp.prettyName(True)) else: # just use the first result for now search.snatchEpisode(foundNZBs[0]) time.sleep(10) self._set_lastBacklog(curDate) self.amActive = False
def test(self): global searchItems searchItems = curData["i"] show = TVShow(tvdbdid) show.name = show_name show.quality = curData["q"] show.saveToDB() sickbeard.showList.append(show) for epNumber in curData["e"]: episode = TVEpisode(show, curData["s"], epNumber) episode.status = c.WANTED episode.saveToDB() bestResult = search.findEpisode(episode, forceSearch) if not bestResult: self.assertEqual(curData["b"], bestResult) self.assertEqual(curData["b"], bestResult.name) #first is expected, second is choosen one
def searchForTodaysEpisodes(self): self._changeMissingEpisodes() # make sure our lists are up to date sickbeard.updateMissingList() sickbeard.updateAiringList() sickbeard.updateComingList() with self.lock: logger.log("Beginning search for todays episodes", logger.DEBUG) epList = sickbeard.missingList + sickbeard.airingList if epList == None or len(epList) == 0: logger.log("No episodes were found to download") return for curEp in epList: if curEp.show.paused: logger.log("Show "+curEp.show.name + " is currently paused, skipping search") continue foundEpisodes = search.findEpisode(curEp) if len(foundEpisodes) == 0: if curEp.status == PREDOWNLOADED: logger.log("Unable to find an HD version of the existing episode "+ curEp.prettyName(True)) else: logger.log("Unable to find download for " + curEp.prettyName(True)) else: # just use the first result for now search.snatchEpisode(foundEpisodes[0]) time.sleep(10) # update our lists to reflect any changes we just made sickbeard.updateMissingList() sickbeard.updateAiringList() sickbeard.updateComingList()
def searchEpisode(self, show=None, season=None, episode=None): outStr = "" epObj = _getEpisode(show, season, episode) if isinstance(epObj, str): return _genericMessage("Error", epObj) tempStr = "Searching for download for " + epObj.prettyName(True) logger.log(tempStr) outStr += tempStr + "<br />\n" foundEpisodes = search.findEpisode(epObj) if len(foundEpisodes) == 0: message = 'No downloads were found' flash.error(message, "Couldn't find a download for <i>%s</i>" % epObj.prettyName(True)) logger.log(message) else: # just use the first result for now logger.log("Downloading episode from " + foundEpisodes[0].url + "<br />\n") result = search.snatchEpisode(foundEpisodes[0]) providerModule = providers.getProviderModule(foundEpisodes[0].provider) if providerModule == None: flash.error('Provider is configured incorrectly, unable to download') else: flash.message('Episode snatched from <b>%s</b>' % providerModule.providerName) #TODO: check if the download was successful # update our lists to reflect the result if this search sickbeard.updateMissingList() sickbeard.updateAiringList() sickbeard.updateComingList() redirect("/home/displayShow?show=" + str(epObj.show.tvdbid))