feat(readarr): add authors to Readarr and expose the command on the CLI

This commit is contained in:
Dark-Alex-17 committed 2026-08-26 17:17:41 -06:00
1 parent 9238c1b9d2
commit e514e9b6cc
8 files changed
+644 -9

No files matched your search

+93 -1
View File
@@ -8,7 +8,9 @@ use super::ReadarrCommand;
use crate::{
app::App,
cli::{CliCommandHandler, Command},
models::readarr_models::{AddReadarrRootFolderBody, MonitorType, NewItemMonitorType},
models::readarr_models::{
AddAuthorBody, AddAuthorOptions, AddReadarrRootFolderBody, MonitorType, NewItemMonitorType,
},
network::{NetworkTrait, readarr_network::ReadarrEvent},
};
@@ -18,6 +20,63 @@ mod add_command_handler_tests;
#[derive(Debug, Clone, PartialEq, Eq, Subcommand)]
pub enum ReadarrAddCommand {
#[command(about = "Add a new author to your Readarr library")]
Author {
#[arg(
long,
help = "The Goodreads foreign author ID of the author you wish to add to your library",
required = true
)]
foreign_author_id: String,
#[arg(long, help = "The name of the author", required = true)]
author_name: String,
#[arg(
long,
help = "The root folder path where all author data and metadata should live",
required = true
)]
root_folder_path: String,
#[arg(
long,
help = "The ID of the quality profile to use for this author",
required = true
)]
quality_profile_id: i64,
#[arg(
long,
help = "The ID of the metadata profile to use for this author",
required = true
)]
metadata_profile_id: i64,
#[arg(long, help = "Disable monitoring for this author")]
disable_monitoring: bool,
#[arg(
long,
help = "Tag IDs to tag the author with",
value_parser,
action = ArgAction::Append
)]
tag: Vec<i64>,
#[arg(
long,
help = "What Readarr should monitor for this author",
value_enum,
default_value_t = MonitorType::default()
)]
monitor: MonitorType,
#[arg(
long,
help = "How Readarr should monitor new items for this author",
value_enum,
default_value_t = NewItemMonitorType::default()
)]
monitor_new_items: NewItemMonitorType,
#[arg(
long,
help = "Tell Readarr to not start a search for missing books once the author is added to your library"
)]
no_search_for_missing_books: bool,
},
#[command(about = "Add a new root folder")]
RootFolder {
#[arg(long, help = "The name of the root folder", required = true)]
@@ -92,6 +151,39 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, ReadarrAddCommand> for ReadarrAddCommandH
async fn handle(self) -> Result<String> {
let result = match self.command {
ReadarrAddCommand::Author {
foreign_author_id,
author_name,
root_folder_path,
quality_profile_id,
metadata_profile_id,
disable_monitoring,
tag: tags,
monitor,
monitor_new_items,
no_search_for_missing_books,
} => {
let body = AddAuthorBody {
foreign_author_id,
author_name,
monitored: !disable_monitoring,
root_folder_path,
quality_profile_id,
metadata_profile_id,
tags,
tag_input_string: None,
add_options: AddAuthorOptions {
monitor,
monitor_new_items,
search_for_missing_books: !no_search_for_missing_books,
},
};
let resp = self
.network
.handle_network_event(ReadarrEvent::AddAuthor(body).into())
.await?;
serde_json::to_string_pretty(&resp)?
}
ReadarrAddCommand::RootFolder {
name,
root_folder_path,