feat(network): Support for fetching all episode files for a given series
This commit is contained in:
@@ -19,7 +19,7 @@ use crate::{
|
||||
HorizontallyScrollableText, ScrollableText, TabRoute, TabState,
|
||||
},
|
||||
};
|
||||
|
||||
use crate::models::sonarr_models::EpisodeFile;
|
||||
use super::sonarr_data::{ActiveSonarrBlock, SonarrData};
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -310,6 +310,7 @@ impl Default for EpisodeDetailsModal {
|
||||
|
||||
pub struct SeasonDetailsModal {
|
||||
pub episodes: StatefulTable<Episode>,
|
||||
pub episode_files: StatefulTable<EpisodeFile>,
|
||||
pub episode_details_modal: Option<EpisodeDetailsModal>,
|
||||
pub season_history: StatefulTable<SonarrHistoryItem>,
|
||||
pub season_releases: StatefulTable<SonarrRelease>,
|
||||
@@ -321,6 +322,7 @@ impl Default for SeasonDetailsModal {
|
||||
SeasonDetailsModal {
|
||||
episodes: StatefulTable::default(),
|
||||
episode_details_modal: None,
|
||||
episode_files: StatefulTable::default(),
|
||||
season_releases: StatefulTable::default(),
|
||||
season_history: StatefulTable::default(),
|
||||
season_details_tabs: TabState::new(vec![
|
||||
|
||||
@@ -322,6 +322,7 @@ mod tests {
|
||||
|
||||
assert!(season_details_modal.episodes.is_empty());
|
||||
assert!(season_details_modal.episode_details_modal.is_none());
|
||||
assert!(season_details_modal.episode_files.is_empty());
|
||||
assert!(season_details_modal.season_releases.is_empty());
|
||||
assert!(season_details_modal.season_history.is_empty());
|
||||
|
||||
|
||||
@@ -176,11 +176,14 @@ impl Display for Episode {
|
||||
#[derive(Default, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EpisodeFile {
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub id: i64,
|
||||
pub relative_path: String,
|
||||
pub path: String,
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub size: i64,
|
||||
pub language: Language,
|
||||
pub quality: QualityWrapper,
|
||||
pub date_added: DateTime<Utc>,
|
||||
pub media_info: Option<MediaInfo>,
|
||||
}
|
||||
@@ -626,6 +629,7 @@ pub enum SonarrSerdeable {
|
||||
DiskSpaces(Vec<DiskSpace>),
|
||||
Episode(Episode),
|
||||
Episodes(Vec<Episode>),
|
||||
EpisodeFiles(Vec<EpisodeFile>),
|
||||
HostConfig(HostConfig),
|
||||
IndexerSettings(IndexerSettings),
|
||||
Indexers(Vec<Indexer>),
|
||||
@@ -669,6 +673,7 @@ serde_enum_from!(
|
||||
DiskSpaces(Vec<DiskSpace>),
|
||||
Episode(Episode),
|
||||
Episodes(Vec<Episode>),
|
||||
EpisodeFiles(Vec<EpisodeFile>),
|
||||
HostConfig(HostConfig),
|
||||
IndexerSettings(IndexerSettings),
|
||||
Indexers(Vec<Indexer>),
|
||||
|
||||
@@ -11,7 +11,7 @@ mod tests {
|
||||
},
|
||||
sonarr_models::{
|
||||
AddSeriesSearchResult, BlocklistItem, BlocklistResponse, DownloadRecord, DownloadsResponse,
|
||||
Episode, IndexerSettings, Series, SeriesMonitor, SeriesStatus, SeriesType,
|
||||
Episode, EpisodeFile, IndexerSettings, Series, SeriesMonitor, SeriesStatus, SeriesType,
|
||||
SonarrHistoryEventType, SonarrHistoryItem, SonarrRelease, SonarrSerdeable, SonarrTask,
|
||||
SonarrTaskName, SystemStatus,
|
||||
},
|
||||
@@ -236,6 +236,21 @@ mod tests {
|
||||
assert_eq!(sonarr_serdeable, SonarrSerdeable::Episodes(episodes));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sonarr_serdeable_from_episode_files() {
|
||||
let episode_files = vec![EpisodeFile {
|
||||
id: 1,
|
||||
..EpisodeFile::default()
|
||||
}];
|
||||
|
||||
let sonarr_serdeable: SonarrSerdeable = episode_files.clone().into();
|
||||
|
||||
assert_eq!(
|
||||
sonarr_serdeable,
|
||||
SonarrSerdeable::EpisodeFiles(episode_files)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sonarr_serdeable_from_host_config() {
|
||||
let host_config = HostConfig {
|
||||
|
||||
Reference in New Issue
Block a user