feat(network): Added support for fetching season releases for Sonarr
This commit is contained in:
@@ -9,7 +9,10 @@ use strum_macros::EnumIter;
|
||||
|
||||
use crate::{models::HorizontallyScrollableText, serde_enum_from};
|
||||
|
||||
use super::servarr_models::{HostConfig, Indexer, QueueEvent, SecurityConfig};
|
||||
use super::servarr_models::{
|
||||
HostConfig, Indexer, Language, LogResponse, QualityProfile, QualityWrapper, QueueEvent, Release,
|
||||
SecurityConfig,
|
||||
};
|
||||
use super::Serdeable;
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -262,28 +265,6 @@ pub struct IndexerValidationFailure {
|
||||
pub severity: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq, Eq, Ord, PartialOrd)]
|
||||
pub struct Language {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Log {
|
||||
pub time: DateTime<Utc>,
|
||||
pub exception: Option<String>,
|
||||
pub exception_type: Option<String>,
|
||||
pub level: String,
|
||||
pub logger: Option<String>,
|
||||
pub message: Option<String>,
|
||||
pub method: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Serialize, Deserialize, Debug, Eq, PartialEq)]
|
||||
pub struct LogResponse {
|
||||
pub records: Vec<Log>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Derivative, Debug, Clone, PartialEq, Eq)]
|
||||
#[derivative(Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@@ -436,32 +417,6 @@ pub struct MovieHistoryItem {
|
||||
pub event_type: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq, Eq, Ord, PartialOrd)]
|
||||
pub struct Quality {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
pub struct QualityProfile {
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl From<(&i64, &String)> for QualityProfile {
|
||||
fn from(value: (&i64, &String)) -> Self {
|
||||
QualityProfile {
|
||||
id: *value.0,
|
||||
name: value.1.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq, Eq, Ord, PartialOrd)]
|
||||
pub struct QualityWrapper {
|
||||
pub quality: Quality,
|
||||
}
|
||||
|
||||
#[derive(Derivative, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
#[derivative(Default)]
|
||||
pub struct Rating {
|
||||
@@ -477,28 +432,6 @@ pub struct RatingsList {
|
||||
pub rotten_tomatoes: Option<Rating>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(default)]
|
||||
pub struct Release {
|
||||
pub guid: String,
|
||||
pub protocol: String,
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub age: i64,
|
||||
pub title: HorizontallyScrollableText,
|
||||
pub indexer: String,
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub indexer_id: i64,
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub size: i64,
|
||||
pub rejected: bool,
|
||||
pub rejections: Option<Vec<String>>,
|
||||
pub seeders: Option<Number>,
|
||||
pub leechers: Option<Number>,
|
||||
pub languages: Option<Vec<Language>>,
|
||||
pub quality: QualityWrapper,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Debug, PartialEq, Eq, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ReleaseDownloadBody {
|
||||
|
||||
@@ -6,11 +6,11 @@ mod tests {
|
||||
use crate::models::{
|
||||
radarr_models::{
|
||||
AddMovieSearchResult, BlocklistItem, BlocklistResponse, Collection, Credit, DiskSpace,
|
||||
DownloadRecord, DownloadsResponse, Indexer, IndexerSettings, IndexerTestResult, Log,
|
||||
LogResponse, MinimumAvailability, Monitor, Movie, MovieHistoryItem, QualityProfile,
|
||||
RadarrSerdeable, Release, RootFolder, SystemStatus, Tag, Task, TaskName, Update,
|
||||
DownloadRecord, DownloadsResponse, Indexer, IndexerSettings, IndexerTestResult,
|
||||
MinimumAvailability, Monitor, Movie, MovieHistoryItem, QualityProfile, RadarrSerdeable,
|
||||
Release, RootFolder, SystemStatus, Tag, Task, TaskName, Update,
|
||||
},
|
||||
servarr_models::{HostConfig, QueueEvent, SecurityConfig},
|
||||
servarr_models::{HostConfig, Log, LogResponse, QueueEvent, SecurityConfig},
|
||||
Serdeable,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::models::radarr_models::{
|
||||
Collection, Credit, MinimumAvailability, Monitor, Movie, MovieHistoryItem, Release, RootFolder,
|
||||
Collection, Credit, MinimumAvailability, Monitor, Movie, MovieHistoryItem, RootFolder,
|
||||
};
|
||||
use crate::models::servarr_data::radarr::radarr_data::RadarrData;
|
||||
use crate::models::servarr_models::Indexer;
|
||||
use crate::models::servarr_models::{Indexer, Release};
|
||||
use crate::models::stateful_list::StatefulList;
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::models::{HorizontallyScrollableText, ScrollableText};
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#[cfg(test)]
|
||||
pub mod utils {
|
||||
use crate::models::radarr_models::{
|
||||
AddMovieSearchResult, CollectionMovie, Credit, MovieHistoryItem, Release,
|
||||
AddMovieSearchResult, CollectionMovie, Credit, MovieHistoryItem,
|
||||
};
|
||||
use crate::models::servarr_data::radarr::modals::MovieDetailsModal;
|
||||
use crate::models::servarr_data::radarr::radarr_data::RadarrData;
|
||||
use crate::models::servarr_models::Release;
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::models::{HorizontallyScrollableText, ScrollableText};
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use crate::models::ScrollableText;
|
||||
use crate::models::{
|
||||
servarr_models::Release, sonarr_models::Episode, stateful_table::StatefulTable, ScrollableText,
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct EpisodeDetailsModal {
|
||||
@@ -9,5 +11,13 @@ pub struct EpisodeDetailsModal {
|
||||
// pub episode_history: StatefulTable<MovieHistoryItem>,
|
||||
// pub episode_cast: StatefulTable<Credit>,
|
||||
// pub episode_crew: StatefulTable<Credit>,
|
||||
// pub episode_releases: StatefulTable<Release>,
|
||||
pub episode_releases: StatefulTable<Release>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct SeasonDetailsModal {
|
||||
pub season_details: ScrollableText,
|
||||
pub episodes: StatefulTable<Episode>,
|
||||
pub episode_details_modal: Option<EpisodeDetailsModal>,
|
||||
pub season_releases: StatefulTable<Release>,
|
||||
}
|
||||
|
||||
@@ -4,14 +4,13 @@ use strum::EnumIter;
|
||||
|
||||
use crate::models::{
|
||||
servarr_models::{Indexer, QueueEvent},
|
||||
sonarr_models::{BlocklistItem, DownloadRecord, Episode, IndexerSettings, Series},
|
||||
sonarr_models::{BlocklistItem, DownloadRecord, IndexerSettings, Season, Series},
|
||||
stateful_list::StatefulList,
|
||||
stateful_table::StatefulTable,
|
||||
stateful_tree::StatefulTree,
|
||||
HorizontallyScrollableText, Route,
|
||||
};
|
||||
|
||||
use super::modals::EpisodeDetailsModal;
|
||||
use super::modals::SeasonDetailsModal;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "sonarr_data_tests.rs"]
|
||||
@@ -20,14 +19,13 @@ mod sonarr_data_tests;
|
||||
pub struct SonarrData {
|
||||
pub blocklist: StatefulTable<BlocklistItem>,
|
||||
pub downloads: StatefulTable<DownloadRecord>,
|
||||
pub episode_details_modal: Option<EpisodeDetailsModal>,
|
||||
pub episodes_table: StatefulTable<Episode>,
|
||||
pub episodes_tree: StatefulTree<Episode>,
|
||||
pub indexers: StatefulTable<Indexer>,
|
||||
pub indexer_settings: Option<IndexerSettings>,
|
||||
pub logs: StatefulList<HorizontallyScrollableText>,
|
||||
pub quality_profile_map: BiMap<i64, String>,
|
||||
pub queued_events: StatefulTable<QueueEvent>,
|
||||
pub seasons: StatefulTable<Season>,
|
||||
pub season_details_modal: Option<SeasonDetailsModal>,
|
||||
pub series: StatefulTable<Series>,
|
||||
pub start_time: DateTime<Utc>,
|
||||
pub version: String,
|
||||
@@ -38,15 +36,14 @@ impl Default for SonarrData {
|
||||
SonarrData {
|
||||
blocklist: StatefulTable::default(),
|
||||
downloads: StatefulTable::default(),
|
||||
episode_details_modal: None,
|
||||
episodes_table: StatefulTable::default(),
|
||||
episodes_tree: StatefulTree::default(),
|
||||
indexers: StatefulTable::default(),
|
||||
indexer_settings: None,
|
||||
logs: StatefulList::default(),
|
||||
quality_profile_map: BiMap::new(),
|
||||
queued_events: StatefulTable::default(),
|
||||
seasons: StatefulTable::default(),
|
||||
series: StatefulTable::default(),
|
||||
season_details_modal: None,
|
||||
start_time: DateTime::default(),
|
||||
version: String::new(),
|
||||
}
|
||||
@@ -57,9 +54,10 @@ impl Default for SonarrData {
|
||||
pub enum ActiveSonarrBlock {
|
||||
Blocklist,
|
||||
BlocklistSortPrompt,
|
||||
EpisodesExplorer,
|
||||
EpisodesTable,
|
||||
EpisodesTableSortPrompt,
|
||||
Episodes,
|
||||
EpisodesSortPrompt,
|
||||
Seasons,
|
||||
SeasonsSortPrompt,
|
||||
#[default]
|
||||
Series,
|
||||
SeriesSortPrompt,
|
||||
|
||||
@@ -36,14 +36,13 @@ mod tests {
|
||||
|
||||
assert!(sonarr_data.blocklist.is_empty());
|
||||
assert!(sonarr_data.downloads.is_empty());
|
||||
assert!(sonarr_data.episode_details_modal.is_none());
|
||||
assert!(sonarr_data.episodes_table.is_empty());
|
||||
assert!(sonarr_data.episodes_tree.is_empty());
|
||||
assert!(sonarr_data.indexers.is_empty());
|
||||
assert!(sonarr_data.indexer_settings.is_none());
|
||||
assert!(sonarr_data.logs.is_empty());
|
||||
assert!(sonarr_data.quality_profile_map.is_empty());
|
||||
assert!(sonarr_data.queued_events.is_empty());
|
||||
assert!(sonarr_data.seasons.is_empty());
|
||||
assert!(sonarr_data.season_details_modal.is_none());
|
||||
assert!(sonarr_data.series.is_empty());
|
||||
assert_eq!(sonarr_data.start_time, <DateTime<Utc>>::default());
|
||||
assert!(sonarr_data.version.is_empty());
|
||||
|
||||
@@ -114,6 +114,54 @@ pub struct IndexerField {
|
||||
pub value: Option<Value>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Hash, Debug, Clone, PartialEq, Eq, Ord, PartialOrd)]
|
||||
pub struct Language {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Log {
|
||||
pub time: DateTime<Utc>,
|
||||
pub exception: Option<String>,
|
||||
pub exception_type: Option<String>,
|
||||
pub level: String,
|
||||
pub logger: Option<String>,
|
||||
pub message: Option<String>,
|
||||
pub method: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Serialize, Deserialize, Debug, Eq, PartialEq)]
|
||||
pub struct LogResponse {
|
||||
pub records: Vec<Log>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq, Eq, Ord, PartialOrd)]
|
||||
pub struct Quality {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
pub struct QualityProfile {
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl From<(&i64, &String)> for QualityProfile {
|
||||
fn from(value: (&i64, &String)) -> Self {
|
||||
QualityProfile {
|
||||
id: *value.0,
|
||||
name: value.1.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq, Eq, Ord, PartialOrd)]
|
||||
pub struct QualityWrapper {
|
||||
pub quality: Quality,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct QueueEvent {
|
||||
@@ -127,6 +175,28 @@ pub struct QueueEvent {
|
||||
pub duration: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(default)]
|
||||
pub struct Release {
|
||||
pub guid: String,
|
||||
pub protocol: String,
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub age: i64,
|
||||
pub title: HorizontallyScrollableText,
|
||||
pub indexer: String,
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub indexer_id: i64,
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub size: i64,
|
||||
pub rejected: bool,
|
||||
pub rejections: Option<Vec<String>>,
|
||||
pub seeders: Option<Number>,
|
||||
pub leechers: Option<Number>,
|
||||
pub languages: Option<Vec<Language>>,
|
||||
pub quality: QualityWrapper,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SecurityConfig {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use pretty_assertions::assert_str_eq;
|
||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
||||
|
||||
use crate::models::servarr_models::{
|
||||
AuthenticationMethod, AuthenticationRequired, CertificateValidation,
|
||||
AuthenticationMethod, AuthenticationRequired, CertificateValidation, QualityProfile,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -31,4 +31,19 @@ mod tests {
|
||||
);
|
||||
assert_str_eq!(CertificateValidation::Disabled.to_string(), "disabled");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_quality_profile_from_tuple_ref() {
|
||||
let id = 2;
|
||||
let name = "Test".to_owned();
|
||||
let quality_profile_tuple = (&id, &name);
|
||||
let expected_quality_profile = QualityProfile {
|
||||
id: 2,
|
||||
name: "Test".to_owned(),
|
||||
};
|
||||
|
||||
let quality_profile = QualityProfile::from(quality_profile_tuple);
|
||||
|
||||
assert_eq!(expected_quality_profile, quality_profile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,10 @@ use strum::EnumIter;
|
||||
use crate::serde_enum_from;
|
||||
|
||||
use super::{
|
||||
servarr_models::{HostConfig, Indexer, QueueEvent, SecurityConfig},
|
||||
servarr_models::{
|
||||
HostConfig, Indexer, Language, LogResponse, QualityProfile, QualityWrapper, QueueEvent,
|
||||
Release, SecurityConfig,
|
||||
},
|
||||
HorizontallyScrollableText, Serdeable,
|
||||
};
|
||||
|
||||
@@ -121,28 +124,6 @@ pub struct IndexerSettings {
|
||||
pub rss_sync_interval: i64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, Hash, Clone, PartialEq, Eq, Ord, PartialOrd)]
|
||||
pub struct Language {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Log {
|
||||
pub time: DateTime<Utc>,
|
||||
pub exception: Option<String>,
|
||||
pub exception_type: Option<String>,
|
||||
pub level: String,
|
||||
pub logger: Option<String>,
|
||||
pub message: Option<String>,
|
||||
pub method: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Serialize, Deserialize, Debug, Eq, PartialEq)]
|
||||
pub struct LogResponse {
|
||||
pub records: Vec<Log>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Derivative, Hash, Debug, Clone, PartialEq, Eq)]
|
||||
#[derivative(Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@@ -168,23 +149,6 @@ pub struct MediaInfo {
|
||||
pub subtitles: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, Hash, Clone, PartialEq, Eq, Ord, PartialOrd)]
|
||||
pub struct Quality {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, Hash, Clone, PartialEq, Eq, Ord, PartialOrd)]
|
||||
pub struct QualityWrapper {
|
||||
pub quality: Quality,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
pub struct QualityProfile {
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Derivative, Serialize, Deserialize, Debug, Clone, PartialEq)]
|
||||
#[derivative(Default)]
|
||||
pub struct Rating {
|
||||
@@ -353,6 +317,7 @@ pub enum SonarrSerdeable {
|
||||
Indexers(Vec<Indexer>),
|
||||
QualityProfiles(Vec<QualityProfile>),
|
||||
QueueEvents(Vec<QueueEvent>),
|
||||
Releases(Vec<Release>),
|
||||
SecurityConfig(SecurityConfig),
|
||||
SeriesVec(Vec<Series>),
|
||||
SystemStatus(SystemStatus),
|
||||
@@ -383,6 +348,7 @@ serde_enum_from!(
|
||||
Indexers(Vec<Indexer>),
|
||||
QualityProfiles(Vec<QualityProfile>),
|
||||
QueueEvents(Vec<QueueEvent>),
|
||||
Releases(Vec<Release>),
|
||||
SecurityConfig(SecurityConfig),
|
||||
SeriesVec(Vec<Series>),
|
||||
SystemStatus(SystemStatus),
|
||||
|
||||
@@ -4,11 +4,12 @@ mod tests {
|
||||
use serde_json::json;
|
||||
|
||||
use crate::models::{
|
||||
servarr_models::{HostConfig, Indexer, QueueEvent, SecurityConfig},
|
||||
servarr_models::{
|
||||
HostConfig, Indexer, Log, LogResponse, QualityProfile, QueueEvent, Release, SecurityConfig,
|
||||
},
|
||||
sonarr_models::{
|
||||
BlocklistItem, BlocklistResponse, DownloadRecord, DownloadsResponse, Episode,
|
||||
IndexerSettings, Log, LogResponse, QualityProfile, Series, SeriesStatus, SeriesType,
|
||||
SonarrSerdeable, SystemStatus,
|
||||
IndexerSettings, Series, SeriesStatus, SeriesType, SonarrSerdeable, SystemStatus,
|
||||
},
|
||||
Serdeable,
|
||||
};
|
||||
@@ -243,6 +244,18 @@ mod tests {
|
||||
assert_eq!(sonarr_serdeable, SonarrSerdeable::QueueEvents(queue_events));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sonarr_serdeable_from_releases() {
|
||||
let releases = vec![Release {
|
||||
size: 1,
|
||||
..Release::default()
|
||||
}];
|
||||
|
||||
let sonarr_serdeable: SonarrSerdeable = releases.clone().into();
|
||||
|
||||
assert_eq!(sonarr_serdeable, SonarrSerdeable::Releases(releases));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sonarr_serdeable_from_security_config() {
|
||||
let security_config = SecurityConfig {
|
||||
|
||||
Reference in New Issue
Block a user