feat(network): Support for fetching all Sonarr language profiles
This commit is contained in:
@@ -31,6 +31,7 @@ pub struct SonarrData {
|
||||
pub indexer_settings: Option<IndexerSettings>,
|
||||
pub indexer_test_all_results: Option<StatefulTable<IndexerTestResultModalItem>>,
|
||||
pub indexer_test_error: Option<String>,
|
||||
pub language_profiles_map: BiMap<i64, String>,
|
||||
pub logs: StatefulList<HorizontallyScrollableText>,
|
||||
pub quality_profile_map: BiMap<i64, String>,
|
||||
pub queued_events: StatefulTable<QueueEvent>,
|
||||
@@ -67,6 +68,7 @@ impl Default for SonarrData {
|
||||
indexer_settings: None,
|
||||
indexer_test_error: None,
|
||||
indexer_test_all_results: None,
|
||||
language_profiles_map: BiMap::new(),
|
||||
logs: StatefulList::default(),
|
||||
quality_profile_map: BiMap::new(),
|
||||
queued_events: StatefulTable::default(),
|
||||
|
||||
@@ -59,6 +59,7 @@ mod tests {
|
||||
assert!(sonarr_data.indexer_settings.is_none());
|
||||
assert!(sonarr_data.indexer_test_error.is_none());
|
||||
assert!(sonarr_data.indexer_test_all_results.is_none());
|
||||
assert!(sonarr_data.language_profiles_map.is_empty());
|
||||
assert!(sonarr_data.logs.is_empty());
|
||||
assert!(sonarr_data.quality_profile_map.is_empty());
|
||||
assert!(sonarr_data.queued_events.is_empty());
|
||||
|
||||
@@ -136,6 +136,8 @@ pub struct IndexerField {
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq, Eq, Ord, PartialOrd)]
|
||||
pub struct Language {
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,28 @@ use super::{
|
||||
#[path = "sonarr_models_tests.rs"]
|
||||
mod sonarr_models_tests;
|
||||
|
||||
#[derive(Default, Clone, Serialize, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AddSeriesBody {
|
||||
pub tvdb_id: i64,
|
||||
pub title: String,
|
||||
pub root_folder_path: String,
|
||||
pub quality_profile_id: i64,
|
||||
pub series_type: SeriesType,
|
||||
pub season_folder: bool,
|
||||
pub language_profile_id: i64,
|
||||
pub tags: Vec<i64>,
|
||||
pub add_options: AddSeriesOptions,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Serialize, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AddSeriesOptions {
|
||||
pub monitor: SeriesMonitor,
|
||||
pub search_for_cutoff_unmet_episodes: bool,
|
||||
pub search_for_missing_episodes: bool,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BlocklistItem {
|
||||
@@ -231,6 +253,71 @@ pub struct Series {
|
||||
pub seasons: Option<Vec<Season>>,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Serialize, Deserialize, Default, PartialEq, Eq, Clone, Copy, Debug, EnumIter, ValueEnum,
|
||||
)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum SeriesMonitor {
|
||||
Unknown,
|
||||
#[default]
|
||||
All,
|
||||
Future,
|
||||
Missing,
|
||||
Existing,
|
||||
FirstSeason,
|
||||
LastSeason,
|
||||
LatestSeason,
|
||||
Pilot,
|
||||
Recent,
|
||||
MonitorSpecials,
|
||||
UnmonitorSpecials,
|
||||
None,
|
||||
Skip,
|
||||
}
|
||||
|
||||
impl Display for SeriesMonitor {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
let series_monitor = match self {
|
||||
SeriesMonitor::Unknown => "unknown",
|
||||
SeriesMonitor::All => "all",
|
||||
SeriesMonitor::Future => "future",
|
||||
SeriesMonitor::Missing => "missing",
|
||||
SeriesMonitor::Existing => "existing",
|
||||
SeriesMonitor::FirstSeason => "firstSeason",
|
||||
SeriesMonitor::LastSeason => "lastSeason",
|
||||
SeriesMonitor::LatestSeason => "latestSeason",
|
||||
SeriesMonitor::Pilot => "pilot",
|
||||
SeriesMonitor::Recent => "recent",
|
||||
SeriesMonitor::MonitorSpecials => "monitorSpecials",
|
||||
SeriesMonitor::UnmonitorSpecials => "unmonitorSpecials",
|
||||
SeriesMonitor::None => "none",
|
||||
SeriesMonitor::Skip => "skip",
|
||||
};
|
||||
write!(f, "{series_monitor}")
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> EnumDisplayStyle<'a> for SeriesMonitor {
|
||||
fn to_display_str(self) -> &'a str {
|
||||
match self {
|
||||
SeriesMonitor::Unknown => "Unknown",
|
||||
SeriesMonitor::All => "All Episodes",
|
||||
SeriesMonitor::Future => "Future Episodes",
|
||||
SeriesMonitor::Missing => "Missing Episodes",
|
||||
SeriesMonitor::Existing => "Existing Episodes",
|
||||
SeriesMonitor::FirstSeason => "Only First Season",
|
||||
SeriesMonitor::LastSeason => "Only Last Season",
|
||||
SeriesMonitor::LatestSeason => "Only Latest Season",
|
||||
SeriesMonitor::Pilot => "Pilot Episode",
|
||||
SeriesMonitor::Recent => "Recent Episodes",
|
||||
SeriesMonitor::MonitorSpecials => "Only Specials",
|
||||
SeriesMonitor::UnmonitorSpecials => "Not Specials",
|
||||
SeriesMonitor::None => "None",
|
||||
SeriesMonitor::Skip => "Skip",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Serialize, Deserialize, Default, PartialEq, Eq, Clone, Copy, Debug, EnumIter, ValueEnum,
|
||||
)]
|
||||
@@ -494,6 +581,7 @@ pub enum SonarrSerdeable {
|
||||
IndexerSettings(IndexerSettings),
|
||||
Indexers(Vec<Indexer>),
|
||||
IndexerTestResults(Vec<IndexerTestResult>),
|
||||
LanguageProfiles(Vec<Language>),
|
||||
LogResponse(LogResponse),
|
||||
QualityProfiles(Vec<QualityProfile>),
|
||||
QueueEvents(Vec<QueueEvent>),
|
||||
@@ -535,6 +623,7 @@ serde_enum_from!(
|
||||
IndexerSettings(IndexerSettings),
|
||||
Indexers(Vec<Indexer>),
|
||||
IndexerTestResults(Vec<IndexerTestResult>),
|
||||
LanguageProfiles(Vec<Language>),
|
||||
LogResponse(LogResponse),
|
||||
QualityProfiles(Vec<QualityProfile>),
|
||||
QueueEvents(Vec<QueueEvent>),
|
||||
|
||||
@@ -6,13 +6,13 @@ mod tests {
|
||||
use crate::models::{
|
||||
radarr_models::IndexerTestResult,
|
||||
servarr_models::{
|
||||
DiskSpace, HostConfig, Indexer, Log, LogResponse, QualityProfile, QueueEvent, RootFolder,
|
||||
SecurityConfig, Tag, Update,
|
||||
DiskSpace, HostConfig, Indexer, Language, Log, LogResponse, QualityProfile, QueueEvent,
|
||||
RootFolder, SecurityConfig, Tag, Update,
|
||||
},
|
||||
sonarr_models::{
|
||||
BlocklistItem, BlocklistResponse, DownloadRecord, DownloadsResponse, Episode,
|
||||
IndexerSettings, Series, SeriesStatus, SeriesType, SonarrHistoryEventType, SonarrHistoryItem,
|
||||
SonarrRelease, SonarrSerdeable, SonarrTask, SonarrTaskName, SystemStatus,
|
||||
IndexerSettings, Series, SeriesMonitor, SeriesStatus, SeriesType, SonarrHistoryEventType,
|
||||
SonarrHistoryItem, SonarrRelease, SonarrSerdeable, SonarrTask, SonarrTaskName, SystemStatus,
|
||||
},
|
||||
EnumDisplayStyle, Serdeable,
|
||||
};
|
||||
@@ -28,6 +28,66 @@ mod tests {
|
||||
assert_str_eq!(episode.to_string(), "Test Title");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_series_monitor_display() {
|
||||
assert_str_eq!(SeriesMonitor::Unknown.to_string(), "unknown");
|
||||
assert_str_eq!(SeriesMonitor::All.to_string(), "all");
|
||||
assert_str_eq!(SeriesMonitor::Future.to_string(), "future");
|
||||
assert_str_eq!(SeriesMonitor::Missing.to_string(), "missing");
|
||||
assert_str_eq!(SeriesMonitor::Existing.to_string(), "existing");
|
||||
assert_str_eq!(SeriesMonitor::FirstSeason.to_string(), "firstSeason");
|
||||
assert_str_eq!(SeriesMonitor::LastSeason.to_string(), "lastSeason");
|
||||
assert_str_eq!(SeriesMonitor::LatestSeason.to_string(), "latestSeason");
|
||||
assert_str_eq!(SeriesMonitor::Pilot.to_string(), "pilot");
|
||||
assert_str_eq!(SeriesMonitor::Recent.to_string(), "recent");
|
||||
assert_str_eq!(
|
||||
SeriesMonitor::MonitorSpecials.to_string(),
|
||||
"monitorSpecials"
|
||||
);
|
||||
assert_str_eq!(
|
||||
SeriesMonitor::UnmonitorSpecials.to_string(),
|
||||
"unmonitorSpecials"
|
||||
);
|
||||
assert_str_eq!(SeriesMonitor::None.to_string(), "none");
|
||||
assert_str_eq!(SeriesMonitor::Skip.to_string(), "skip");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_series_monitor_to_display_str() {
|
||||
assert_str_eq!(SeriesMonitor::Unknown.to_display_str(), "Unknown");
|
||||
assert_str_eq!(SeriesMonitor::All.to_display_str(), "All Episodes");
|
||||
assert_str_eq!(SeriesMonitor::Future.to_display_str(), "Future Episodes");
|
||||
assert_str_eq!(SeriesMonitor::Missing.to_display_str(), "Missing Episodes");
|
||||
assert_str_eq!(
|
||||
SeriesMonitor::Existing.to_display_str(),
|
||||
"Existing Episodes"
|
||||
);
|
||||
assert_str_eq!(
|
||||
SeriesMonitor::FirstSeason.to_display_str(),
|
||||
"Only First Season"
|
||||
);
|
||||
assert_str_eq!(
|
||||
SeriesMonitor::LastSeason.to_display_str(),
|
||||
"Only Last Season"
|
||||
);
|
||||
assert_str_eq!(
|
||||
SeriesMonitor::LatestSeason.to_display_str(),
|
||||
"Only Latest Season"
|
||||
);
|
||||
assert_str_eq!(SeriesMonitor::Pilot.to_display_str(), "Pilot Episode");
|
||||
assert_str_eq!(SeriesMonitor::Recent.to_display_str(), "Recent Episodes");
|
||||
assert_str_eq!(
|
||||
SeriesMonitor::MonitorSpecials.to_display_str(),
|
||||
"Only Specials"
|
||||
);
|
||||
assert_str_eq!(
|
||||
SeriesMonitor::UnmonitorSpecials.to_display_str(),
|
||||
"Not Specials"
|
||||
);
|
||||
assert_str_eq!(SeriesMonitor::None.to_display_str(), "None");
|
||||
assert_str_eq!(SeriesMonitor::Skip.to_display_str(), "Skip");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_series_status_display() {
|
||||
assert_str_eq!(SeriesStatus::Continuing.to_string(), "continuing");
|
||||
@@ -312,6 +372,27 @@ mod tests {
|
||||
assert_eq!(sonarr_serdeable, SonarrSerdeable::DiskSpaces(disk_spaces));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sonarr_serdeable_from_language_profiles() {
|
||||
let language_profiles = vec![
|
||||
Language {
|
||||
id: 1,
|
||||
name: "English".to_owned(),
|
||||
},
|
||||
Language {
|
||||
id: 2,
|
||||
name: "Japanese".to_owned(),
|
||||
},
|
||||
];
|
||||
|
||||
let sonarr_serdeable: SonarrSerdeable = language_profiles.clone().into();
|
||||
|
||||
assert_eq!(
|
||||
sonarr_serdeable,
|
||||
SonarrSerdeable::LanguageProfiles(language_profiles)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sonarr_serdeable_from_log_response() {
|
||||
let log_response = LogResponse {
|
||||
|
||||
Reference in New Issue
Block a user