Skip to content

Commit

Permalink
[build] Arr version handling update
Browse files Browse the repository at this point in the history
  • Loading branch information
Feramance committed Oct 23, 2023
1 parent 8dca686 commit 61aad1f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 15 additions & 13 deletions qBitrr/arss.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import qbittorrentapi
import qbittorrentapi.exceptions
import requests
from packaging import version as version_parser
from peewee import JOIN, SqliteDatabase, fn
from pyarr import RadarrAPI, SonarrAPI
from qbittorrentapi import TorrentDictionary, TorrentStates
Expand Down Expand Up @@ -113,7 +114,8 @@ def __init__(
self.completed_folder = pathlib.Path(COMPLETED_DOWNLOAD_FOLDER).joinpath(self.category)
if not self.completed_folder.exists() and not SEARCH_ONLY:
try:
self.completed_folder.mkdir(mode=777, parents=True, exist_ok=True)
self.completed_folder.mkdir(parents=True, exist_ok=True)
self.completed_folder.chmod(mode=0o777)
except BaseException:
self.logger.warning(
"%s completed folder is a soft requirement. The specified folder does not exist %s and cannot be created. This will disable all file monitoring.",
Expand Down Expand Up @@ -302,13 +304,13 @@ def __init__(
if isinstance(self.client, SonarrAPI):
self.type = "sonarr"
version_info = self.client.get_update()
self.version = version_info[0].get("version")[:1]
self.logger.debug("%s version: %s", self._name, self.version)
self.version = version_parser.parse(version_info[0].get("version"))
self.logger.debug("%s version: %s", self.version)
elif isinstance(self.client, RadarrAPI):
self.type = "radarr"
version_info = self.client.get_update()
self.version = version_info[0].get("version")[:1]
self.logger.debug("%s version: %s", self._name, self.version)
self.version = version_parser.parse(version_info[0].get("version"))
self.logger.debug("%s version: %s", self.version)

if self.rss_sync_timer > 0:
self.rss_sync_timer_last_checked = datetime(1970, 1, 1)
Expand Down Expand Up @@ -565,9 +567,9 @@ def _get_arr_modes(
if self.type == "sonarr":
return EpisodesModel, CommandsModel, SeriesModel
elif self.type == "radarr":
if self.version == "4":
if self.version.major == 4:
return MoviesModel, CommandsModel, MoviesMetadataModel
elif self.version == "5":
elif self.version.major == 5:
return MoviesModelv5, CommandsModel, MoviesMetadataModel
else:
raise UnhandledError("Well you shouldn't have reached here, Arr.type=%s" % self.type)
Expand Down Expand Up @@ -1418,9 +1420,9 @@ def _db_request_update(self, request_ids: dict[str, set[int | str]]):
):
self.db_update_single_series(db_entry=db_entry, request=True)
elif self.type == "radarr" and any(i in request_ids for i in ["ImdbId", "TmdbId"]):
if self.version == "4":
if self.version.major == 4:
self.model_arr_file: MoviesModel
elif self.version == "5":
elif self.version.major == 5:
self.model_arr_file: MoviesModelv5
self.model_arr_movies_file: MoviesMetadataModel
condition = self.model_arr_movies_file.Year <= datetime.now().year
Expand Down Expand Up @@ -1561,9 +1563,9 @@ def db_update(self):
):
self.db_update_single_series(db_entry=series, series=True)
elif self.type == "radarr":
if self.version == "4":
if self.version.major == 4:
self.model_arr_file: MoviesModel
elif self.version == "5":
elif self.version.major == 5:
self.model_arr_file: MoviesModelv5
if self.search_by_year:
for movies in (
Expand Down Expand Up @@ -1991,9 +1993,9 @@ def db_update_single_series(

elif self.type == "radarr":
self.model_file: MoviesFilesModel
if self.version == "4":
if self.version.major == 4:
db_entry: MoviesModel
elif self.version == "5":
elif self.version.major == 5:
db_entry: MoviesModelv5
searched = False
QualityUnmet = self.quality_unmet_search
Expand Down
2 changes: 1 addition & 1 deletion qBitrr/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

class qBitManager:
min_supported_version = VersionClass("4.3.9")
soft_not_supported_supported_version = VersionClass("4.5")
soft_not_supported_supported_version = VersionClass("4.4.4")
max_supported_version = VersionClass("4.6.0")
_head_less_mode = False

Expand Down

0 comments on commit 61aad1f

Please sign in to comment.