pinakes-core: unify book metadata extraction; remove ExtractedBookMetadata
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ifd6e66515b9ff78a4bb13eba47b9b2cf6a6a6964
This commit is contained in:
parent
9c67c81a79
commit
8f2b44b50c
3 changed files with 30 additions and 20 deletions
|
|
@ -417,6 +417,10 @@ pub struct SavedSearch {
|
|||
// Book Management Types
|
||||
|
||||
/// Metadata for book-type media.
|
||||
///
|
||||
/// Used both as a DB record (with populated `media_id`, `created_at`,
|
||||
/// `updated_at`) and as an extraction result (with placeholder values for
|
||||
/// those fields when the record has not yet been persisted).
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct BookMetadata {
|
||||
pub media_id: MediaId,
|
||||
|
|
@ -435,6 +439,28 @@ pub struct BookMetadata {
|
|||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
impl Default for BookMetadata {
|
||||
fn default() -> Self {
|
||||
let now = Utc::now();
|
||||
Self {
|
||||
media_id: MediaId(uuid::Uuid::nil()),
|
||||
isbn: None,
|
||||
isbn13: None,
|
||||
publisher: None,
|
||||
language: None,
|
||||
page_count: None,
|
||||
publication_date: None,
|
||||
series_name: None,
|
||||
series_index: None,
|
||||
format: None,
|
||||
authors: Vec::new(),
|
||||
identifiers: HashMap::new(),
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Information about a book author.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct AuthorInfo {
|
||||
|
|
@ -476,22 +502,6 @@ impl AuthorInfo {
|
|||
}
|
||||
}
|
||||
|
||||
/// Book metadata extracted from files (without database-specific fields)
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
pub struct ExtractedBookMetadata {
|
||||
pub isbn: Option<String>,
|
||||
pub isbn13: Option<String>,
|
||||
pub publisher: Option<String>,
|
||||
pub language: Option<String>,
|
||||
pub page_count: Option<i32>,
|
||||
pub publication_date: Option<chrono::NaiveDate>,
|
||||
pub series_name: Option<String>,
|
||||
pub series_index: Option<f64>,
|
||||
pub format: Option<String>,
|
||||
pub authors: Vec<AuthorInfo>,
|
||||
pub identifiers: HashMap<String, Vec<String>>,
|
||||
}
|
||||
|
||||
/// Reading progress for a book.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ReadingProgress {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue