Skip to content

Commit

Permalink
[patch] Quick fix for config generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Feramance committed Aug 24, 2023
1 parent b664a66 commit dc60fcb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 37 deletions.
77 changes: 41 additions & 36 deletions qBitrr/arss.py
Original file line number Diff line number Diff line change
Expand Up @@ -1337,39 +1337,39 @@ def db_update(self):
self.logger.trace(f"Started updating database")
self.db_update_todays_releases()
with self.db.atomic():
if self.type == "sonarr":
if not self.series_search:
_series = set()
for series in self.model_arr_file.select().where(
(self.model_arr_file.AirDateUtc.is_null(False))
& (self.model_arr_file.AirDateUtc < datetime.now(timezone.utc))
& (
self.model_arr_file.AbsoluteEpisodeNumber.is_null(False)
| self.model_arr_file.SceneAbsoluteEpisodeNumber.is_null(False)
)
& (
self.model_arr_file.AirDateUtc
>= datetime(month=1, day=1, year=self.search_current_year)
)
& (
self.model_arr_file.AirDateUtc
<= datetime(month=12, day=31, year=self.search_current_year)
)
):
series: EpisodesModel
_series.add(series.SeriesId)
self.db_update_single_series(db_entry=series)
for series in self.model_arr_file.select().where(
self.model_arr_file.SeriesId.in_(_series)
):
self.db_update_single_series(db_entry=series)
else:
for series in self.model_arr_series_file.select().order_by(
self.model_arr_series_file.Added.desc()
):
self.db_update_single_series(db_entry=series, series=True)
elif self.type == "radarr":
try:
try:
if self.type == "sonarr":
if not self.series_search:
_series = set()
for series in self.model_arr_file.select().where(
(self.model_arr_file.AirDateUtc.is_null(False))
& (self.model_arr_file.AirDateUtc < datetime.now(timezone.utc))
& (
self.model_arr_file.AbsoluteEpisodeNumber.is_null(False)
| self.model_arr_file.SceneAbsoluteEpisodeNumber.is_null(False)
)
& (
self.model_arr_file.AirDateUtc
>= datetime(month=1, day=1, year=self.search_current_year)
)
& (
self.model_arr_file.AirDateUtc
<= datetime(month=12, day=31, year=self.search_current_year)
)
):
series: EpisodesModel
_series.add(series.SeriesId)
self.db_update_single_series(db_entry=series)
for series in self.model_arr_file.select().where(
self.model_arr_file.SeriesId.in_(_series)
):
self.db_update_single_series(db_entry=series)
else:
for series in self.model_arr_series_file.select().order_by(
self.model_arr_series_file.Added.desc()
):
self.db_update_single_series(db_entry=series, series=True)
elif self.type == "radarr":
for movies in (
self.model_arr_file.select(self.model_arr_file)
.join(
Expand All @@ -1383,8 +1383,9 @@ def db_update(self):
.order_by(self.model_arr_file.Added.desc())
):
self.db_update_single_series(db_entry=movies)
except BaseException:
pass
except BaseException:
self.logger.error(e.message)
raise DelayLoopException(length=300, type="delay")
self.logger.trace(f"Finished updating database")

def minimum_availability_check(
Expand Down Expand Up @@ -2038,6 +2039,10 @@ def process_torrents(self):
self.process()
except NoConnectionrException as e:
self.logger.error(e.message)
except requests.exceptions.ConnectionError:
self.logger.warning("Couldn't connect to %s", self.type)
self._temp_overseer_request_cache = defaultdict(set)
return self._temp_overseer_request_cache
except qbittorrentapi.exceptions.APIError as e:
self.logger.error("The qBittorrent API returned an unexpected error")
self.logger.debug("Unexpected APIError from qBitTorrent", exc_info=e)
Expand Down Expand Up @@ -3321,7 +3326,7 @@ def run_torrent_loop(self) -> NoReturn:
except NoConnectionrException as e:
self.logger.error(e.message)
self.manager.qbit_manager.should_delay_torrent_scan = True
raise DelayLoopException(length=300, type=e.type)
raise DelayLoopException(length=300, type="arr")
except qbittorrentapi.exceptions.APIConnectionError as e:
self.logger.warning(e)
raise DelayLoopException(length=300, type="qbit")
Expand Down
2 changes: 1 addition & 1 deletion qBitrr/gen_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def _gen_default_search_table(category: str, cat_default: Table):
search_table.add(
comment("First year to search; Remove this field to set it to the current year.")
)
search_table.add(comment("StartYear", datetime.now().year))
search_table.add("#StartYear", datetime.now().year)
search_table.add(nl())
search_table.add(comment("Last Year to Search"))
search_table.add("LastYear", 1900)
Expand Down

0 comments on commit dc60fcb

Please sign in to comment.