def setEpisodeToWanted(show, s, e): """ Sets an episode to wanted, only if it is currently skipped """ epObj = show.getEpisode(int(s), int(e)) if epObj: with epObj.lock: if epObj.status != SKIPPED or epObj.airdate == datetime.date.fromordinal( 1): return logger.log(u"Setting episode %s S%02dE%02d to wanted" % (show.name, s, e)) # figure out what segment the episode is in and remember it so we can backlog it epObj.status = WANTED epObj.saveToDB() cur_backlog_queue_item = search_queue.BacklogQueueItem(show, [epObj]) sickbeard.searchQueueScheduler.action.add_item(cur_backlog_queue_item) logger.log( u"Starting backlog search for %s S%02dE%02d because some episodes were set to wanted" % (show.name, s, e))
def startBacklog(self, show): segments = [i for i in self.todoBacklog if i[0] == show] for segment in segments: cur_backlog_queue_item = search_queue.BacklogQueueItem(show, segment[1]) sickbeard.searchQueueScheduler.action.add_item(cur_backlog_queue_item) logger.log(u"Starting backlog for " + show.name + " season " + str(segment[1]) + " because some eps were set to wanted") self.todoBacklog.remove(segment)
def setEpisodeToWanted(self, show, s, e): """ Sets an episode to wanted, only is it is currently skipped or Downloadable """ epObj = show.getEpisode(int(s), int(e)) if epObj: with epObj.lock: if epObj.status not in ( SKIPPED, DOWNLOADABLE ) or epObj.airdate == datetime.date.fromordinal(1): return logger.log(u"Setting episode s" + str(s) + "e" + str(e) + " of show " + show.name + " to wanted") # figure out what segment the episode is in and remember it so we can backlog it epObj.status = WANTED epObj.saveToDB() cur_backlog_queue_item = search_queue.BacklogQueueItem( show, [epObj]) sickbeard.searchQueueScheduler.action.add_item( cur_backlog_queue_item) logger.log(u"Starting backlog for " + show.name + " season " + str(s) + " episode " + str(e) + " because some eps were set to wanted")
def setEpisodeToWanted(self, show, s, e): """ Sets an episode to wanted, only is it is currently skipped """ epObj = show.getEpisode(int(s), int(e)) if epObj: segments = {} with epObj.lock: if epObj.status != SKIPPED: return logger.log(u"Setting episode s" + str(s) + "e" + str(e) + " of show " + show.name + " to wanted") # figure out what segment the episode is in and remember it so we can backlog it if epObj.season in ep_segment: segments[epObj.season].append(epObj) else: segments[epObj.season] = [epObj] epObj.status = WANTED epObj.saveToDB() for season, segment in segments.items(): cur_backlog_queue_item = search_queue.BacklogQueueItem( show, segment[1]) sickbeard.searchQueueScheduler.action.add_item( cur_backlog_queue_item) logger.log(u"Starting backlog for " + show.name + " season " + str(season) + " because some eps were set to wanted")
def searchBacklog(self, which_shows=None): if self.amActive: logger.log(u"Backlog is still running, not starting it again", logger.DEBUG) return self.amActive = True self.amPaused = False if which_shows: show_list = which_shows else: show_list = sickbeard.showList self._get_lastBacklog() curDate = datetime.date.today().toordinal() fromDate = datetime.date.fromordinal(1) if not which_shows and not ( (curDate - self._lastBacklog) >= self.cycleTime): logger.log(u"Running limited backlog on missed episodes " + str(sickbeard.BACKLOG_DAYS) + " day(s) and older only") fromDate = datetime.date.today() - datetime.timedelta( days=sickbeard.BACKLOG_DAYS) # go through non air-by-date shows and see if they need any episodes for curShow in show_list: if curShow.paused: continue segments = self._get_segments(curShow, fromDate) for season, segment in segments.iteritems(): self.currentSearchInfo = { 'title': curShow.name + " Season " + str(season) } backlog_queue_item = search_queue.BacklogQueueItem( curShow, segment) sickbeard.searchQueueScheduler.action.add_item( backlog_queue_item) # @UndefinedVariable if not segments: logger.log( u"Nothing needs to be downloaded for %s, skipping" % curShow.name, logger.DEBUG) # don't consider this an actual backlog search if we only did recent eps # or if we only did certain shows if fromDate == datetime.date.fromordinal(1) and not which_shows: self._set_lastBacklog(curDate) self.amActive = False self._resetPI()
def process(self): self._log(u"Failed download detected: (" + str(self.nzb_name) + ", " + str(self.dir_name) + ")") releaseName = show_name_helpers.determineReleaseName( self.dir_name, self.nzb_name) if releaseName is None: self._log(u"Warning: unable to find a valid release name.", logger.WARNING) raise exceptions.FailedProcessingFailed() parser = NameParser(False) try: parsed = parser.parse(releaseName) except InvalidNameException: self._log(u"Error: release name is invalid: " + releaseName, logger.WARNING) raise exceptions.FailedProcessingFailed() logger.log(u"name_parser info: ", logger.DEBUG) logger.log(u" - " + str(parsed.series_name), logger.DEBUG) logger.log(u" - " + str(parsed.season_number), logger.DEBUG) logger.log(u" - " + str(parsed.episode_numbers), logger.DEBUG) logger.log(u" - " + str(parsed.extra_info), logger.DEBUG) logger.log(u" - " + str(parsed.release_group), logger.DEBUG) logger.log(u" - " + str(parsed.air_date), logger.DEBUG) show_id = self._get_show_id(parsed.series_name) if show_id is None: self._log(u"Warning: couldn't find show ID", logger.WARNING) raise exceptions.FailedProcessingFailed() self._log(u"Found show_id: " + str(show_id), logger.DEBUG) self._show_obj = helpers.findCertainShow(sickbeard.showList, show_id) if self._show_obj is None: self._log( u"Could not create show object. Either the show hasn't been added to SickBeard, or it's still loading (if SB was restarted recently)", logger.WARNING) raise exceptions.FailedProcessingFailed() # Revert before fail, as fail alters the history self._log(u"Reverting episodes...") self.log += failed_history.revertEpisodes(self._show_obj, parsed.season_number, parsed.episode_numbers) self._log(u"Marking release as bad: " + releaseName) self.log += failed_history.logFailed(releaseName) cur_backlog_queue_item = search_queue.BacklogQueueItem( self._show_obj, parsed.season_number) sickbeard.searchQueueScheduler.action.add_item(cur_backlog_queue_item) return True
def searchBacklog(self, which_shows=None): if self.amActive: logger.log(u"Backlog is still running, not starting it again", logger.DEBUG) return if which_shows: show_list = which_shows else: show_list = sickbeard.showList self._get_lastBacklog() curDate = datetime.date.today().toordinal() fromDate = datetime.date.fromordinal(1) if not which_shows and not curDate - self._lastBacklog >= self.cycleTime: logger.log( u"Running limited backlog on recently missed episodes only") fromDate = datetime.date.today() - datetime.timedelta(days=7) self.amActive = True self.amPaused = False # go through non air-by-date shows and see if they need any episodes for curShow in show_list: if curShow.paused: continue segments = self._get_segments(curShow, fromDate) if len(segments): backlog_queue_item = search_queue.BacklogQueueItem( curShow, segments) sickbeard.searchQueueScheduler.action.add_item( backlog_queue_item) #@UndefinedVariable else: logger.log( u"Nothing needs to be downloaded for " + str(curShow.name) + ", skipping this season", logger.DEBUG) # don't consider this an actual backlog search if we only did recent eps # or if we only did certain shows if fromDate == datetime.date.fromordinal(1) and not which_shows: self._set_lastBacklog(curDate) self.amActive = False self._resetPI()
def add_backlog_item(self, items, standard_backlog, limited_backlog, forced, torrent_only): for segments in items: if len(segments): for season, segment in segments.items(): self.currentSearchInfo = { 'title': segment[0].show.name + ' Season ' + str(season) } backlog_queue_item = search_queue.BacklogQueueItem( segment[0].show, segment, standard_backlog=standard_backlog, limited_backlog=limited_backlog, forced=forced, torrent_only=torrent_only) sickbeard.searchQueueScheduler.action.add_item( backlog_queue_item)
def searchBacklog(self, which_shows=None): if which_shows: show_list = which_shows else: show_list = sickbeard.showList if self.amActive == True: logger.log(u"Backlog is still running, not starting it again", logger.DEBUG) return self._get_lastBacklog() curDate = datetime.date.today().toordinal() fromDate = datetime.date.fromordinal(1) if not which_shows and not curDate - self._lastBacklog >= self.cycleTime: logger.log( u"Running limited backlog on recently missed episodes only") fromDate = datetime.date.today() - datetime.timedelta(days=7) self.amActive = True self.amPaused = False myDB = db.DBConnection() numSeasonResults = myDB.select( "SELECT DISTINCT(season), showid FROM tv_episodes ep, tv_shows show WHERE season != 0 AND ep.showid = show.tvdb_id AND show.paused = 0 AND ep.airdate > ?", [fromDate.toordinal()]) # get separate lists of the season/date shows season_shows = [x for x in show_list if not x.air_by_date] air_by_date_shows = [x for x in show_list if x.air_by_date] # figure out how many segments of air by date shows we're going to do air_by_date_segments = [] for cur_id in [x.tvdbid for x in air_by_date_shows]: air_by_date_segments += self._get_air_by_date_segments( cur_id, fromDate) logger.log(u"Air-by-date segments: " + str(air_by_date_segments), logger.DEBUG) totalSeasons = float(len(numSeasonResults) + len(air_by_date_segments)) numSeasonsDone = 0.0 # go through non air-by-date shows and see if they need any episodes for curShow in show_list: if curShow.paused: continue if curShow.air_by_date: segments = [ x[1] for x in self._get_air_by_date_segments( curShow.tvdbid, fromDate) ] else: segments = self._get_season_segments(curShow.tvdbid, fromDate) for cur_segment in segments: self.currentSearchInfo = { 'title': curShow.name + " Season " + str(cur_segment) } backlog_queue_item = search_queue.BacklogQueueItem( curShow, cur_segment) if not backlog_queue_item.wantSeason: logger.log( u"Nothing in season " + str(cur_segment) + " needs to be downloaded, skipping this season", logger.DEBUG) else: sickbeard.searchQueueScheduler.action.add_item( backlog_queue_item) # don't consider this an actual backlog search if we only did recent eps # or if we only did certain shows if fromDate == datetime.date.fromordinal(1) or not which_shows: self._set_lastBacklog(curDate) self.amActive = False self._resetPI()
def searchBacklog(self, which_shows=None, force_type=NORMAL_BACKLOG): if self.amActive: logger.log(u'Backlog is still running, not starting it again', logger.DEBUG) return if which_shows: show_list = which_shows standard_backlog = False else: show_list = sickbeard.showList standard_backlog = True self._get_lastBacklog() curDate = datetime.date.today().toordinal() fromDate = datetime.date.fromordinal(1) limited_backlog = False if (not which_shows and force_type == LIMITED_BACKLOG) or ( not which_shows and force_type != FULL_BACKLOG and not curDate - self._lastBacklog >= self.cycleTime): logger.log( u'Running limited backlog for episodes missed during the last %s day(s)' % str(sickbeard.BACKLOG_DAYS)) fromDate = datetime.date.today() - datetime.timedelta( days=sickbeard.BACKLOG_DAYS) limited_backlog = True forced = False if not which_shows and force_type != NORMAL_BACKLOG: forced = True self.amActive = True self.amPaused = False # go through non air-by-date shows and see if they need any episodes for curShow in show_list: if curShow.paused: continue segments = wantedEpisodes(curShow, fromDate, make_dict=True) for season, segment in segments.items(): self.currentSearchInfo = { 'title': curShow.name + ' Season ' + str(season) } backlog_queue_item = search_queue.BacklogQueueItem( curShow, segment, standard_backlog=standard_backlog, limited_backlog=limited_backlog, forced=forced) sickbeard.searchQueueScheduler.action.add_item( backlog_queue_item) # @UndefinedVariable else: logger.log( u'Nothing needs to be downloaded for %s, skipping' % str(curShow.name), logger.DEBUG) # don't consider this an actual backlog search if we only did recent eps # or if we only did certain shows if fromDate == datetime.date.fromordinal(1) and not which_shows: self._set_lastBacklog(curDate) self.amActive = False self._resetPI()