diff --git a/qBitrr/arss.py b/qBitrr/arss.py index 0710d69b..4be6af5c 100755 --- a/qBitrr/arss.py +++ b/qBitrr/arss.py @@ -1102,6 +1102,10 @@ def db_reset__series_searched_state(self): self.series_file_model.update(Searched=False).where( self.series_file_model.EntryId.in_(series_ids) ).execute() + Ids = [id.Id for id in self.model_arr_series_file.select().execute()] + self.series_file_model.delete().where( + self.series_file_model.EntryId.not_in(Ids) + ).execute() def db_reset__episode_searched_state(self): self.model_file: EpisodeFilesModel @@ -1111,6 +1115,8 @@ def db_reset__episode_searched_state(self): self.model_file.update(Searched=False).where( self.model_file.Searched == True ).execute() + Ids = [id.Id for id in self.model_arr_file.select().execute()] + self.model_file.delete().where(self.model_file.EntryId.not_in(Ids)).execute() def db_reset__movie_searched_state(self): self.model_file: MoviesFilesModel @@ -1120,6 +1126,8 @@ def db_reset__movie_searched_state(self): self.model_file.update(Searched=False).where( self.model_file.Searched == True ).execute() + Ids = [id.Id for id in self.model_arr_file.select().execute()] + self.model_file.delete().where(self.model_file.EntryId.not_in(Ids)).execute() def db_get_files_series( self, @@ -1425,8 +1433,6 @@ def db_update(self): if self.type == "sonarr": if not self.series_search: self.model_arr_file: EpisodesModel - Ids = [id.Id for id in self.model_arr_file.select().execute()] - self.model_file.delete().where(self.model_file.EntryId.not_in(Ids)).execute() _series = set() if self.search_by_year: series_query = self.model_arr_file.select().where( @@ -1472,10 +1478,6 @@ def db_update(self): self.db_update_single_series(db_entry=series) else: self.model_arr_series_file: SeriesModel - Ids = [id.Id for id in self.model_arr_series_file.select().execute()] - self.series_file_model.delete().where( - self.series_file_model.EntryId.not_in(Ids) - ).execute() for series in ( self.model_arr_series_file.select() .order_by(self.model_arr_series_file.Added.desc()) @@ -1487,14 +1489,6 @@ def db_update(self): self.model_arr_file: MoviesModel elif self.version == "5": self.model_arr_file: MoviesModelv5 - Ids = [id.Id for id in self.model_arr_file.select().execute()] - deleted = ( - self.model_file.delete().where(self.model_file.EntryId.not_in(Ids)).execute() - ) - if deleted == 0: - self.logger.info("No records deleted") - elif deleted > 0: - self.logger.info("Deleted %s records", deleted) if self.search_by_year: for movies in ( self.model_arr_file.select(self.model_arr_file) @@ -3711,6 +3705,7 @@ def run_search_loop(self) -> NoReturn: years_index = 0 while True: if self.loop_completed: + self.register_search_mode() years_index = 0 timer = datetime.now() if self.search_by_year: