feat(cli): Support for deleting a series from Sonarr

This commit is contained in:
2024-11-23 12:47:22 -07:00
parent cac54c5447
commit c8a2fea9cd
2 changed files with 121 additions and 1 deletions
+26
View File
@@ -7,6 +7,7 @@ use tokio::sync::Mutex;
use crate::{
app::App,
cli::{CliCommandHandler, Command},
models::sonarr_models::DeleteSeriesParams,
network::{sonarr_network::SonarrEvent, NetworkTrait},
};
@@ -42,6 +43,15 @@ pub enum SonarrDeleteCommand {
#[arg(long, help = "The ID of the root folder to delete", required = true)]
root_folder_id: i64,
},
#[command(about = "Delete a series from your Sonarr library")]
Series {
#[arg(long, help = "The ID of the series to delete", required = true)]
series_id: i64,
#[arg(long, help = "Delete the series files from disk as well")]
delete_files_from_disk: bool,
#[arg(long, help = "Add a list exclusion for this series")]
add_list_exclusion: bool,
},
#[command(about = "Delete the tag with the specified ID")]
Tag {
#[arg(long, help = "The ID of the tag to delete", required = true)]
@@ -104,6 +114,22 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, SonarrDeleteCommand> for SonarrDeleteComm
.await?;
serde_json::to_string_pretty(&resp)?
}
SonarrDeleteCommand::Series {
series_id,
delete_files_from_disk,
add_list_exclusion,
} => {
let delete_series_params = DeleteSeriesParams {
id: series_id,
delete_series_files: delete_files_from_disk,
add_list_exclusion,
};
let resp = self
.network
.handle_network_event(SonarrEvent::DeleteSeries(Some(delete_series_params)).into())
.await?;
serde_json::to_string_pretty(&resp)?
}
SonarrDeleteCommand::Tag { tag_id } => {
let resp = self
.network