Skip to content

Commit

Permalink
[build] Fixed Sonarr v4 Series table to match new field added
Browse files Browse the repository at this point in the history
  • Loading branch information
Feramance committed Nov 3, 2023
1 parent 740959c commit 7156cd1
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 8 deletions.
41 changes: 40 additions & 1 deletion qBitrr/arr_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class EpisodesModel(Model):
EpisodeFileId = IntegerField()
AbsoluteEpisodeNumber = IntegerField()
SceneAbsoluteEpisodeNumber = IntegerField()
SceneEpisodeNumber = IntegerField()
SceneSeasonNumber = IntegerField()
SceneEpisodeNumber = IntegerField()
Monitored = BooleanField()
AirDateUtc = DateTimeField(formats=["%Y-%m-%d %H:%M:%S.%f"])
AirDate = TextField()
Expand Down Expand Up @@ -137,3 +137,42 @@ class SeriesModel(Model):
AddOptions = TextField()
TvMazeId = IntegerField()
OriginalLanguage = IntegerField()


class SeriesModelv4(Model):
Id = IntegerField(null=False, primary_key=True)
TvdbId = IntegerField()
TvRageId = IntegerField()
ImdbId = TextField()
Title = TextField()
TitleSlug = TextField()
CleanTitle = TextField()
Status = IntegerField()
Overview = TextField()
AirTime = TextField()
Images = TextField()
Path = TextField()
Monitored = BooleanField()
SeasonFolder = IntegerField()
LastInfoSync = DateTimeField(formats=["%Y-%m-%d %H:%M:%S.%f"])
LastDiskSync = DateTimeField(formats=["%Y-%m-%d %H:%M:%S.%f"])
Runtime = IntegerField()
SeriesType = IntegerField()
Network = TextField()
UseSceneNumbering = BooleanField()
FirstAired = DateTimeField(formats=["%Y-%m-%d %H:%M:%S.%f"])
NextAiring = DateTimeField(formats=["%Y-%m-%d %H:%M:%S.%f"])
Year = IntegerField()
Seasons = TextField()
Actors = TextField()
Ratings = TextField()
Genres = TextField()
Certification = TextField()
SortTitle = TextField()
QualityProfileId = IntegerField()
Tags = TextField()
Added = DateTimeField(formats=["%Y-%m-%d %H:%M:%S.%f"])
AddOptions = TextField()
TvMazeId = IntegerField()
OriginalLanguage = IntegerField()
LastAired = DateTimeField(formats=["%Y-%m-%d %H:%M:%S.%f"])
27 changes: 20 additions & 7 deletions qBitrr/arss.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
MoviesModel,
MoviesModelv5,
SeriesModel,
SeriesModelv4,
)
from qBitrr.config import (
APPDATA_FOLDER,
Expand Down Expand Up @@ -486,7 +487,7 @@ def __init__(

self.search_setup_completed = False
self.model_arr_file: EpisodesModel | MoviesModel | MoviesModelv5 = None
self.model_arr_series_file: SeriesModel = None
self.model_arr_series_file: SeriesModel | SeriesModelv4 = None
self.model_arr_movies_file: MoviesMetadataModel = None

self.model_arr_command: CommandsModel = None
Expand Down Expand Up @@ -562,10 +563,13 @@ def _get_arr_modes(
) -> tuple[
type[EpisodesModel] | type[MoviesModel] | type[MoviesModelv5],
type[CommandsModel],
type[SeriesModel] | type[MoviesMetadataModel],
type[SeriesModel | SeriesModelv4] | type[MoviesMetadataModel],
]: # sourcery skip: replace-interpolation-with-fstring, switch
if self.type == "sonarr":
return EpisodesModel, CommandsModel, SeriesModel
if self.version.major == 3:
return EpisodesModel, CommandsModel, SeriesModel
elif self.version.major == 4:
return EpisodesModel, CommandsModel, SeriesModelv4
elif self.type == "radarr":
if self.version.major == 4:
return MoviesModel, CommandsModel, MoviesMetadataModel
Expand Down Expand Up @@ -1378,7 +1382,10 @@ def _db_request_update(self, request_ids: dict[str, set[int | str]]):
try:
if self.type == "sonarr" and any(i in request_ids for i in ["ImdbId", "TvdbId"]):
self.model_arr_file: EpisodesModel
self.model_arr_series_file: SeriesModel
if self.version.major == 3:
self.model_arr_series_file: SeriesModel
elif self.version.major == 4:
self.model_arr_series_file: SeriesModelv4
condition = self.model_arr_file.AirDateUtc.is_null(False)
if not self.search_specials:
condition &= self.model_arr_file.SeasonNumber != 0
Expand Down Expand Up @@ -1546,7 +1553,10 @@ def db_update(self):
):
self.db_update_single_series(db_entry=series)
else:
self.model_arr_series_file: SeriesModel
if self.version.major == 3:
self.model_arr_series_file: SeriesModel
elif self.version.major == 4:
self.model_arr_series_file: SeriesModelv4
for series in (
self.model_arr_series_file.select()
.order_by(self.model_arr_series_file.Added.desc())
Expand Down Expand Up @@ -1831,7 +1841,7 @@ def minimum_availability_check(

def db_update_single_series(
self,
db_entry: EpisodesModel | SeriesModel | MoviesModel | MoviesModelv5 = None,
db_entry: EpisodesModel | SeriesModel | SeriesModelv4 | MoviesModel | MoviesModelv5 = None,
request: bool = False,
series: bool = False,
):
Expand Down Expand Up @@ -1937,7 +1947,10 @@ def db_update_single_series(
else:
return
else:
db_entry: SeriesModel
if self.version.major == 3:
db_entry: SeriesModel
elif self.version.major == 4:
db_entry: SeriesModelv4
self.series_file_model: SeriesFilesModel
EntryId = db_entry.Id
if db_entry.Monitored == 1:
Expand Down

0 comments on commit 7156cd1

Please sign in to comment.