fix: match 'completed' download state and prefer format over quality
The API returns download.state='completed' but convert_album only
matched 'downloaded', causing monitored+downloaded albums to display
as Wanted with 0 tracks. Also prefer download.format ('FLAC') over
download.quality (empty) for the quality display.
This commit is contained in:
@@ -22,13 +22,12 @@ pub fn convert_album(detail: AlbumDetail) -> Album {
|
||||
let monitored = monitor_state.is_monitored();
|
||||
|
||||
let (have, status, quality) = if let Some(download) = detail.download {
|
||||
let have = if download.state == "downloaded" {
|
||||
detail.total_tracks as u16
|
||||
} else {
|
||||
0
|
||||
let have = match download.state.as_str() {
|
||||
"completed" | "downloaded" => detail.total_tracks as u16,
|
||||
_ => 0,
|
||||
};
|
||||
let status = match download.state.as_str() {
|
||||
"downloaded" => AlbumStatus::Complete,
|
||||
"completed" | "downloaded" => AlbumStatus::Complete,
|
||||
"downloading" => AlbumStatus::Partial,
|
||||
_ => {
|
||||
if monitored {
|
||||
@@ -38,10 +37,12 @@ pub fn convert_album(detail: AlbumDetail) -> Album {
|
||||
}
|
||||
}
|
||||
};
|
||||
let quality = if download.quality.is_empty() {
|
||||
"—".to_string()
|
||||
} else {
|
||||
let quality = if !download.format.is_empty() {
|
||||
download.format
|
||||
} else if !download.quality.is_empty() {
|
||||
download.quality
|
||||
} else {
|
||||
"—".to_string()
|
||||
};
|
||||
(have, status, quality)
|
||||
} else {
|
||||
|
||||
@@ -16,6 +16,10 @@ pub struct IndexerOptions {
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct MonitorAlbumResponse {
|
||||
#[prost(message, optional, tag = "1")]
|
||||
pub album: ::core::option::Option<AlbumDetail>,
|
||||
#[prost(message, optional, tag = "2")]
|
||||
pub artist: ::core::option::Option<ArtistSummary>,
|
||||
#[prost(message, optional, tag = "3")]
|
||||
pub release: ::core::option::Option<MonitoredRelease>,
|
||||
}
|
||||
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
|
||||
|
||||
Reference in New Issue
Block a user