1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
|
"""Sonarr Models."""
# pylint: disable=invalid-name, too-many-instance-attributes
from __future__ import annotations
from dataclasses import dataclass, field
from datetime import datetime
from enum import Enum
from ..const import DATE, EPISODE_ID, PATH, SERIES_ID
from .base import BaseModel
from .request_common import (
_Common2,
_Common3,
_Common4,
_Common7,
_Common8,
_Fields,
_ImportListCommon,
_ManualImport,
_Monitor,
_MonitorOption,
_Notification,
_Quality,
_QualityCommon,
_RecordCommon,
_ReleaseCommon,
_Rename,
_StatusMessage,
_TagDetails,
)
from .sonarr_common import (
_SonarrAddOptions,
_SonarrCommon,
_SonarrCommon2,
_SonarrEpisodeFile,
_SonarrEpisodeHistoryData,
_SonarrEpisodeMonitor,
_SonarrLanguageItem,
_SonarrParseEpisodeInfo,
_SonarrSeries2,
_SonarrSeriesAlternateTitle,
_SonarrSeriesCommon,
_SonarrWantedMissingRecord,
)
class SonarrCommands(str, Enum):
"""Sonarr commands."""
DOWNLOADED_EPISODES_SCAN = "DownloadedEpisodesScan"
EPISODE_SEARCH = "EpisodeSearch"
REFRESH_SERIES = "RefreshSeries"
RENAME_SERIES = "RenameSeries"
RESCAN_SERIES = "RescanSeries"
SEASON_SEARCH = "SeasonSearch"
SERIES_SEARCH = "SeriesSearch"
class SonarrEventType(Enum):
"""Sonarr event types."""
DELETED = 5
FAILED = 4
GRABBED = 1
IGNORED = 7
IMPORTED = 3
RENAMED = 6
class SonarrSortKeys(str, Enum):
"""Sonarr sort keys."""
AIR_DATE_UTC = "airDateUtc"
DATE = DATE
DOWNLOAD_CLIENT = "downloadClient"
EPISODE = "episode"
EPISODE_ID = EPISODE_ID
EPISODE_TITLE = "episode.title"
ID = "id"
INDEXER = "indexer"
LANGUAGE = "language"
MESSAGE = "message"
PATH = PATH
PROGRESS = "progress"
PROTOCOL = "protocol"
QUALITY = "quality"
RATINGS = "ratings"
SERIES_ID = SERIES_ID
SERIES_TITLE = "series.sortTitle"
SIZE = "size"
SOURCE_TITLE = "sourcetitle"
STATUS = "status"
TIMELEFT = "timeleft"
@dataclass(init=False)
class SonarrCalendar(_SonarrWantedMissingRecord, _SonarrCommon2):
"""Sonarr calendar attributes."""
@dataclass(init=False)
class SonarrEpisode(_SonarrCommon):
"""Sonarr episode attributes."""
series: type[_SonarrSeriesCommon] = field(default=_SonarrSeriesCommon)
def __post_init__(self):
"""Post init."""
super().__post_init__()
self.series = _SonarrSeriesCommon(self.series)
@dataclass(init=False)
class SonarrEpisodeFile(_SonarrEpisodeFile):
"""Sonarr episode file attributes."""
@dataclass(init=False)
class SonarrEpisodeHistory(_Common2, _QualityCommon):
"""Sonarr history record attributes."""
data: type[_SonarrEpisodeHistoryData] = field(default=_SonarrEpisodeHistoryData)
date: datetime
episodeId: int
id: int
language: type[_Common3] = field(default=_Common3)
languageCutoffNotMet: bool
seriesId: int
sourceTitle: str
def __post_init__(self):
"""Post init."""
super().__post_init__()
self.data = _SonarrEpisodeHistoryData(self.data)
self.language = _Common3(self.language)
@dataclass(init=False)
class SonarrHistory(_RecordCommon):
"""Sonarr history attributes."""
records: list[SonarrEpisodeHistory] = field(
default_factory=list[SonarrEpisodeHistory]
)
def __post_init__(self):
"""Post init."""
self.records = [SonarrEpisodeHistory(record) for record in self.records]
@dataclass(init=False)
class SonarrWantedMissing(_RecordCommon):
"""Sonarr wanted missing attributes."""
records: list[_SonarrWantedMissingRecord] = field(
default_factory=list[_SonarrWantedMissingRecord]
)
def __post_init__(self):
"""Post init."""
self.records = [_SonarrWantedMissingRecord(record) for record in self.records]
@dataclass(init=False)
class SonarrQueueDetail(_Common4, _Common8):
"""Sonarr queue detail attributes."""
episode: type[_SonarrCommon] = field(default=_SonarrCommon)
episodeId: int
language: type[_Common3] = field(default=_Common3)
series: type[_SonarrSeries2] = field(default=_SonarrSeries2)
seriesId: int
def __post_init__(self):
"""Post init."""
super().__post_init__()
self.quality = _Quality(self.quality)
self.episode = _SonarrCommon(self.episode)
self.language = _Common3(self.language)
self.series = _SonarrSeries2(self.series)
self.statusMessages = [_StatusMessage(x) for x in self.statusMessages or []]
@dataclass(init=False)
class SonarrQueue(_RecordCommon):
"""Sonarr queue attributes."""
records: list[SonarrQueueDetail] = field(default_factory=list[SonarrQueueDetail])
def __post_init__(self):
"""Post init."""
super().__post_init__()
self.records = [SonarrQueueDetail(record) for record in self.records]
@dataclass(init=False)
class SonarrParse(BaseModel):
"""Sonarr parse attributes."""
episodes: list[SonarrEpisode] | None = None
parsedEpisodeInfo: type[_SonarrParseEpisodeInfo] = field(
default=_SonarrParseEpisodeInfo
)
series: type[_SonarrSeries2] = field(default=_SonarrSeries2)
title: str
def __post_init__(self):
"""Post init."""
self.episodes = [SonarrEpisode(episode) for episode in self.episodes or []]
self.parsedEpisodeInfo = _SonarrParseEpisodeInfo(self.parsedEpisodeInfo)
self.series = _SonarrSeries2(self.series)
@dataclass(init=False)
class _SonarrSceneMapping(BaseModel):
"""Sonarr scene mapping attributes."""
title: str
seasonNumber: int
@dataclass(init=False)
class SonarrRelease(_ReleaseCommon):
"""Sonarr release attributes."""
absoluteEpisodeNumbers: list[int]
episodeNumbers: list[int]
episodeRequested: bool
fullSeason: bool
isAbsoluteNumbering: bool
isDaily: bool
isPossibleSpecialEpisode: bool
language: type[_Common3] = field(default=_Common3)
languageWeight: int
mappedAbsoluteEpisodeNumbers: list[int]
mappedEpisodeNumbers: list[int]
mappedSeasonNumber: int
preferredWordScore: int
quality: type[_Quality] = field(default=_Quality)
rejected: bool
releaseGroup: str
releaseHash: str
releaseWeight: int
sceneMapping: type[_SonarrSceneMapping] = field(default=_SonarrSceneMapping)
seasonNumber: int
seriesTitle: str
special: bool
tvdbId: int
tvRageId: int
def __post_init__(self):
"""Post init."""
super().__post_init__()
self.language = _Common3(self.language)
self.quality = _Quality(self.quality)
self.sceneMapping = _SonarrSceneMapping(self.sceneMapping)
@dataclass(init=False)
class SonarrSeries(_SonarrSeriesCommon):
"""Sonarr series attributes."""
alternateTitles: list[_SonarrSeriesAlternateTitle] | None = None
rootFolderPath: str
previousAiring: str
def __post_init__(self):
"""Post init."""
super().__post_init__()
self.alternateTitles = [
_SonarrSeriesAlternateTitle(altTit) for altTit in self.alternateTitles or []
]
@dataclass(init=False)
class SonarrSeriesAdd(SonarrSeries):
"""Sonarr series add attributes."""
addOptions: type[_SonarrAddOptions] = field(default=_SonarrAddOptions)
def __post_init__(self):
"""Post init."""
super().__post_init__()
self.addOptions = _SonarrAddOptions(self.addOptions)
@dataclass(init=False)
class SonarrSeriesLookup(_SonarrSeriesCommon):
"""Sonarr series lookup attributes."""
@dataclass(init=False)
class SonarrBlocklistSeries(_Common7):
"""Sonarr blocklist series attributes."""
date: datetime
episodeIds: list[int]
language: type[_Common3] = field(default=_Common3)
message: str
quality: type[_Quality] = field(default=_Quality)
seriesId: int
sourceTitle: str
def __post_init__(self):
"""Post init."""
super().__post_init__()
self.language = _Common3(self.language)
self.quality = _Quality(self.quality)
@dataclass(init=False)
class SonarrBlocklist(_RecordCommon):
"""Sonarr blocklist attributes."""
records: list[SonarrBlocklistSeries] = field(
default_factory=list[SonarrBlocklistSeries]
)
def __post_init__(self):
"""Post init."""
self.records = [SonarrBlocklistSeries(record) for record in self.records]
@dataclass(init=False)
class SonarrNamingConfig(BaseModel):
"""Sonarr naming config attributes."""
animeEpisodeFormat: str
dailyEpisodeFormat: str
id: int
includeEpisodeTitle: bool
includeQuality: bool
includeSeriesTitle: bool
multiEpisodeStyle: int
numberStyle: str
renameEpisodes: bool
replaceIllegalCharacters: bool
replaceSpaces: bool
seasonFolderFormat: str
separator: str
seriesFolderFormat: str
specialsFolderFormat: str
standardEpisodeFormat: str
@dataclass(init=False)
class SonarrNotification(_Common3, _Notification):
"""Sonarr notification attributes."""
fields: list[_Fields] | None = None
onEpisodeFileDelete: bool
onEpisodeFileDeleteForUpgrade: bool
onSeriesDelete: bool
supportsOnEpisodeFileDelete: bool
supportsOnEpisodeFileDeleteForUpgrade: bool
supportsOnSeriesDelete: bool
def __post_init__(self):
"""Post init."""
self.fields = [_Fields(field) for field in self.fields or []]
@dataclass(init=False)
class SonarrRename(_Rename):
"""Sonarr rename attributes."""
episodeFileId: int
episodeNumbers: list[int]
seasonNumber: int
seriesId: int
@dataclass(init=False)
class SonarrTagDetails(_TagDetails):
"""Sonarr tag details attributes."""
indexerIds: list[int]
seriesIds: list[int]
@dataclass(init=False)
class SonarrImportList(_ImportListCommon, _Common3):
"""Sonarr importlist attributes."""
enableAutomaticAdd: bool
fields: list[_Fields] | None = None
implementation: str
implementationName: str
infoLink: str
languageProfileId: int
listType: str
qualityProfileId: int
seasonFolder: bool
seriesType: str
shouldMonitor: str
tags: list[int]
def __post_init__(self):
"""Post init."""
self.fields = [_Fields(field) for field in self.fields or []]
@dataclass(init=False)
class SonarrManualImport(_ManualImport):
"""Sonarr manual import attributes."""
episodes: list[SonarrEpisodeMonitor] | None = None
folderName: str
language: type[_Common3] = field(default=_Common3)
relativePath: str
seasonNumber: int
series: type[_SonarrSeries2] = field(default=_SonarrSeries2)
def __post_init__(self):
"""Post init."""
super().__post_init__()
self.episodes = [
SonarrEpisodeMonitor(episode) for episode in self.episodes or []
]
self.language = _Common3(self.language)
self.series = _SonarrSeries2(self.series)
@dataclass(init=False)
class SonarrSeasonPass(BaseModel):
"""Sonarr season pass attributes."""
monitoringOptions: type[_MonitorOption] = field(default=_MonitorOption)
series: list[_Monitor] | None = None
def __post_init__(self):
"""Post init."""
super().__post_init__()
self.monitoringOptions = _MonitorOption(self.monitoringOptions)
self.series = [_Monitor(x) for x in self.series or []]
@dataclass(init=False)
class SonarrLanguage(BaseModel):
"""Sonarr launguage attributes."""
cutoff: type[_Common3] = field(default=_Common3)
id: int
languages: list[_SonarrLanguageItem] | None = None
name: str
upgradeAllowed: bool
def __post_init__(self):
"""Post init."""
super().__post_init__()
self.cutoff = _Common3(self.cutoff)
self.languages = [_SonarrLanguageItem(x) for x in self.languages or []]
@dataclass(init=False)
class SonarrEpisodeMonitor(_SonarrEpisodeMonitor):
"""Sonarr episode monitor attributes."""
|