def run(self, force=False): """ Runs the failed searcher, queuing selected episodes for search that have failed to snatch :param force: Force search """ if self.amActive or (not sickrage.app.config.use_failed_snatcher or sickrage.app.developer) and not force: return self.amActive = True # set thread name threading.currentThread().setName(self.name) # trim failed download history FailedHistory.trimHistory() sickrage.app.log.info("Searching for failed snatches") show = None failed_snatches = False snatched_episodes = ( x for x in sickrage.app.main_db.all('history') if x['action'] in Quality.SNATCHED + Quality.SNATCHED_BEST + Quality.SNATCHED_PROPER and 24 >= int( (datetime.datetime.now() - datetime.datetime.strptime( x['date'], History.date_format)).total_seconds() / 3600) >= sickrage.app.config.failed_snatch_age) downloaded_releases = ((x['showid'], x['season'], x['episode']) for x in sickrage.app.main_db.all('history') if x['action'] in Quality.DOWNLOADED) episodes = [ x for x in snatched_episodes if (x['showid'], x['season'], x['episode']) not in downloaded_releases ] for episode in episodes: failed_snatches = True if not show or int(episode["showid"]) != show.indexerid: show = findCertainShow(int(episode["showid"])) # for when there is orphaned series in the database but not loaded into our showlist if not show or show.paused: continue ep_obj = show.getEpisode(int(episode['season']), int(episode['episode'])) if isinstance(ep_obj, TVEpisode): # put it on the queue sickrage.app.search_queue.put( FailedQueueItem(show, [ep_obj], True)) if not failed_snatches: sickrage.app.log.info("No failed snatches found") self.amActive = False
def new_episode_finder(): curDate = datetime.date.today() if tz_updater.network_dict: curDate += datetime.timedelta(days=1) else: curDate += datetime.timedelta(days=2) curTime = datetime.datetime.now(sickrage.app.tz) show = None for episode in sickrage.app.main_db.all('tv_episodes'): if not all([ episode['status'] == common.UNAIRED, episode['season'] > 0, episode['airdate'] > 1 ]): continue if not show or int(episode["showid"]) != show.indexerid: show = findCertainShow(int(episode["showid"])) # for when there is orphaned series in the database but not loaded into our showlist if not show or show.paused: continue air_date = datetime.date.fromordinal(episode['airdate']) air_date += datetime.timedelta(days=show.search_delay) if not curDate.toordinal() >= air_date.toordinal(): continue if show.airs and show.network: # This is how you assure it is always converted to local time air_time = tz_updater.parse_date_time( episode['airdate'], show.airs, show.network).astimezone(sickrage.app.tz) # filter out any episodes that haven't started airing yet, # but set them to the default status while they are airing # so they are snatched faster if air_time > curTime: continue ep_obj = show.getEpisode(int(episode['season']), int(episode['episode'])) with ep_obj.lock: ep_obj.status = show.default_ep_status if ep_obj.season else common.SKIPPED sickrage.app.log.info( 'Setting status ({status}) for show airing today: {name} {special}' .format( name=ep_obj.pretty_name(), status=common.statusStrings[ep_obj.status], special='(specials are not supported)' if not ep_obj.season else '', )) ep_obj.saveToDB()
def run(self, force=False): """ Runs the failed searcher, queuing selected episodes for search that have failed to snatch :param force: Force search """ if self.amActive or (not sickrage.app.config.use_failed_snatcher or sickrage.app.developer) and not force: return self.amActive = True # set thread name threading.currentThread().setName(self.name) # trim failed download history FailedHistory.trimHistory() sickrage.app.log.info("Searching for failed snatches") show = None failed_snatches = False snatched_episodes = (x for x in sickrage.app.main_db.all('history') if x['action'] in Quality.SNATCHED + Quality.SNATCHED_BEST + Quality.SNATCHED_PROPER and 24 >= int((datetime.datetime.now() - datetime.datetime.strptime(x['date'], History.date_format)).total_seconds() / 3600) >= sickrage.app.config.failed_snatch_age) downloaded_releases = ((x['showid'], x['season'], x['episode']) for x in sickrage.app.main_db.all('history') if x['action'] in Quality.DOWNLOADED) episodes = [x for x in snatched_episodes if (x['showid'], x['season'], x['episode']) not in downloaded_releases] for episode in episodes: failed_snatches = True if not show or int(episode["showid"]) != show.indexerid: show = findCertainShow(int(episode["showid"])) # for when there is orphaned series in the database but not loaded into our showlist if not show or show.paused: continue ep_obj = show.get_episode(int(episode['season']), int(episode['episode'])) if isinstance(ep_obj, TVEpisode): curStatus, curQuality = Quality.splitCompositeStatus(ep_obj.status) if curStatus not in {SNATCHED, SNATCHED_BEST, SNATCHED_PROPER}: continue # put it on the queue sickrage.app.search_queue.put(FailedQueueItem(show, [ep_obj], True)) if not failed_snatches: sickrage.app.log.info("No failed snatches found") self.amActive = False
def run(self, force=False): """ Runs the daily searcher, queuing selected episodes for search :param force: Force search """ if self.amActive or sickrage.srCore.srConfig.DEVELOPER and not force: return self.amActive = True # set thread name threading.currentThread().setName(self.name) # trim failed download history if sickrage.srCore.srConfig.USE_FAILED_DOWNLOADS: FailedHistory.trimHistory() sickrage.srCore.srLogger.info("{}: Searching for new released episodes".format(self.name)) curDate = datetime.date.today() curDate += datetime.timedelta(days=2) if tz_updater.load_network_dict(): curDate += datetime.timedelta(days=1) curTime = datetime.datetime.now(tz_updater.sr_timezone) show = None episodes = [x['doc'] for x in sickrage.srCore.mainDB.db.all('tv_episodes', with_doc=True) if x['doc']['status'] == UNAIRED and x['doc']['season'] > 0 and curDate.toordinal() >= x['doc']['airdate'] > 1] for episode in episodes: if not show or int(episode["showid"]) != show.indexerid: show = findCertainShow(sickrage.srCore.SHOWLIST, int(episode["showid"])) # for when there is orphaned series in the database but not loaded into our showlist if not show or show.paused: continue if show.airs and show.network: # This is how you assure it is always converted to local time air_time = tz_updater.parse_date_time( episode['airdate'], show.airs, show.network, dateOnly=True ).astimezone(tz_updater.sr_timezone) # filter out any episodes that haven't started airing yet, # but set them to the default status while they are airing # so they are snatched faster if air_time > curTime: continue ep = show.getEpisode(int(episode['season']), int(episode['episode'])) with ep.lock: if ep.season == 0: sickrage.srCore.srLogger.info( "New episode {} airs today, setting status to SKIPPED because is a special season".format( ep.prettyName())) ep.status = SKIPPED else: sickrage.srCore.srLogger.info( "New episode {} airs today, setting to default episode status for this show: {}".format( ep.prettyName(), statusStrings[ep.show.default_ep_status])) ep.status = ep.show.default_ep_status ep.saveToDB() else: sickrage.srCore.srLogger.info("{}: No new released episodes found".format(self.name)) # queue episode for daily search sickrage.srCore.SEARCHQUEUE.put(DailySearchQueueItem()) self.amActive = False
def run(self, force=False): """ Runs the daily searcher, queuing selected episodes for search :param force: Force search """ if self.amActive or sickrage.app.developer and not force: return self.amActive = True # set thread name threading.currentThread().setName(self.name) # trim failed download history if sickrage.app.config.use_failed_downloads: FailedHistory.trimHistory() sickrage.app.log.info("Searching for new released episodes") curDate = datetime.date.today() curDate += datetime.timedelta(days=2) if tz_updater.load_network_dict(): curDate += datetime.timedelta(days=1) curTime = datetime.datetime.now(sickrage.app.tz) show = None episodes = [ x['doc'] for x in sickrage.app.main_db.db.all('tv_episodes', with_doc=True) if x['doc']['status'] == common.UNAIRED and x['doc']['season'] > 0 and curDate.toordinal() >= x['doc']['airdate'] > 1 ] new_episodes = False for episode in episodes: if not show or int(episode["showid"]) != show.indexerid: show = findCertainShow(sickrage.app.showlist, int(episode["showid"])) # for when there is orphaned series in the database but not loaded into our showlist if not show or show.paused: continue if show.airs and show.network: # This is how you assure it is always converted to local time air_time = tz_updater.parse_date_time( episode['airdate'], show.airs, show.network, dateOnly=True).astimezone(sickrage.app.tz) # filter out any episodes that haven't started airing yet, # but set them to the default status while they are airing # so they are snatched faster if air_time > curTime: continue ep_obj = show.getEpisode(int(episode['season']), int(episode['episode'])) with ep_obj.lock: ep_obj.status = show.default_ep_status if ep_obj.season else common.SKIPPED sickrage.app.log.info( 'Setting status ({status}) for show airing today: {name} {special}' .format( name=ep_obj.pretty_name(), status=common.statusStrings[ep_obj.status], special='(specials are not supported)' if not ep_obj.season else '', )) ep_obj.saveToDB() new_episodes = True if not new_episodes: sickrage.app.log.info("No new released episodes found") # queue episode for daily search sickrage.app.search_queue.put(DailySearchQueueItem()) self.amActive = False
def run(self, force=False): """ Runs the daily searcher, queuing selected episodes for search :param force: Force search """ if self.amActive or sickrage.app.developer and not force: return self.amActive = True # set thread name threading.currentThread().setName(self.name) # trim failed download history if sickrage.app.config.use_failed_downloads: FailedHistory.trimHistory() sickrage.app.log.info("Searching for new released episodes") curDate = datetime.date.today() curDate += datetime.timedelta(days=2) if tz_updater.load_network_dict(): curDate += datetime.timedelta(days=1) curTime = datetime.datetime.now(sickrage.app.tz) show = None episodes = [x['doc'] for x in sickrage.app.main_db.db.all('tv_episodes', with_doc=True) if x['doc']['status'] == common.UNAIRED and x['doc']['season'] > 0 and curDate.toordinal() >= x['doc']['airdate'] > 1] new_episodes = False for episode in episodes: if not show or int(episode["showid"]) != show.indexerid: show = findCertainShow(sickrage.app.showlist, int(episode["showid"])) # for when there is orphaned series in the database but not loaded into our showlist if not show or show.paused: continue if show.airs and show.network: # This is how you assure it is always converted to local time air_time = tz_updater.parse_date_time( episode['airdate'], show.airs, show.network, dateOnly=True ).astimezone(sickrage.app.tz) # filter out any episodes that haven't started airing yet, # but set them to the default status while they are airing # so they are snatched faster if air_time > curTime: continue ep_obj = show.getEpisode(int(episode['season']), int(episode['episode'])) with ep_obj.lock: ep_obj.status = show.default_ep_status if ep_obj.season else common.SKIPPED sickrage.app.log.info('Setting status ({status}) for show airing today: {name} {special}'.format( name=ep_obj.pretty_name(), status=common.statusStrings[ep_obj.status], special='(specials are not supported)' if not ep_obj.season else '', )) ep_obj.saveToDB() new_episodes = True if not new_episodes: sickrage.app.log.info("No new released episodes found") # queue episode for daily search sickrage.app.search_queue.put(DailySearchQueueItem()) self.amActive = False