def run(self, force=False): """ Runs the daily searcher, queuing selected episodes for search :param force: Force search """ if self.amActive: 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 ...") curDate = (datetime.date.today() + datetime.timedelta(days=2)).toordinal() if tz_updater.load_network_dict(): curDate = (datetime.date.today() + datetime.timedelta(days=1)).toordinal() curTime = datetime.datetime.now(tz_updater.sr_timezone) show = None for dbData in [ x['doc'] for x in MainDB().db.all('tv_episodes', with_doc=True) if x['doc']['status'] in [UNAIRED, WANTED] and x['doc']['season'] > 0 and curDate >= x['doc']['airdate'] > 1 ]: try: if not show or int(dbData['showid']) != show.indexerid: show = findCertainShow(sickrage.srCore.SHOWLIST, int(dbData['showid'])) # for when there is orphaned series in the database but not loaded into our showlist if not show or show.paused: continue except MultipleShowObjectsException: sickrage.srCore.srLogger.info( "ERROR: expected to find a single show matching " + str(dbData['showid'])) 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( dbData['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(dbData['season']), int(dbData['episode'])) with ep.lock: if ep.season == 0: sickrage.srCore.srLogger.info( "New episode " + ep.prettyName() + " airs today, setting status to SKIPPED because is a special season" ) ep.status = SKIPPED else: sickrage.srCore.srLogger.info( "New episode %s airs today, setting to default episode status for this show: %s" % (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 ...") # 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.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
def run(self, force=False): """ Runs the daily searcher, queuing selected episodes for search :param force: Force search """ if self.amActive: 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 ...") curDate = (datetime.date.today() + datetime.timedelta(days=2)).toordinal() if tz_updater.load_network_dict(): curDate = (datetime.date.today() + datetime.timedelta(days=1)).toordinal() curTime = datetime.datetime.now(tz_updater.sr_timezone) show = None for dbData in [x['doc'] for x in sickrage.srCore.mainDB.db.all('tv_episodes', with_doc=True) if x['doc']['status'] in [UNAIRED, WANTED] and x['doc']['season'] > 0 and curDate >= x['doc']['airdate'] > 1]: try: if not show or int(dbData['showid']) != show.indexerid: show = findCertainShow(sickrage.srCore.SHOWLIST, int(dbData['showid'])) # for when there is orphaned series in the database but not loaded into our showlist if not show or show.paused: continue except MultipleShowObjectsException: sickrage.srCore.srLogger.info("ERROR: expected to find a single show matching " + str(dbData['showid'])) 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(dbData['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(dbData['season']), int(dbData['episode'])) with ep.lock: if ep.season == 0: sickrage.srCore.srLogger.info( "New episode " + ep.prettyName() + " airs today, setting status to SKIPPED because is a special season") ep.status = SKIPPED else: sickrage.srCore.srLogger.info( "New episode %s airs today, setting to default episode status for this show: %s" % ( 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 ...") # queue episode for daily search sickrage.srCore.SEARCHQUEUE.put(DailySearchQueueItem()) self.amActive = False