feat(cli): Support for editing a sonarr series

This commit is contained in:
2024-11-25 16:19:48 -07:00
parent 3af22cceac
commit ee312a21eb
2 changed files with 493 additions and 3 deletions
+111 -1
View File
@@ -9,7 +9,7 @@ use crate::{
cli::{mutex_flags_or_option, CliCommandHandler, Command},
models::{
servarr_models::EditIndexerParams,
sonarr_models::{IndexerSettings, SonarrSerdeable},
sonarr_models::{EditSeriesParams, IndexerSettings, SeriesType, SonarrSerdeable},
Serdeable,
},
network::{sonarr_network::SonarrEvent, NetworkTrait},
@@ -148,6 +148,82 @@ pub enum SonarrEditCommand {
#[arg(long, help = "Clear all tags on this indexer", conflicts_with = "tag")]
clear_tags: bool,
},
#[command(
about = "Edit preferences for the specified series",
group(
ArgGroup::new("edit_series")
.args([
"enable_monitoring",
"disable_monitoring",
"enable_season_folders",
"disable_season_folders",
"series_type",
"quality_profile_id",
"language_profile_id",
"root_folder_path",
"tag",
"clear_tags"
]).required(true)
.multiple(true))
)]
Series {
#[arg(
long,
help = "The ID of the series whose settings you want to edit",
required = true
)]
series_id: i64,
#[arg(
long,
help = "Enable monitoring of this series in Sonarr so Sonarr will automatically download this series if it is available",
conflicts_with = "disable_monitoring"
)]
enable_monitoring: bool,
#[arg(
long,
help = "Disable monitoring of this series so Sonarr does not automatically download the series if it is found to be available",
conflicts_with = "enable_monitoring"
)]
disable_monitoring: bool,
#[arg(
long,
help = "The minimum availability to monitor for this film",
value_enum
)]
#[arg(
long,
help = "Enable sorting episodes of this series into season folders",
conflicts_with = "disable_season_folders"
)]
enable_season_folders: bool,
#[arg(
long,
help = "Disable sorting episodes of this series into season folders",
conflicts_with = "enable_season_folders"
)]
disable_season_folders: bool,
#[arg(long, help = "The type of series", value_enum)]
series_type: Option<SeriesType>,
#[arg(long, help = "The ID of the quality profile to use for this series")]
quality_profile_id: Option<i64>,
#[arg(long, help = "The ID of the language profile to use for this series")]
language_profile_id: Option<i64>,
#[arg(
long,
help = "The root folder path where all film data and metadata should live"
)]
root_folder_path: Option<String>,
#[arg(
long,
help = "Tag IDs to tag this series with",
value_parser,
action = ArgAction::Append,
conflicts_with = "clear_tags"
)]
tag: Option<Vec<i64>>,
#[arg(long, help = "Clear all tags on this series", conflicts_with = "tag")]
clear_tags: bool,
},
}
impl From<SonarrEditCommand> for Command {
@@ -246,6 +322,40 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, SonarrEditCommand> for SonarrEditCommandH
.await?;
"Indexer updated".to_owned()
}
SonarrEditCommand::Series {
series_id,
enable_monitoring,
disable_monitoring,
enable_season_folders,
disable_season_folders,
series_type,
quality_profile_id,
language_profile_id,
root_folder_path,
tag,
clear_tags,
} => {
let monitored_value = mutex_flags_or_option(enable_monitoring, disable_monitoring);
let season_folders_value =
mutex_flags_or_option(enable_season_folders, disable_season_folders);
let edit_series_params = EditSeriesParams {
series_id,
monitored: monitored_value,
use_season_folders: season_folders_value,
series_type,
quality_profile_id,
language_profile_id,
root_folder_path,
tags: tag,
clear_tags,
};
self
.network
.handle_network_event(SonarrEvent::EditSeries(Some(edit_series_params)).into())
.await?;
"Series Updated".to_owned()
}
};
Ok(result)