feat: Bulk added CLI support for tracks and album functionalities in Lidarr
This commit is contained in:
@@ -17,6 +17,19 @@ mod manual_search_command_handler_tests;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Subcommand)]
|
||||
pub enum LidarrManualSearchCommand {
|
||||
#[command(
|
||||
about = "Trigger a manual search of releases for the given album corresponding to the artist with the given ID"
|
||||
)]
|
||||
Album {
|
||||
#[arg(
|
||||
long,
|
||||
help = "The Lidarr ID of the artist whose releases you wish to fetch and list",
|
||||
required = true
|
||||
)]
|
||||
artist_id: i64,
|
||||
#[arg(long, help = "The Lidarr album ID to search for", required = true)]
|
||||
album_id: i64,
|
||||
},
|
||||
#[command(
|
||||
about = "Trigger a manual search of discography releases for the given artist corresponding to the artist with the given ID."
|
||||
)]
|
||||
@@ -59,6 +72,27 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, LidarrManualSearchCommand>
|
||||
|
||||
async fn handle(self) -> Result<String> {
|
||||
let result = match self.command {
|
||||
LidarrManualSearchCommand::Album {
|
||||
artist_id,
|
||||
album_id,
|
||||
} => {
|
||||
println!("Searching for album releases. This may take a minute...");
|
||||
match self
|
||||
.network
|
||||
.handle_network_event(LidarrEvent::GetAlbumReleases(artist_id, album_id).into())
|
||||
.await
|
||||
{
|
||||
Ok(Serdeable::Lidarr(LidarrSerdeable::Releases(releases_vec))) => {
|
||||
let albums_vec: Vec<LidarrRelease> = releases_vec
|
||||
.into_iter()
|
||||
.filter(|release| !release.discography)
|
||||
.collect();
|
||||
serde_json::to_string_pretty(&albums_vec)?
|
||||
}
|
||||
Err(e) => return Err(e),
|
||||
_ => serde_json::to_string_pretty(&json!({"message": "Failed to parse response"}))?,
|
||||
}
|
||||
}
|
||||
LidarrManualSearchCommand::Discography { artist_id } => {
|
||||
println!("Searching for artist discography releases. This may take a minute...");
|
||||
match self
|
||||
|
||||
Reference in New Issue
Block a user