def run(self, force=False): if self.amActive: return self.amActive = True # set thread name threading.currentThread().setName(self.name) update_timestamp = int(time.mktime( datetime.datetime.now().timetuple())) try: dbData = sickrage.app.cache_db.db.get('lastUpdate', 'theTVDB', with_doc=True)['doc'] last_update = int(dbData['time']) except RecordNotFound: last_update = update_timestamp dbData = sickrage.app.cache_db.db.insert({ '_t': 'lastUpdate', 'provider': 'theTVDB', 'time': 0 }) # get indexer updated show ids indexer_api = IndexerApi().indexer(**IndexerApi().api_params.copy()) updated_shows = set(s["id"] for s in indexer_api.updated(last_update) or {}) # start update process pi_list = [] for show in sickrage.app.showlist: if show.paused: sickrage.app.log.info( 'Show update skipped, show: {} is paused.'.format( show.name)) try: show.nextEpisode() stale = ( datetime.datetime.now() - datetime.datetime.fromordinal(show.last_update)).days > 7 if show.indexerid in updated_shows or stale: pi_list.append( sickrage.app.show_queue.updateShow(show, False)) else: pi_list.append( sickrage.app.show_queue.refreshShow(show, False)) except (CantUpdateShowException, CantRefreshShowException) as e: sickrage.app.log.debug("Automatic update failed: {}".format( e.message)) ProgressIndicators.setIndicator( 'dailyShowUpdates', QueueProgressIndicator("Daily Show Updates", pi_list)) dbData['time'] = update_timestamp sickrage.app.cache_db.db.update(dbData) self.amActive = False
def run(self, force=False): if self.amActive: return self.amActive = True # set thread name threading.currentThread().setName(self.name) update_timestamp = int(time.mktime(datetime.datetime.now().timetuple())) dbData = sickrage.app.cache_db.get('lastUpdate', 'theTVDB') if dbData: last_update = int(dbData['time']) else: last_update = update_timestamp dbData = sickrage.app.cache_db.insert({ '_t': 'lastUpdate', 'provider': 'theTVDB', 'time': 0 }) # get indexer updated show ids indexer_api = IndexerApi().indexer(**IndexerApi().api_params.copy()) updated_shows = set(s["id"] for s in indexer_api.updated(last_update) or {}) # start update process pi_list = [] for show in sickrage.app.showlist: if show.paused: sickrage.app.log.info('Show update skipped, show: {} is paused.'.format(show.name)) continue if show.status == 'Ended': if not sickrage.app.config.showupdate_stale: sickrage.app.log.info('Show update skipped, show: {} status is ended.'.format(show.name)) continue elif not (datetime.datetime.now() - datetime.datetime.fromordinal(show.last_update)).days >= 90: sickrage.app.log.info( 'Show update skipped, show: {} status is ended and recently updated.'.format(show.name)) continue try: if show.indexerid in updated_shows: pi_list.append(sickrage.app.show_queue.updateShow(show, indexer_update_only=True, force=False)) elif (datetime.datetime.now() - datetime.datetime.fromordinal(show.last_update)).days >= 7: pi_list.append(sickrage.app.show_queue.updateShow(show, force=False)) #else: # pi_list.append(sickrage.app.show_queue.refreshShow(show, False)) except (CantUpdateShowException, CantRefreshShowException) as e: sickrage.app.log.debug("Automatic update failed: {}".format(e)) ProgressIndicators.setIndicator('dailyShowUpdates', QueueProgressIndicator("Daily Show Updates", pi_list)) dbData['time'] = update_timestamp sickrage.app.cache_db.update(dbData) self.amActive = False
def run(self, force=False): if self.amActive: return self.amActive = True # set thread name threading.currentThread().setName(self.name) update_timestamp = int(time.mktime(datetime.datetime.now().timetuple())) try: dbData = sickrage.app.cache_db.db.get('lastUpdate', 'theTVDB', with_doc=True)['doc'] last_update = int(dbData['time']) except RecordNotFound: last_update = update_timestamp dbData = sickrage.app.cache_db.db.insert({ '_t': 'lastUpdate', 'provider': 'theTVDB', 'time': 0 }) # get indexer updated show ids indexer_api = IndexerApi().indexer(**IndexerApi().api_params.copy()) updated_shows = set(s["id"] for s in indexer_api.updated(last_update) or {}) # start update process pi_list = [] for show in sickrage.app.showlist: if show.paused: sickrage.app.log.info('Show update skipped, show: {} is paused.'.format(show.name)) try: show.nextEpisode() stale = (datetime.datetime.now() - datetime.datetime.fromordinal(show.last_update)).days > 7 if show.indexerid in updated_shows or stale: pi_list.append(sickrage.app.show_queue.updateShow(show, False)) else: pi_list.append(sickrage.app.show_queue.refreshShow(show, False)) except (CantUpdateShowException, CantRefreshShowException) as e: sickrage.app.log.debug("Automatic update failed: {}".format(e.message)) ProgressIndicators.setIndicator('dailyShowUpdates', QueueProgressIndicator("Daily Show Updates", pi_list)) dbData['time'] = update_timestamp sickrage.app.cache_db.db.update(dbData) self.amActive = False
def task(self, force=False): if self.running and not force: return try: self.running = True # set thread name threading.currentThread().setName(self.name) session = sickrage.app.cache_db.session() update_timestamp = int( time.mktime(datetime.datetime.now().timetuple())) try: dbData = session.query( CacheDB.LastUpdate).filter_by(provider='theTVDB').one() last_update = int(dbData.time) except orm.exc.NoResultFound: last_update = update_timestamp dbData = CacheDB.LastUpdate(**{ 'provider': 'theTVDB', 'time': 0 }) session.add(dbData) finally: session.commit() # get indexer updated show ids indexer_api = IndexerApi().indexer( **IndexerApi().api_params.copy()) updated_shows = set( s["id"] for s in indexer_api.updated(last_update) or {}) # start update process pi_list = [] for show_obj in get_show_list(): if show_obj.paused: sickrage.app.log.info( 'Show update skipped, show: {} is paused.'.format( show_obj.name)) continue if show_obj.status == 'Ended': if not sickrage.app.config.showupdate_stale: sickrage.app.log.info( 'Show update skipped, show: {} status is ended.'. format(show_obj.name)) continue elif not (datetime.datetime.now() - datetime.datetime.fromordinal( show_obj.last_update)).days >= 90: sickrage.app.log.info( 'Show update skipped, show: {} status is ended and recently updated.' .format(show_obj.name)) continue try: if show_obj.indexer_id in updated_shows: pi_list.append( sickrage.app.show_queue.update_show( show_obj.indexer_id, indexer_update_only=True, force=False)) elif (datetime.datetime.now() - datetime.datetime.fromordinal( show_obj.last_update)).days >= 7: pi_list.append( sickrage.app.show_queue.update_show( show_obj.indexer_id, force=False)) except (CantUpdateShowException, CantRefreshShowException) as e: sickrage.app.log.debug( "Automatic update failed: {}".format(e)) ProgressIndicators.setIndicator( 'dailyShowUpdates', QueueProgressIndicator("Daily Show Updates", pi_list)) dbData.time = update_timestamp session.commit() finally: self.running = False