Skip to content

Commit

Permalink
[patch] updated minimum availability to function off of radarr prefer…
Browse files Browse the repository at this point in the history
…ences rather than config file
  • Loading branch information
Feramance committed Aug 19, 2023
1 parent a8bc4cf commit 9a97456
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 23 deletions.
56 changes: 40 additions & 16 deletions qBitrr/arss.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@ def __init__(
self.quality_unmet_search = CONFIG.get(
f"{name}.EntrySearch.QualityUnmetSearch", fallback=False
)
self.minimum_availability = CONFIG.get(
f"{name}.EntrySearch.MinimumAvailability", fallback=3
)

self.ignore_torrents_younger_than = CONFIG.get(
f"{name}.Torrent.IgnoreTorrentsYoungerThan", fallback=600
Expand Down Expand Up @@ -1251,15 +1248,46 @@ def _db_request_update(self, request_ids: dict[str, set[int | str]]):
self.model_arr_file: MoviesModel
self.model_arr_movies_file: MoviesMetadataModel
condition = self.model_arr_movies_file.Year <= datetime.now().year
condition &= self.model_arr_movies_file.Year > 0
if self.minimum_availability == 2:
condition &= self.model_arr_movies_file.InCinemas <= datetime.now()
elif self.minimum_availability == 3:
condition &= (
self.model_arr_movies_file.DigitalRelease
<= datetime.now() | self.model_arr_movies_file.PhysicalRelease
<= datetime.now()

condition &= (
(
(
(
self.model_arr_movies_file.DigitalRelease
<= datetime.now() | self.model_arr_movies_file.PhysicalRelease
<= datetime.now()
)
| (
self.model_arr_movies_file.InCinemas.is_null()
& self.model_arr_movies_file.DigitalRelease.is_null()
& self.model_arr_movies_file.PhysicalRelease.is_null()
)
)
& self.model_arr_file.MinimumAvailability
== 3
)
| (
(
(self.model_arr_movies_file.InCinemas <= datetime.now())
| (
self.model_arr_movies_file.InCinemas.is_null()
& self.model_arr_movies_file.DigitalRelease.is_null()
& self.model_arr_movies_file.PhysicalRelease.is_null()
)
)
& self.model_arr_file.MinimumAvailability
== 2
)
| (
(
self.model_arr_movies_file.DigitalRelease.is_null()
& self.model_arr_movies_file.PhysicalRelease.is_null()
)
& self.model_arr_file.MinimumAvailability
== 1
)
)

tmdb_con = None
imdb_con = None
if ImdbIds := request_ids.get("ImdbId"):
Expand Down Expand Up @@ -1370,11 +1398,7 @@ def db_update(self):
self.model_arr_movies_file,
on=(self.model_arr_file.MovieMetadataId == self.model_arr_movies_file.Id),
)
.where(
self.model_arr_movies_file.Year
== self.search_current_year & self.model_arr_file.MinimumAvailability
== self.minimum_availability
)
.where(self.model_arr_movies_file.Year == self.search_current_year)
.order_by(self.model_arr_file.Added.desc())
):
self.db_update_single_series(db_entry=movies)
Expand Down
10 changes: 3 additions & 7 deletions qBitrr/gen_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,13 +610,6 @@ def _gen_default_search_table(category: str, cat_default: Table):
search_table.add(comment("Do a quality unmet search for existing entries."))
search_table.add("QualityUnmetSearch", False)
search_table.add(nl())
search_table.add(
comment(
"Choose Minimum Availability for Radarr Instances. (Announced=1, In Cinemas=2, Released=3)"
)
)
search_table.add("MinimumAvailability", 3)
search_table.add(nl())
search_table.add(
comment(
"Once you have search all files on your specified year range restart the loop and "
Expand Down Expand Up @@ -688,6 +681,9 @@ def _gen_default_overseerr_table(category: str, search_table: Table):
overseerr_table.add(comment("Only process approved requests"))
overseerr_table.add("ApprovedOnly", True)
overseerr_table.add(nl())
overseerr_table.add(comment("Only for 4K Instances"))
overseerr_table.add("Is4K", False)
overseerr_table.add(nl())
search_table.add("Overseerr", overseerr_table)


Expand Down

0 comments on commit 9a97456

Please sign in to comment.